Skip to content

Commit b3a8930

Browse files
committed
fix OpenAI file search to use queries and results fields
Updated _map_file_search_tool_call to use the actual SDK structure: - Store queries on BuiltinToolCallPart args - Store results on BuiltinToolReturnPart content - Removed incorrect action field that doesn't exist in the SDK
1 parent 8eba82d commit b3a8930

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ async def _map_messages( # noqa: C901
14891489
responses.ResponseFileSearchToolCallParam,
14901490
{
14911491
'id': item.tool_call_id,
1492-
'action': args,
1492+
'queries': args.get('queries', []),
14931493
'status': 'completed',
14941494
'type': 'file_search_call',
14951495
},
@@ -2266,20 +2266,19 @@ def _map_file_search_tool_call(
22662266
item: responses.ResponseFileSearchToolCall,
22672267
provider_name: str,
22682268
) -> tuple[BuiltinToolCallPart, BuiltinToolReturnPart]:
2269-
args: dict[str, Any] | None = None
2269+
args = {'queries': item.queries}
22702270

2271-
result = {
2271+
result: dict[str, Any] = {
22722272
'status': item.status,
22732273
}
2274-
2275-
if action := item.action: # type: ignore[reportAttributeAccessIssue]
2276-
args = action.model_dump(mode='json') # type: ignore[reportUnknownMemberType]
2274+
if item.results is not None:
2275+
result['results'] = [r.model_dump(mode='json') for r in item.results]
22772276

22782277
return (
22792278
BuiltinToolCallPart(
22802279
tool_name=FileSearchTool.kind,
22812280
tool_call_id=item.id,
2282-
args=args, # type: ignore[reportUnknownArgumentType]
2281+
args=args,
22832282
provider_name=provider_name,
22842283
),
22852284
BuiltinToolReturnPart(

0 commit comments

Comments
 (0)