Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions google/genai/_interactions/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
from datetime import date, datetime
from typing_extensions import Self, Literal
from typing_extensions import Self, Literal, TypedDict

import pydantic
from pydantic.fields import FieldInfo
Expand Down Expand Up @@ -146,6 +146,10 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
return model.model_dump_json(indent=indent)


class _ModelDumpKwargs(TypedDict, total=False):
by_alias: bool


def model_dump(
model: pydantic.BaseModel,
*,
Expand All @@ -157,14 +161,17 @@ def model_dump(
by_alias: bool | None = None,
) -> dict[str, Any]:
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
kwargs: _ModelDumpKwargs = {}
if by_alias is not None:
kwargs["by_alias"] = by_alias
return model.model_dump(
mode=mode,
exclude=exclude,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
# warnings are not supported in Pydantic v1
warnings=True if PYDANTIC_V1 else warnings,
by_alias=by_alias,
**kwargs,
)
return cast(
"dict[str, Any]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CodeExecutionCallContent(BaseModel):
"""A unique ID for this specific tool call."""

arguments: CodeExecutionCallArguments
"""The arguments to pass to the code execution."""
"""Required. The arguments to pass to the code execution."""

type: Literal["code_execution_call"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CodeExecutionCallContentParam(TypedDict, total=False):
"""A unique ID for this specific tool call."""

arguments: Required[CodeExecutionCallArgumentsParam]
"""The arguments to pass to the code execution."""
"""Required. The arguments to pass to the code execution."""

type: Required[Literal["code_execution_call"]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CodeExecutionResultContent(BaseModel):
"""ID to match the ID from the code execution call block."""

result: str
"""The output of the code execution."""
"""Required. The output of the code execution."""

type: Literal["code_execution_result"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CodeExecutionResultContentParam(TypedDict, total=False):
"""ID to match the ID from the code execution call block."""

result: Required[str]
"""The output of the code execution."""
"""Required. The output of the code execution."""

type: Required[Literal["code_execution_result"]]

Expand Down
12 changes: 6 additions & 6 deletions google/genai/_interactions/types/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@
VideoContent,
ThoughtContent,
FunctionCallContent,
FunctionResultContent,
CodeExecutionCallContent,
CodeExecutionResultContent,
URLContextCallContent,
URLContextResultContent,
MCPServerToolCallContent,
GoogleSearchCallContent,
FileSearchCallContent,
GoogleMapsCallContent,
FunctionResultContent,
CodeExecutionResultContent,
URLContextResultContent,
GoogleSearchResultContent,
MCPServerToolCallContent,
MCPServerToolResultContent,
FileSearchCallContent,
FileSearchResultContent,
GoogleMapsCallContent,
GoogleMapsResultContent,
],
PropertyInfo(discriminator="type"),
Expand Down
Loading
Loading