google-genai 1.24.0__tar.gz → 1.26.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_genai-1.24.0/google_genai.egg-info → google_genai-1.26.0}/PKG-INFO +70 -12
- {google_genai-1.24.0 → google_genai-1.26.0}/README.md +69 -11
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_api_client.py +11 -1
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_common.py +6 -4
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_extra_utils.py +1 -1
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_live_converters.py +1624 -1922
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_replay_api_client.py +15 -8
- google_genai-1.26.0/google/genai/_tokens_converters.py +817 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_transformers.py +33 -17
- google_genai-1.26.0/google/genai/batches.py +2679 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/caches.py +0 -65
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/errors.py +2 -2
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/files.py +4 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/live.py +22 -15
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/models.py +10 -170
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/operations.py +36 -266
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/tokens.py +8 -4
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/tunings.py +7 -46
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/types.py +126 -46
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/version.py +1 -1
- {google_genai-1.24.0 → google_genai-1.26.0/google_genai.egg-info}/PKG-INFO +70 -12
- {google_genai-1.24.0 → google_genai-1.26.0}/pyproject.toml +1 -1
- google_genai-1.24.0/google/genai/_tokens_converters.py +0 -1680
- google_genai-1.24.0/google/genai/batches.py +0 -5768
- {google_genai-1.24.0 → google_genai-1.26.0}/LICENSE +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/MANIFEST.in +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/__init__.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_adapters.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_api_module.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_automatic_function_calling_util.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_base_url.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_mcp_utils.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/_test_api_client.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/chats.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/client.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/live_music.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/pagers.py +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google/genai/py.typed +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google_genai.egg-info/SOURCES.txt +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google_genai.egg-info/dependency_links.txt +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google_genai.egg-info/requires.txt +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/google_genai.egg-info/top_level.txt +0 -0
- {google_genai-1.24.0 → google_genai-1.26.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: google-genai
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.26.0
|
4
4
|
Summary: GenAI Python SDK
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
6
6
|
License: Apache-2.0
|
@@ -89,10 +89,13 @@ You can create a client by configuring the necessary environment variables.
|
|
89
89
|
Configuration setup instructions depends on whether you're using the Gemini
|
90
90
|
Developer API or the Gemini API in Vertex AI.
|
91
91
|
|
92
|
-
**Gemini Developer API:** Set `
|
92
|
+
**Gemini Developer API:** Set the `GEMINI_API_KEY` or `GOOGLE_API_KEY`.
|
93
|
+
It will automatically be picked up by the client. It's recommended that you
|
94
|
+
set only one of those variables, but if both are set, `GOOGLE_API_KEY` takes
|
95
|
+
precedence.
|
93
96
|
|
94
97
|
```bash
|
95
|
-
export
|
98
|
+
export GEMINI_API_KEY='your-api-key'
|
96
99
|
```
|
97
100
|
|
98
101
|
**Gemini API on Vertex AI:** Set `GOOGLE_GENAI_USE_VERTEXAI`,
|
@@ -606,16 +609,16 @@ from google.genai import types
|
|
606
609
|
function = types.FunctionDeclaration(
|
607
610
|
name='get_current_weather',
|
608
611
|
description='Get the current weather in a given location',
|
609
|
-
|
610
|
-
type
|
611
|
-
properties
|
612
|
-
'location':
|
613
|
-
type
|
614
|
-
description
|
615
|
-
|
612
|
+
parameters_json_schema={
|
613
|
+
'type': 'object',
|
614
|
+
'properties': {
|
615
|
+
'location': {
|
616
|
+
'type': 'string',
|
617
|
+
'description': 'The city and state, e.g. San Francisco, CA',
|
618
|
+
}
|
616
619
|
},
|
617
|
-
required
|
618
|
-
|
620
|
+
'required': ['location'],
|
621
|
+
},
|
619
622
|
)
|
620
623
|
|
621
624
|
tool = types.Tool(function_declarations=[function])
|
@@ -796,6 +799,40 @@ However you define your schema, don't duplicate it in your input prompt,
|
|
796
799
|
including by giving examples of expected JSON output. If you do, the generated
|
797
800
|
output might be lower in quality.
|
798
801
|
|
802
|
+
#### JSON Schema support
|
803
|
+
Schemas can be provided as standard JSON schema.
|
804
|
+
```python
|
805
|
+
user_profile = {
|
806
|
+
'properties': {
|
807
|
+
'age': {
|
808
|
+
'anyOf': [
|
809
|
+
{'maximum': 20, 'minimum': 0, 'type': 'integer'},
|
810
|
+
{'type': 'null'},
|
811
|
+
],
|
812
|
+
'title': 'Age',
|
813
|
+
},
|
814
|
+
'username': {
|
815
|
+
'description': "User's unique name",
|
816
|
+
'title': 'Username',
|
817
|
+
'type': 'string',
|
818
|
+
},
|
819
|
+
},
|
820
|
+
'required': ['username', 'age'],
|
821
|
+
'title': 'User Schema',
|
822
|
+
'type': 'object',
|
823
|
+
}
|
824
|
+
|
825
|
+
response = client.models.generate_content(
|
826
|
+
model='gemini-2.0-flash',
|
827
|
+
contents='Give me information of the United States.',
|
828
|
+
config={
|
829
|
+
'response_mime_type': 'application/json',
|
830
|
+
'response_json_schema': userProfile
|
831
|
+
},
|
832
|
+
)
|
833
|
+
print(response.parsed)
|
834
|
+
```
|
835
|
+
|
799
836
|
#### Pydantic Model Schema support
|
800
837
|
|
801
838
|
Schemas can be provided as Pydantic Models.
|
@@ -1633,3 +1670,24 @@ except errors.APIError as e:
|
|
1633
1670
|
print(e.code) # 404
|
1634
1671
|
print(e.message)
|
1635
1672
|
```
|
1673
|
+
|
1674
|
+
## Extra Request Body
|
1675
|
+
|
1676
|
+
The `extra_body` field in `HttpOptions` accepts a dictionary of additional JSON
|
1677
|
+
properties to include in the request body. This can be used to access new or
|
1678
|
+
experimental backend features that are not yet formally supported in the SDK.
|
1679
|
+
The structure of the dictionary must match the backend API's request structure.
|
1680
|
+
|
1681
|
+
- VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
|
1682
|
+
- GeminiAPI backend API docs: https://ai.google.dev/api/rest
|
1683
|
+
|
1684
|
+
```python
|
1685
|
+
response = client.models.generate_content(
|
1686
|
+
model="gemini-2.5-pro",
|
1687
|
+
contents="What is the weather in Boston? and how about Sunnyvale?",
|
1688
|
+
config=types.GenerateContentConfig(
|
1689
|
+
tools=[get_current_weather],
|
1690
|
+
http_options=types.HttpOptions(extra_body={'tool_config': {'function_calling_config': {'mode': 'COMPOSITIONAL'}}}),
|
1691
|
+
),
|
1692
|
+
)
|
1693
|
+
```
|
@@ -55,10 +55,13 @@ You can create a client by configuring the necessary environment variables.
|
|
55
55
|
Configuration setup instructions depends on whether you're using the Gemini
|
56
56
|
Developer API or the Gemini API in Vertex AI.
|
57
57
|
|
58
|
-
**Gemini Developer API:** Set `
|
58
|
+
**Gemini Developer API:** Set the `GEMINI_API_KEY` or `GOOGLE_API_KEY`.
|
59
|
+
It will automatically be picked up by the client. It's recommended that you
|
60
|
+
set only one of those variables, but if both are set, `GOOGLE_API_KEY` takes
|
61
|
+
precedence.
|
59
62
|
|
60
63
|
```bash
|
61
|
-
export
|
64
|
+
export GEMINI_API_KEY='your-api-key'
|
62
65
|
```
|
63
66
|
|
64
67
|
**Gemini API on Vertex AI:** Set `GOOGLE_GENAI_USE_VERTEXAI`,
|
@@ -572,16 +575,16 @@ from google.genai import types
|
|
572
575
|
function = types.FunctionDeclaration(
|
573
576
|
name='get_current_weather',
|
574
577
|
description='Get the current weather in a given location',
|
575
|
-
|
576
|
-
type
|
577
|
-
properties
|
578
|
-
'location':
|
579
|
-
type
|
580
|
-
description
|
581
|
-
|
578
|
+
parameters_json_schema={
|
579
|
+
'type': 'object',
|
580
|
+
'properties': {
|
581
|
+
'location': {
|
582
|
+
'type': 'string',
|
583
|
+
'description': 'The city and state, e.g. San Francisco, CA',
|
584
|
+
}
|
582
585
|
},
|
583
|
-
required
|
584
|
-
|
586
|
+
'required': ['location'],
|
587
|
+
},
|
585
588
|
)
|
586
589
|
|
587
590
|
tool = types.Tool(function_declarations=[function])
|
@@ -762,6 +765,40 @@ However you define your schema, don't duplicate it in your input prompt,
|
|
762
765
|
including by giving examples of expected JSON output. If you do, the generated
|
763
766
|
output might be lower in quality.
|
764
767
|
|
768
|
+
#### JSON Schema support
|
769
|
+
Schemas can be provided as standard JSON schema.
|
770
|
+
```python
|
771
|
+
user_profile = {
|
772
|
+
'properties': {
|
773
|
+
'age': {
|
774
|
+
'anyOf': [
|
775
|
+
{'maximum': 20, 'minimum': 0, 'type': 'integer'},
|
776
|
+
{'type': 'null'},
|
777
|
+
],
|
778
|
+
'title': 'Age',
|
779
|
+
},
|
780
|
+
'username': {
|
781
|
+
'description': "User's unique name",
|
782
|
+
'title': 'Username',
|
783
|
+
'type': 'string',
|
784
|
+
},
|
785
|
+
},
|
786
|
+
'required': ['username', 'age'],
|
787
|
+
'title': 'User Schema',
|
788
|
+
'type': 'object',
|
789
|
+
}
|
790
|
+
|
791
|
+
response = client.models.generate_content(
|
792
|
+
model='gemini-2.0-flash',
|
793
|
+
contents='Give me information of the United States.',
|
794
|
+
config={
|
795
|
+
'response_mime_type': 'application/json',
|
796
|
+
'response_json_schema': userProfile
|
797
|
+
},
|
798
|
+
)
|
799
|
+
print(response.parsed)
|
800
|
+
```
|
801
|
+
|
765
802
|
#### Pydantic Model Schema support
|
766
803
|
|
767
804
|
Schemas can be provided as Pydantic Models.
|
@@ -1599,3 +1636,24 @@ except errors.APIError as e:
|
|
1599
1636
|
print(e.code) # 404
|
1600
1637
|
print(e.message)
|
1601
1638
|
```
|
1639
|
+
|
1640
|
+
## Extra Request Body
|
1641
|
+
|
1642
|
+
The `extra_body` field in `HttpOptions` accepts a dictionary of additional JSON
|
1643
|
+
properties to include in the request body. This can be used to access new or
|
1644
|
+
experimental backend features that are not yet formally supported in the SDK.
|
1645
|
+
The structure of the dictionary must match the backend API's request structure.
|
1646
|
+
|
1647
|
+
- VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
|
1648
|
+
- GeminiAPI backend API docs: https://ai.google.dev/api/rest
|
1649
|
+
|
1650
|
+
```python
|
1651
|
+
response = client.models.generate_content(
|
1652
|
+
model="gemini-2.5-pro",
|
1653
|
+
contents="What is the weather in Boston? and how about Sunnyvale?",
|
1654
|
+
config=types.GenerateContentConfig(
|
1655
|
+
tools=[get_current_weather],
|
1656
|
+
http_options=types.HttpOptions(extra_body={'tool_config': {'function_calling_config': {'mode': 'COMPOSITIONAL'}}}),
|
1657
|
+
),
|
1658
|
+
)
|
1659
|
+
```
|
@@ -232,8 +232,18 @@ class HttpResponse:
|
|
232
232
|
byte_stream: Union[Any, bytes] = None,
|
233
233
|
session: Optional['aiohttp.ClientSession'] = None,
|
234
234
|
):
|
235
|
+
if isinstance(headers, dict):
|
236
|
+
self.headers = headers
|
237
|
+
elif isinstance(headers, httpx.Headers):
|
238
|
+
self.headers = {
|
239
|
+
key: ', '.join(headers.get_list(key))
|
240
|
+
for key in headers.keys()}
|
241
|
+
elif type(headers).__name__ == 'CIMultiDictProxy':
|
242
|
+
self.headers = {
|
243
|
+
key: ', '.join(headers.getall(key))
|
244
|
+
for key in headers.keys()}
|
245
|
+
|
235
246
|
self.status_code: int = 200
|
236
|
-
self.headers = headers
|
237
247
|
self.response_stream = response_stream
|
238
248
|
self.byte_stream = byte_stream
|
239
249
|
self._session = session
|
@@ -29,11 +29,13 @@ import warnings
|
|
29
29
|
import pydantic
|
30
30
|
from pydantic import alias_generators
|
31
31
|
|
32
|
-
from . import _api_client
|
33
|
-
from . import errors
|
34
|
-
|
35
32
|
logger = logging.getLogger('google_genai._common')
|
36
33
|
|
34
|
+
|
35
|
+
class ExperimentalWarning(Warning):
|
36
|
+
"""Warning for experimental features."""
|
37
|
+
|
38
|
+
|
37
39
|
def set_value_by_path(data: Optional[dict[Any, Any]], keys: list[str], value: Any) -> None:
|
38
40
|
"""Examples:
|
39
41
|
|
@@ -540,7 +542,7 @@ def experimental_warning(message: str) -> Callable[[Callable[..., Any]], Callabl
|
|
540
542
|
warning_done = True
|
541
543
|
warnings.warn(
|
542
544
|
message=message,
|
543
|
-
category=
|
545
|
+
category=ExperimentalWarning,
|
544
546
|
stacklevel=2,
|
545
547
|
)
|
546
548
|
return func(*args, **kwargs)
|
@@ -114,7 +114,7 @@ def format_destination(
|
|
114
114
|
unique_name = unique_name or _common.timestamped_unique_name()
|
115
115
|
config.dest = f'{bigquery_source_uri}_dest_{unique_name}'
|
116
116
|
else:
|
117
|
-
raise ValueError(f'
|
117
|
+
raise ValueError(f'The source {src} is not supported.')
|
118
118
|
return config
|
119
119
|
|
120
120
|
|