Python: Fix sample bugs in file search and web search samples (#4049)

- Fix file search samples: return vector_store.id string instead of
  Content object to avoid JSON serialization error
- Fix web search sample: use correct web_search_options parameter for
  ChatClient instead of ResponsesClient's user_location parameter
- Fix assistants client: pass tool_resources from options to run_options
  so vector store IDs reach thread creation
- Add error handling for cleanup in Azure file search sample

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Giles Odigwe
2026-02-18 12:24:16 -08:00
committed by GitHub
Unverified
parent c23bc1371c
commit 1b87a07377
4 changed files with 23 additions and 11 deletions
@@ -670,6 +670,7 @@ class OpenAIAssistantsClient( # type: ignore[misc]
tool_choice = options.get("tool_choice")
tools = options.get("tools")
response_format = options.get("response_format")
tool_resources = options.get("tool_resources")
if max_tokens is not None:
run_options["max_completion_tokens"] = max_tokens
@@ -683,6 +684,9 @@ class OpenAIAssistantsClient( # type: ignore[misc]
if allow_multiple_tool_calls is not None:
run_options["parallel_tool_calls"] = allow_multiple_tool_calls
if tool_resources is not None:
run_options["tool_resources"] = tool_resources
tool_mode = validate_tool_mode(tool_choice)
tool_definitions: list[MutableMapping[str, Any]] = []
# Always include tools if provided, regardless of tool_choice