Skip to content

Commit c2765ac

Browse files
committed
upgrade google-genai SDK to v1.49.0 with file_search support
Now using the official FileSearchDict from the SDK instead of our custom TypedDict. The SDK added file_search tool support in v1.49.0, so we can remove the workaround and type: ignore comment.
1 parent 9b5bb54 commit c2765ac

File tree

4 files changed

+4229
-4233
lines changed

4 files changed

+4229
-4233
lines changed

pydantic_ai_slim/pydantic_ai/models/google.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, Literal, cast, overload
99
from uuid import uuid4
1010

11-
from typing_extensions import TypedDict, assert_never
11+
from typing_extensions import assert_never
1212

1313
from .. import UnexpectedModelBehavior, _utils, usage
1414
from .._output import OutputObjectDefinition
@@ -61,6 +61,7 @@
6161
ExecutableCode,
6262
ExecutableCodeDict,
6363
FileDataDict,
64+
FileSearchDict,
6465
FinishReason as GoogleFinishReason,
6566
FunctionCallDict,
6667
FunctionCallingConfigDict,
@@ -92,14 +93,6 @@
9293
) from _import_error
9394

9495

95-
# FileSearchDict will be available in future google-genai versions
96-
# For now, we define it ourselves to match the expected structure
97-
class FileSearchDict(TypedDict, total=False):
98-
"""Configuration for file search tool in Google Gemini."""
99-
100-
file_search_store_names: list[str]
101-
102-
10396
LatestGoogleModelNames = Literal[
10497
'gemini-2.0-flash',
10598
'gemini-2.0-flash-lite',
@@ -353,7 +346,7 @@ def _get_tools(self, model_request_parameters: ModelRequestParameters) -> list[T
353346
tools.append(ToolDict(code_execution=ToolCodeExecutionDict()))
354347
elif isinstance(tool, FileSearchTool):
355348
file_search_config = FileSearchDict(file_search_store_names=tool.vector_store_ids)
356-
tools.append(ToolDict(file_search=file_search_config)) # type: ignore[call-arg]
349+
tools.append(ToolDict(file_search=file_search_config))
357350
elif isinstance(tool, ImageGenerationTool): # pragma: no branch
358351
if not self.profile.supports_image_output:
359352
raise UserError(

pydantic_ai_slim/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ logfire = ["logfire[httpx]>=3.14.1"]
7070
openai = ["openai>=1.107.2"]
7171
cohere = ["cohere>=5.18.0; platform_system != 'Emscripten'"]
7272
vertexai = ["google-auth>=2.36.0", "requests>=2.32.2"]
73-
google = ["google-genai>=1.46.0"]
73+
google = ["google-genai>=1.49.0"]
7474
anthropic = ["anthropic>=0.70.0"]
7575
groq = ["groq>=0.25.0"]
7676
mistral = ["mistralai>=1.9.10"]

tests/models/test_google.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,9 +3203,8 @@ def _generate_response_with_texts(response_id: str, texts: list[str]) -> Generat
32033203
)
32043204

32053205

3206-
# Integration tests for FileSearchTool are skipped because google-genai SDK v1.46.0
3207-
# does not support file_search as a tool type yet. The code is ready for when SDK adds support.
3208-
# Unit tests below validate the parsing logic.
3206+
# Unit tests below validate the FileSearchTool parsing logic.
3207+
# Integration tests require setting up file search stores via the Google API.
32093208

32103209

32113210
def test_map_file_search_grounding_metadata():

0 commit comments

Comments
 (0)