Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update rag.md example code to prevent errors #1009

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions docs/source/building_applications/rag.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ chunks = [
"content": "Your document text here",
"mime_type": "text/plain",
},
...,
]
client.vector_io.insert(vector_db_id, chunks)
client.vector_io.insert(vector_db_id=vector_db_id, chunks=chunks)

# You can then query for these chunks
chunks_response = client.vector_io.query(
vector_db_id, query="What do you know about..."
vector_db_id=vector_db_id, query="What do you know about..."
)
```

Expand Down Expand Up @@ -72,8 +71,8 @@ client.tool_runtime.rag_tool.insert(

# Query documents
results = client.tool_runtime.rag_tool.query(
vector_db_id=vector_db_id,
query="What do you know about...",
vector_db_ids=[vector_db_id],
content="What do you know about...",
)
```

Expand All @@ -82,10 +81,14 @@ results = client.tool_runtime.rag_tool.query(
One of the most powerful patterns is combining agents with RAG capabilities. Here's a complete example:

```python
from llama_stack_client.types.agent_create_params import AgentConfig
from llama_stack_client.lib.agents.agent import Agent

# Configure agent with memory
agent_config = AgentConfig(
model="Llama3.2-3B-Instruct",
model="meta-llama/Llama-3.2-3B-Instruct",
instructions="You are a helpful assistant",
enable_session_persistence=False,
toolgroups=[
{
"name": "builtin::rag",
Expand All @@ -105,10 +108,10 @@ response = agent.create_turn(
{"role": "user", "content": "I am providing some documents for reference."}
],
documents=[
dict(
content="https://raw.githubusercontent.com/example/doc.rst",
mime_type="text/plain",
)
{
"content": "https://raw.githubusercontent.com/example/doc.rst",
"mime_type": "text/plain",
}
],
session_id=session_id,
)
Expand Down