chore: Rename RagTool FileSearchTool

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-10-24 16:52:58 -04:00
parent 4566eebe05
commit 2d9163529a
288 changed files with 16985 additions and 2071 deletions

View file

@ -4,5 +4,5 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from .rag_tool import *
from .file_search_tool import *
from .tools import *

View file

@ -76,7 +76,7 @@ class RAGDocument(BaseModel):
@json_schema_type
class RAGQueryResult(BaseModel):
class FileSearchResult(BaseModel):
"""Result of a RAG query containing retrieved content and metadata.
:param content: (Optional) The retrieved content from the query
@ -88,7 +88,7 @@ class RAGQueryResult(BaseModel):
@json_schema_type
class RAGQueryGenerator(Enum):
class FileSearchGenerator(Enum):
"""Types of query generators for RAG systems.
:cvar default: Default query generator using simple text processing
@ -102,7 +102,7 @@ class RAGQueryGenerator(Enum):
@json_schema_type
class RAGSearchMode(StrEnum):
class FileSearchMode(StrEnum):
"""
Search modes for RAG query retrieval:
- VECTOR: Uses vector similarity search for semantic matching
@ -116,7 +116,7 @@ class RAGSearchMode(StrEnum):
@json_schema_type
class DefaultRAGQueryGeneratorConfig(BaseModel):
class DefaultFileSearchGeneratorConfig(BaseModel):
"""Configuration for the default RAG query generator.
:param type: Type of query generator, always 'default'
@ -128,8 +128,8 @@ class DefaultRAGQueryGeneratorConfig(BaseModel):
@json_schema_type
class LLMRAGQueryGeneratorConfig(BaseModel):
"""Configuration for the LLM-based RAG query generator.
class LLMFileSearchGeneratorConfig(BaseModel):
"""Configuration for the LLM-based File Search generator.
:param type: Type of query generator, always 'llm'
:param model: Name of the language model to use for query generation
@ -141,15 +141,15 @@ class LLMRAGQueryGeneratorConfig(BaseModel):
template: str
RAGQueryGeneratorConfig = Annotated[
DefaultRAGQueryGeneratorConfig | LLMRAGQueryGeneratorConfig,
FileSearchGeneratorConfig = Annotated[
DefaultFileSearchGeneratorConfig | LLMFileSearchGeneratorConfig,
Field(discriminator="type"),
]
register_schema(RAGQueryGeneratorConfig, name="RAGQueryGeneratorConfig")
register_schema(FileSearchGeneratorConfig, name="FileSearchGeneratorConfig")
@json_schema_type
class RAGQueryConfig(BaseModel):
class FileSearchConfig(BaseModel):
"""
Configuration for the RAG query generation.
@ -165,11 +165,11 @@ class RAGQueryConfig(BaseModel):
# This config defines how a query is generated using the messages
# for memory bank retrieval.
query_generator_config: RAGQueryGeneratorConfig = Field(default=DefaultRAGQueryGeneratorConfig())
query_generator_config: FileSearchGeneratorConfig = Field(default=DefaultFileSearchGeneratorConfig())
max_tokens_in_context: int = 4096
max_chunks: int = 5
chunk_template: str = "Result {index}\nContent: {chunk.content}\nMetadata: {metadata}\n"
mode: RAGSearchMode | None = RAGSearchMode.VECTOR
mode: FileSearchMode | None = FileSearchMode.VECTOR
ranker: Ranker | None = Field(default=None) # Only used for hybrid mode
@field_validator("chunk_template")
@ -185,8 +185,8 @@ class RAGQueryConfig(BaseModel):
@runtime_checkable
@trace_protocol
class RAGToolRuntime(Protocol):
@webmethod(route="/tool-runtime/rag-tool/insert", method="POST", level=LLAMA_STACK_API_V1)
class FileSearchToolRuntime(Protocol):
@webmethod(route="/tool-runtime/file_search-tool/insert", method="POST", level=LLAMA_STACK_API_V1)
async def insert(
self,
documents: list[RAGDocument],
@ -201,18 +201,18 @@ class RAGToolRuntime(Protocol):
"""
...
@webmethod(route="/tool-runtime/rag-tool/query", method="POST", level=LLAMA_STACK_API_V1)
@webmethod(route="/tool-runtime/file_search-tool/query", method="POST", level=LLAMA_STACK_API_V1)
async def query(
self,
content: InterleavedContent,
vector_db_ids: list[str],
query_config: RAGQueryConfig | None = None,
) -> RAGQueryResult:
query_config: FileSearchConfig | None = None,
) -> FileSearchResult:
"""Query the RAG system for context; typically invoked by the agent.
:param content: The query content to search for in the indexed documents
:param vector_db_ids: List of vector database IDs to search within
:param query_config: (Optional) Configuration parameters for the query operation
:returns: RAGQueryResult containing the retrieved content and metadata
:returns: FileSearchResult containing the retrieved content and metadata
"""
...

View file

@ -16,7 +16,7 @@ from llama_stack.apis.version import LLAMA_STACK_API_V1
from llama_stack.core.telemetry.trace_protocol import trace_protocol
from llama_stack.schema_utils import json_schema_type, webmethod
from .rag_tool import RAGToolRuntime
from .file_search_tool import FileSearchToolRuntime
@json_schema_type
@ -195,7 +195,7 @@ class SpecialToolGroup(Enum):
class ToolRuntime(Protocol):
tool_store: ToolStore | None = None
rag_tool: RAGToolRuntime | None = None
rag_tool: FileSearchToolRuntime | None = None
# TODO: This needs to be renamed once OPEN API generator name conflict issue is fixed.
@webmethod(route="/tool-runtime/list-tools", method="GET", level=LLAMA_STACK_API_V1)