Skip to content

Commit 6c3379f

Browse files
Annhiluccopybara-github
authored andcommitted
feat: Breaking change to Interactions API to refactor TextContent annotations to use specific citation types
PiperOrigin-RevId: 884559523
1 parent d896373 commit 6c3379f

14 files changed

Lines changed: 325 additions & 98 deletions

google/genai/_interactions/types/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@
3333
from .content_stop import ContentStop as ContentStop
3434
from .image_config import ImageConfig as ImageConfig
3535
from .text_content import TextContent as TextContent
36+
from .url_citation import URLCitation as URLCitation
3637
from .allowed_tools import AllowedTools as AllowedTools
3738
from .audio_content import AudioContent as AudioContent
3839
from .content_delta import ContentDelta as ContentDelta
3940
from .content_param import ContentParam as ContentParam
4041
from .content_start import ContentStart as ContentStart
42+
from .file_citation import FileCitation as FileCitation
4143
from .image_content import ImageContent as ImageContent
4244
from .speech_config import SpeechConfig as SpeechConfig
4345
from .video_content import VideoContent as VideoContent
4446
from .function_param import FunctionParam as FunctionParam
47+
from .place_citation import PlaceCitation as PlaceCitation
4548
from .thinking_level import ThinkingLevel as ThinkingLevel
4649
from .thought_content import ThoughtContent as ThoughtContent
4750
from .annotation_param import AnnotationParam as AnnotationParam
@@ -52,14 +55,17 @@
5255
from .image_config_param import ImageConfigParam as ImageConfigParam
5356
from .text_content_param import TextContentParam as TextContentParam
5457
from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig
58+
from .url_citation_param import URLCitationParam as URLCitationParam
5559
from .url_context_result import URLContextResult as URLContextResult
5660
from .allowed_tools_param import AllowedToolsParam as AllowedToolsParam
5761
from .audio_content_param import AudioContentParam as AudioContentParam
62+
from .file_citation_param import FileCitationParam as FileCitationParam
5863
from .image_content_param import ImageContentParam as ImageContentParam
5964
from .speech_config_param import SpeechConfigParam as SpeechConfigParam
6065
from .video_content_param import VideoContentParam as VideoContentParam
6166
from .dynamic_agent_config import DynamicAgentConfig as DynamicAgentConfig
6267
from .google_search_result import GoogleSearchResult as GoogleSearchResult
68+
from .place_citation_param import PlaceCitationParam as PlaceCitationParam
6369
from .function_call_content import FunctionCallContent as FunctionCallContent
6470
from .interaction_sse_event import InteractionSSEEvent as InteractionSSEEvent
6571
from .thought_content_param import ThoughtContentParam as ThoughtContentParam

google/genai/_interactions/types/annotation.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,14 @@
1515

1616
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1717

18-
from typing import Optional
18+
from typing import Union
19+
from typing_extensions import Annotated, TypeAlias
1920

20-
from .._models import BaseModel
21+
from .._utils import PropertyInfo
22+
from .url_citation import URLCitation
23+
from .file_citation import FileCitation
24+
from .place_citation import PlaceCitation
2125

2226
__all__ = ["Annotation"]
2327

24-
25-
class Annotation(BaseModel):
26-
"""Citation information for model-generated content."""
27-
28-
end_index: Optional[int] = None
29-
"""End of the attributed segment, exclusive."""
30-
31-
source: Optional[str] = None
32-
"""Source attributed for a portion of the text.
33-
34-
Could be a URL, title, or
35-
other identifier.
36-
"""
37-
38-
start_index: Optional[int] = None
39-
"""Start of segment of the response that is attributed to this source.
40-
41-
Index indicates the start of the segment, measured in bytes.
42-
"""
28+
Annotation: TypeAlias = Annotated[Union[URLCitation, FileCitation, PlaceCitation], PropertyInfo(discriminator="type")]

google/genai/_interactions/types/annotation_param.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,13 @@
1717

1818
from __future__ import annotations
1919

20-
from typing_extensions import TypedDict
20+
from typing import Union
21+
from typing_extensions import TypeAlias
2122

22-
__all__ = ["AnnotationParam"]
23-
24-
25-
class AnnotationParam(TypedDict, total=False):
26-
"""Citation information for model-generated content."""
27-
28-
end_index: int
29-
"""End of the attributed segment, exclusive."""
23+
from .url_citation_param import URLCitationParam
24+
from .file_citation_param import FileCitationParam
25+
from .place_citation_param import PlaceCitationParam
3026

31-
source: str
32-
"""Source attributed for a portion of the text.
33-
34-
Could be a URL, title, or
35-
other identifier.
36-
"""
37-
38-
start_index: int
39-
"""Start of segment of the response that is attributed to this source.
27+
__all__ = ["AnnotationParam"]
4028

41-
Index indicates the start of the segment, measured in bytes.
42-
"""
29+
AnnotationParam: TypeAlias = Union[URLCitationParam, FileCitationParam, PlaceCitationParam]

