File size: 501 Bytes
7f5ef51 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from pinecone import Pinecone
from pinecone_plugins.assistant.models.chat import Message
pc = Pinecone(api_key=pcsk_3MGbHp_26EnMmQQm72aznGSw4vP3WbWLfbeHjeFbNXWWS8pG5kdwSi7aVmGcL3GmH4JokU
)
assistant = pc.assistant.Assistant(assistant_name="codette")
msg = Message(content="How old is the earth?")
resp = assistant.chat(messages=[msg])
print(resp["message"]["content"])
# With streaming
chunks = assistant.chat(messages=[msg], stream=True)
for chunk in chunks:
if chunk:
print(chunk)
|