docs/examples/llm/netmind.ipynb
This notebook shows how to use Netmind AI as an LLM. Check out the full list of models netmind.ai.
Visit https://www.netmind.ai/ and sign up to get an API key.
If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.
%pip install llama-index-llms-netmind
!pip install llama-index
from llama_index.llms.netmind import NetmindLLM
# set api key in env or in llm
# import os
# os.environ["NETMIND_API_KEY"] = "your api key"
llm = NetmindLLM(
model="meta-llama/Llama-3.3-70B-Instruct", api_key="your api key"
)
resp = llm.complete("Is 9.9 or 9.11 bigger?")
print(resp)
chat with a list of messagesfrom llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.chat(messages)
print(resp)
Using stream_complete endpoint
response = llm.stream_complete("Who is Paul Graham?")
for r in response:
print(r.delta, end="")
Using stream_chat endpoint
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.stream_chat(messages)
for r in resp:
print(r.delta, end="")