diff --git a/google/genai/_gaos/resources/interactions/__init__.py b/google/genai/_gaos/resources/interactions/__init__.py index 1a58f6bca..728ff78ca 100644 --- a/google/genai/_gaos/resources/interactions/__init__.py +++ b/google/genai/_gaos/resources/interactions/__init__.py @@ -112,7 +112,7 @@ from ...types.interactions.mediaresolution import MediaResolution from ...types.interactions.modalitytokens import ModalityTokens from ...types.interactions.model import Model -from ...types.interactions.modeloutputstep import ModelOutputStep +from ...types.interactions.modeloutputstep import ModelOutputStep, ModelOutputStepError from ...types.interactions.parallelaisearchconfig import ParallelAISearchConfig from ...types.interactions.placecitation import PlaceCitation from ...types.interactions.ragresource import RagResource @@ -270,6 +270,7 @@ "ModalityTokens", "Model", "ModelOutputStep", + "ModelOutputStepError", "ModelParam", "ParallelAISearchConfig", "PlaceCitation", diff --git a/google/genai/_gaos/types/interactions/__init__.py b/google/genai/_gaos/types/interactions/__init__.py index f4a711f23..2640ae402 100644 --- a/google/genai/_gaos/types/interactions/__init__.py +++ b/google/genai/_gaos/types/interactions/__init__.py @@ -274,7 +274,12 @@ from .mediaresolution import MediaResolution from .modalitytokens import ModalityTokens, ModalityTokensParam from .model import Model - from .modeloutputstep import ModelOutputStep, ModelOutputStepParam + from .modeloutputstep import ( + ModelOutputStep, + ModelOutputStepError, + ModelOutputStepErrorParam, + ModelOutputStepParam, + ) from .parallelaisearchconfig import ( ParallelAISearchConfig, ParallelAISearchConfigParam, @@ -573,6 +578,8 @@ "ModalityTokensParam", "Model", "ModelOutputStep", + "ModelOutputStepError", + "ModelOutputStepErrorParam", "ModelOutputStepParam", "Network", "NetworkEnum", @@ -915,6 +922,8 @@ "ModalityTokensParam": ".modalitytokens", "Model": ".model", "ModelOutputStep": ".modeloutputstep", + "ModelOutputStepError": ".modeloutputstep", + "ModelOutputStepErrorParam": ".modeloutputstep", "ModelOutputStepParam": ".modeloutputstep", "ParallelAISearchConfig": ".parallelaisearchconfig", "ParallelAISearchConfigParam": ".parallelaisearchconfig", diff --git a/google/genai/_gaos/types/interactions/modeloutputstep.py b/google/genai/_gaos/types/interactions/modeloutputstep.py index 80e04566b..e2dde0aca 100644 --- a/google/genai/_gaos/types/interactions/modeloutputstep.py +++ b/google/genai/_gaos/types/interactions/modeloutputstep.py @@ -23,15 +23,67 @@ import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import List, Literal, Optional +from typing import Any, Dict, List, Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict +class ModelOutputStepErrorParam(TypedDict): + r"""The error result of the operation in case of failure or cancellation.""" + + code: NotRequired[int] + r"""The status code, which should be an enum value of google.rpc.Code.""" + message: NotRequired[str] + r"""A developer-facing error message, which should be in English. Any + user-facing error message should be localized and sent in the + google.rpc.Status.details field, or localized by the client. + """ + details: NotRequired[List[Dict[str, Any]]] + r"""A list of messages that carry the error details. There is a common set of + message types for APIs to use. + """ + + +class ModelOutputStepError(BaseModel): + r"""The error result of the operation in case of failure or cancellation.""" + + code: Optional[int] = None + r"""The status code, which should be an enum value of google.rpc.Code.""" + + message: Optional[str] = None + r"""A developer-facing error message, which should be in English. Any + user-facing error message should be localized and sent in the + google.rpc.Status.details field, or localized by the client. + """ + + details: Optional[List[Dict[str, Any]]] = None + r"""A list of messages that carry the error details. There is a common set of + message types for APIs to use. + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["code", "message", "details"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + class ModelOutputStepParam(TypedDict): r"""Output generated by the model.""" type: Literal["model_output"] content: NotRequired[List[ContentParam]] + error: NotRequired[ModelOutputStepErrorParam] + r"""The error result of the operation in case of failure or cancellation.""" class ModelOutputStep(BaseModel): @@ -46,9 +98,12 @@ class ModelOutputStep(BaseModel): content: Optional[List[Content]] = None + error: Optional[ModelOutputStepError] = None + r"""The error result of the operation in case of failure or cancellation.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["content"]) + optional_fields = set(["content", "error"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/step.py b/google/genai/_gaos/types/interactions/step.py index d8b1bf02e..4cb637747 100644 --- a/google/genai/_gaos/types/interactions/step.py +++ b/google/genai/_gaos/types/interactions/step.py @@ -52,9 +52,9 @@ StepParam = TypeAliasType( "StepParam", Union[ - ModelOutputStepParam, UserInputStepParam, FileSearchCallStepParam, + ModelOutputStepParam, ThoughtStepParam, FileSearchResultStepParam, CodeExecutionCallStepParam,