Responses file_search wire up additional params

This adds passing of max_num_results from the file_search tool call
into the knowledge_search tool, as well as logs warnings if the
filters or ranking_options params are used since those are not wired
up yet. And, it adds the API surface for filters and ranking options
so we don't have to generate clients again as we add that.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
Ben Browning 2025-06-12 07:05:58 -04:00
parent 788d34d8b4
commit 8a5ea57253
4 changed files with 53 additions and 2 deletions

View file

@ -7255,6 +7255,35 @@
"type": "string" "type": "string"
} }
}, },
"filters": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "null"
},
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array"
},
{
"type": "object"
}
]
}
},
"max_num_results": {
"type": "integer",
"default": 10
},
"ranking_options": { "ranking_options": {
"type": "object", "type": "object",
"properties": { "properties": {

View file

@ -5157,6 +5157,19 @@ components:
type: array type: array
items: items:
type: string type: string
filters:
type: object
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
max_num_results:
type: integer
default: 10
ranking_options: ranking_options:
type: object type: object
properties: properties:

View file

@ -409,8 +409,9 @@ class FileSearchRankingOptions(BaseModel):
class OpenAIResponseInputToolFileSearch(BaseModel): class OpenAIResponseInputToolFileSearch(BaseModel):
type: Literal["file_search"] = "file_search" type: Literal["file_search"] = "file_search"
vector_store_ids: list[str] vector_store_ids: list[str]
filters: dict[str, Any] | None = None
max_num_results: int | None = Field(default=10, ge=1, le=50)
ranking_options: FileSearchRankingOptions | None = None ranking_options: FileSearchRankingOptions | None = None
# TODO: add filters, max_num_results
class ApprovalFilter(BaseModel): class ApprovalFilter(BaseModel):

View file

@ -64,7 +64,7 @@ from llama_stack.apis.inference.inference import (
OpenAIToolMessageParam, OpenAIToolMessageParam,
OpenAIUserMessageParam, OpenAIUserMessageParam,
) )
from llama_stack.apis.tools.tools import ToolGroups, ToolRuntime from llama_stack.apis.tools import RAGQueryConfig, ToolGroups, ToolRuntime
from llama_stack.log import get_logger from llama_stack.log import get_logger
from llama_stack.models.llama.datatypes import ToolDefinition, ToolParamDefinition from llama_stack.models.llama.datatypes import ToolDefinition, ToolParamDefinition
from llama_stack.providers.utils.inference.openai_compat import convert_tooldef_to_openai_tool from llama_stack.providers.utils.inference.openai_compat import convert_tooldef_to_openai_tool
@ -699,7 +699,15 @@ class OpenAIResponsesImpl:
t for t in ctx.response_tools if isinstance(t, OpenAIResponseInputToolFileSearch) t for t in ctx.response_tools if isinstance(t, OpenAIResponseInputToolFileSearch)
) )
if response_file_search_tool: if response_file_search_tool:
if response_file_search_tool.filters:
logger.warning("Filters are not yet supported for file_search tool")
if response_file_search_tool.ranking_options:
logger.warning("Ranking options are not yet supported for file_search tool")
tool_kwargs["vector_db_ids"] = response_file_search_tool.vector_store_ids tool_kwargs["vector_db_ids"] = response_file_search_tool.vector_store_ids
tool_kwargs["query_config"] = RAGQueryConfig(
mode="vector",
max_chunks=response_file_search_tool.max_num_results,
)
result = await self.tool_runtime_api.invoke_tool( result = await self.tool_runtime_api.invoke_tool(
tool_name=function.name, tool_name=function.name,
kwargs=tool_kwargs, kwargs=tool_kwargs,