google/genai/_interactions/types/content_delta.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"DeltaMCPServerToolResultResultItemsItem",
6161
"DeltaFileSearchCall",
6262
"DeltaFileSearchResult",
63-
"DeltaFileSearchResultResult",
6463
"DeltaGoogleMapsCall",
6564
"DeltaGoogleMapsResult",
6665
]
@@ -325,26 +324,13 @@ class DeltaFileSearchCall(BaseModel):
325324
"""A signature hash for backend validation."""
326325

327326

328-
class DeltaFileSearchResultResult(BaseModel):
329-
"""The result of the File Search."""
330-
331-
file_search_store: Optional[str] = None
332-
"""The name of the file search store."""
333-
334-
text: Optional[str] = None
335-
"""The text of the search result."""
336-
337-
title: Optional[str] = None
338-
"""The title of the search result."""
339-
340-
341327
class DeltaFileSearchResult(BaseModel):
342328
call_id: str
343329
"""ID to match the ID from the function call block."""
344330

345331
type: Literal["file_search_result"]
346332

347-
result: Optional[List[DeltaFileSearchResultResult]] = None
333+
result: Optional[List[object]] = None
348334

349335
signature: Optional[str] = None
350336
"""A signature hash for backend validation."""
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17+
18+
from typing import Optional
19+
from typing_extensions import Literal
20+
21+
from .._models import BaseModel
22+
23+
__all__ = ["FileCitation"]
24+
25+
26+
class FileCitation(BaseModel):
27+
"""A file citation annotation."""
28+
29+
type: Literal["file_citation"]
30+
31+
document_uri: Optional[str] = None
32+
"""The URI of the file."""
33+
34+
end_index: Optional[int] = None
35+
"""End of the attributed segment, exclusive."""
36+
37+
file_name: Optional[str] = None
38+
"""The name of the file."""
39+
40+
source: Optional[str] = None
41+
"""Source attributed for a portion of the text."""
42+
43+
start_index: Optional[int] = None
44+
"""Start of segment of the response that is attributed to this source."""
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17+
18+
from __future__ import annotations
19+
20+
from typing_extensions import Literal, Required, TypedDict
21+
22+
__all__ = ["FileCitationParam"]
23+
24+
25+
class FileCitationParam(TypedDict, total=False):
26+
"""A file citation annotation."""
27+
28+
type: Required[Literal["file_citation"]]
29+
30+
document_uri: str
31+
"""The URI of the file."""
32+
33+
end_index: int
34+
"""End of the attributed segment, exclusive."""
35+
36+
file_name: str
37+
"""The name of the file."""
38+
39+
source: str
40+
"""Source attributed for a portion of the text."""
41+
42+
start_index: int
43+
"""Start of segment of the response that is attributed to this source."""

google/genai/_interactions/types/file_search_result_content.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,7 @@
2020

2121
from .._models import BaseModel
2222

23-
__all__ = ["FileSearchResultContent", "Result"]
24-
25-
26-
class Result(BaseModel):
27-
"""The result of the File Search."""
28-
29-
file_search_store: Optional[str] = None
30-
"""The name of the file search store."""
31-
32-
text: Optional[str] = None
33-
"""The text of the search result."""
34-
35-
title: Optional[str] = None
36-
"""The title of the search result."""
23+
__all__ = ["FileSearchResultContent"]
3724

3825

3926
class FileSearchResultContent(BaseModel):
@@ -44,7 +31,7 @@ class FileSearchResultContent(BaseModel):
4431

4532
type: Literal["file_search_result"]
4633

47-
result: Optional[List[Result]] = None
34+
result: Optional[List[object]] = None
4835
"""The results of the File Search."""
4936

5037
signature: Optional[str] = None

google/genai/_interactions/types/file_search_result_content_param.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,7 @@
2424
from .._utils import PropertyInfo
2525
from .._models import set_pydantic_config
2626

27-
__all__ = ["FileSearchResultContentParam", "Result"]
28-
29-
30-
class Result(TypedDict, total=False):
31-
"""The result of the File Search."""
32-
33-
file_search_store: str
34-
"""The name of the file search store."""
35-
36-
text: str
37-
"""The text of the search result."""
38-
39-
title: str
40-
"""The title of the search result."""
27+
__all__ = ["FileSearchResultContentParam"]
4128

4229

4330
class FileSearchResultContentParam(TypedDict, total=False):
@@ -48,7 +35,7 @@ class FileSearchResultContentParam(TypedDict, total=False):
4835

4936
type: Required[Literal["file_search_result"]]
5037

51-
result: Iterable[Result]
38+
result: Iterable[object]
5239
"""The results of the File Search."""
5340

5441
signature: Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]

google/genai/_interactions/types/google_search_result.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ class GoogleSearchResult(BaseModel):
2727

2828
search_suggestions: Optional[str] = None
2929
"""Web content snippet that can be embedded in a web page or an app webview."""
30-
31-
title: Optional[str] = None
32-
"""Title of the search result."""
33-
34-
url: Optional[str] = None
35-
"""URI reference of the search result."""

google/genai/_interactions/types/google_search_result_param.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ class GoogleSearchResultParam(TypedDict, total=False):
2727

2828
search_suggestions: str
2929
"""Web content snippet that can be embedded in a web page or an app webview."""
30-
31-
title: str
32-
"""Title of the search result."""
33-
34-
url: str
35-
"""URI reference of the search result."""

0 commit comments

Comments
 (0)