Using Pinecone Assistant
1. Understanding Pinecone Assistant
| Feature | Description |
|---|---|
| Managed RAG | Document upload → chat-ready |
| Built-in | Chunking, embedding, retrieval, LLM |
| Citations | Returns source references |
| No infra | No need to manage index directly |
2. Creating Assistant
Example: Create
from pinecone import Pinecone
pc = Pinecone(api_key="...")
assistant = pc.assistant.create_assistant(
assistant_name="docs-bot",
instructions="Answer using only uploaded docs.",
region="us",
)
3. Uploading Documents
Example: Upload
a = pc.assistant.Assistant("docs-bot")
a.upload_file(file_path="./manual.pdf", metadata={"product": "v3"})
| Format | Supported |
|---|---|
| Yes | |
| DOCX | Yes |
| TXT/MD | Yes |
| JSON | Yes |
4. Chatting with Assistant
Example: Chat
from pinecone_plugins.assistant.models.chat import Message
msgs = [Message(role="user", content="How do I install?")]
resp = a.chat(messages=msgs)
print(resp.message.content)
for c in resp.citations: print(c.references)
5. Configuring Assistant Settings
| Setting | Description |
|---|---|
instructions | System prompt |
model | gpt-4o / claude-3.5-sonnet |
region | us / eu |
metadata | Assistant tagging |
6. Managing Document Collections
Example: List + Delete
files = a.list_files()
for f in files:
print(f.id, f.name, f.status)
a.delete_file(file_id="abc-123")
7. Handling Chat History
Example: Multi-Turn
history = []
def ask(q):
history.append(Message(role="user", content=q))
r = a.chat(messages=history)
history.append(Message(role="assistant", content=r.message.content))
return r.message.content
8. Customizing Response Behavior
| Setting | Effect |
|---|---|
| instructions | Persona, tone, scope |
| temperature | Per-chat creativity |
| filter | Limit retrieval to matching docs |
9. Monitoring Assistant Usage
| Metric | Source |
|---|---|
| Tokens used | Pinecone console / API usage |
| Files indexed | list_files() |
| Chat volume | Application log |
10. Optimizing Assistant Performance
| Tip | Effect |
|---|---|
| Smaller knowledge base | Higher relevance |
| Clear instructions | Reduces hallucinations |
| File metadata filters | Scoped retrieval |
| Streaming | Faster perceived latency |