Skip to content

Commit 90f109f

Browse files
MarkDaoustcopybara-github
authored andcommitted
cleanup!: Remove legacy unstructured response_format field.
PiperOrigin-RevId: 1013374852
1 parent d97752a commit 90f109f

2 files changed

Lines changed: 46 additions & 9 deletions

File tree

‎google/genai/_gaos/types/interactions/__init__.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@
318318
from .ragstoreconfig import RagStoreConfig, RagStoreConfigParam
319319
from .ranking import Ranking, RankingParam
320320
from .rankservice import RankService, RankServiceParam
321-
from .responseformat import ResponseFormat, ResponseFormatParam
321+
from .responseformat import (
322+
ResponseFormat,
323+
ResponseFormatParam,
324+
UnknownResponseFormat,
325+
)
322326
from .responsemodality import ResponseModality
323327
from .retrieval import Retrieval, RetrievalParam, RetrievalRetrievalType
324328
from .retrievalcallarguments import (
@@ -822,6 +826,7 @@
822826
"UnknownFunctionResultSubcontent",
823827
"UnknownInteractionAgentConfig",
824828
"UnknownInteractionSSEEvent",
829+
"UnknownResponseFormat",
825830
"UnknownStep",
826831
"UnknownStepDeltaData",
827832
"UnknownThoughtSummaryContent",
@@ -1127,6 +1132,7 @@
11271132
"RankServiceParam": ".rankservice",
11281133
"ResponseFormat": ".responseformat",
11291134
"ResponseFormatParam": ".responseformat",
1135+
"UnknownResponseFormat": ".responseformat",
11301136
"ResponseModality": ".responsemodality",
11311137
"Retrieval": ".retrieval",
11321138
"RetrievalParam": ".retrieval",

‎google/genai/_gaos/types/interactions/responseformat.py‎

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
1919

2020
from __future__ import annotations
21+
from .. import BaseModel
22+
from ...utils.unions import parse_open_union
2123
from .audioresponseformat import AudioResponseFormat, AudioResponseFormatParam
2224
from .imageresponseformat import ImageResponseFormat, ImageResponseFormatParam
2325
from .textresponseformat import TextResponseFormat, TextResponseFormatParam
2426
from .videoresponseformat import VideoResponseFormat, VideoResponseFormatParam
25-
from typing import Any, Dict, Union
26-
from typing_extensions import TypeAliasType
27+
from functools import partial
28+
from pydantic import ConfigDict
29+
from pydantic.functional_validators import BeforeValidator
30+
from typing import Any, Literal, Union
31+
from typing_extensions import Annotated, TypeAliasType
2732

2833

2934
ResponseFormatParam = TypeAliasType(
@@ -33,18 +38,44 @@
3338
AudioResponseFormatParam,
3439
ImageResponseFormatParam,
3540
VideoResponseFormatParam,
36-
Dict[str, Any],
3741
],
3842
)
3943

4044

41-
ResponseFormat = TypeAliasType(
42-
"ResponseFormat",
45+
class UnknownResponseFormat(BaseModel):
46+
r"""A ResponseFormat variant the SDK doesn't recognize. Preserves the raw payload."""
47+
48+
type: Literal["UNKNOWN"] = "UNKNOWN"
49+
raw: Any
50+
is_unknown: Literal[True] = True
51+
52+
model_config = ConfigDict(frozen=True)
53+
54+
55+
_RESPONSE_FORMAT_VARIANTS: dict[str, Any] = {
56+
"audio": AudioResponseFormat,
57+
"image": ImageResponseFormat,
58+
"text": TextResponseFormat,
59+
"video": VideoResponseFormat,
60+
}
61+
62+
63+
ResponseFormat = Annotated[
4364
Union[
44-
TextResponseFormat,
4565
AudioResponseFormat,
4666
ImageResponseFormat,
67+
TextResponseFormat,
4768
VideoResponseFormat,
48-
Dict[str, Any],
69+
UnknownResponseFormat,
4970
],
50-
)
71+
BeforeValidator(
72+
partial(
73+
parse_open_union,
74+
disc_key="type",
75+
variants=_RESPONSE_FORMAT_VARIANTS,
76+
unknown_cls=UnknownResponseFormat,
77+
union_name="ResponseFormat",
78+
lenient=True,
79+
)
80+
),
81+
]

0 commit comments

Comments
 (0)