RAG Data Models¶
Centralized documentation for core RAG Pydantic models used across the API.
These models define query parameters, responses, and hit structures for retrieval-augmented generation.
Query Request¶
RAGQueryRequest ¶
Bases: BaseModel
Query parameters for RAG retrieval.
Attributes:
| Name | Type | Description |
|---|---|---|
text | str | Query text to search for |
top_k | int | Number of top results to retrieve (default: 5) |
filters | str | None | Optional SQL WHERE clause for filtering (e.g., "category = 'programming'") |
Examples:
| Python Console Session | |
|---|---|
| Python Console Session | |
|---|---|
| Python Console Session | |
|---|---|
Query Response¶
RAGQueryResponse ¶
Bases: BaseModel
RAG response with ranked hits.
Attributes:
| Name | Type | Description |
|---|---|---|
hits | list[RAGHit] | List of retrieved chunks, ranked by similarity |
Retrieval Hit¶
RAGHit ¶
Bases: BaseModel
Single retrieval result (one chunk).
Represents a chunk of text retrieved from the RAG knowledge base, along with metadata and similarity score.
Attributes:
| Name | Type | Description |
|---|---|---|
document_id | str | Original Document.document_id that this chunk belongs to |
chunk_id | str | ID of the specific chunk (e.g. "{document_id}:{i}") |
text | str | Chunk text content |
metadata | dict[str, Any] | Merged document and chunk metadata |
score | float | Similarity score (higher = better, cosine similarity: 0.0-1.0) |