mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-28 03:42:00 +00:00
feat: Adding support for metadata in RAG insertion and querying
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
473a07f624
commit
e50a546bc0
8 changed files with 149 additions and 25 deletions
7
docs/_static/llama-stack-spec.html
vendored
7
docs/_static/llama-stack-spec.html
vendored
|
|
@ -11133,13 +11133,18 @@
|
|||
"max_chunks": {
|
||||
"type": "integer",
|
||||
"default": 5
|
||||
},
|
||||
"include_metadata_in_content": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"query_generator_config",
|
||||
"max_tokens_in_context",
|
||||
"max_chunks"
|
||||
"max_chunks",
|
||||
"include_metadata_in_content"
|
||||
],
|
||||
"title": "RAGQueryConfig"
|
||||
},
|
||||
|
|
|
|||
4
docs/_static/llama-stack-spec.yaml
vendored
4
docs/_static/llama-stack-spec.yaml
vendored
|
|
@ -7690,11 +7690,15 @@ components:
|
|||
max_chunks:
|
||||
type: integer
|
||||
default: 5
|
||||
include_metadata_in_content:
|
||||
type: boolean
|
||||
default: false
|
||||
additionalProperties: false
|
||||
required:
|
||||
- query_generator_config
|
||||
- max_tokens_in_context
|
||||
- max_chunks
|
||||
- include_metadata_in_content
|
||||
title: RAGQueryConfig
|
||||
RAGQueryGeneratorConfig:
|
||||
oneOf:
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ chunks = [
|
|||
"mime_type": "text/plain",
|
||||
"metadata": {
|
||||
"document_id": "doc1",
|
||||
"author": "Jane Doe",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
|
@ -98,6 +99,17 @@ results = client.tool_runtime.rag_tool.query(
|
|||
)
|
||||
```
|
||||
|
||||
You can configure adding metadata to the context if you find it useful for your application. Simply add:
|
||||
```python
|
||||
# Query documents
|
||||
results = client.tool_runtime.rag_tool.query(
|
||||
vector_db_ids=[vector_db_id],
|
||||
content="What do you know about...",
|
||||
query_config={
|
||||
"include_metadata_in_content": True,
|
||||
},
|
||||
)
|
||||
```
|
||||
### Building RAG-Enhanced Agents
|
||||
|
||||
One of the most powerful patterns is combining agents with RAG capabilities. Here's a complete example:
|
||||
|
|
@ -115,6 +127,12 @@ agent = Agent(
|
|||
"name": "builtin::rag/knowledge_search",
|
||||
"args": {
|
||||
"vector_db_ids": [vector_db_id],
|
||||
# Defaults
|
||||
"query_config": {
|
||||
"chunk_size_in_tokens": 512,
|
||||
"chunk_overlap_in_tokens": 0,
|
||||
"include_metadata_in_content": False,
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue