llm-gemini 0.12__py3-none-any.whl → 0.13__py3-none-any.whl
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.
- {llm_gemini-0.12.dist-info → llm_gemini-0.13.dist-info}/METADATA +2 -2
- llm_gemini-0.13.dist-info/RECORD +7 -0
- {llm_gemini-0.12.dist-info → llm_gemini-0.13.dist-info}/WHEEL +1 -1
- llm_gemini.py +35 -3
- llm_gemini-0.12.dist-info/RECORD +0 -7
- {llm_gemini-0.12.dist-info → llm_gemini-0.13.dist-info}/LICENSE +0 -0
- {llm_gemini-0.12.dist-info → llm_gemini-0.13.dist-info}/entry_points.txt +0 -0
- {llm_gemini-0.12.dist-info → llm_gemini-0.13.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.13
|
4
4
|
Summary: LLM plugin to access Google's Gemini family of models
|
5
5
|
Author: Simon Willison
|
6
6
|
License: Apache-2.0
|
@@ -11,7 +11,7 @@ Project-URL: CI, https://github.com/simonw/llm-gemini/actions
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
|
-
Requires-Dist: llm>=0.
|
14
|
+
Requires-Dist: llm>=0.23
|
15
15
|
Requires-Dist: httpx
|
16
16
|
Requires-Dist: ijson
|
17
17
|
Provides-Extra: test
|
@@ -0,0 +1,7 @@
|
|
1
|
+
llm_gemini.py,sha256=lpsKlCAiJtEkwE5Va1zpbX0oSUAWQ0dTfbmH-Xo4hPo,13910
|
2
|
+
llm_gemini-0.13.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
+
llm_gemini-0.13.dist-info/METADATA,sha256=WhmPBMoyvyyH0ErFWaR4_0uDKN9ixogNkdshmED32FQ,7014
|
4
|
+
llm_gemini-0.13.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
5
|
+
llm_gemini-0.13.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
+
llm_gemini-0.13.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
+
llm_gemini-0.13.dist-info/RECORD,,
|
llm_gemini.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import copy
|
1
2
|
import httpx
|
2
3
|
import ijson
|
3
4
|
import llm
|
@@ -64,8 +65,16 @@ def register_models(register):
|
|
64
65
|
]:
|
65
66
|
can_google_search = model_id in GOOGLE_SEARCH_MODELS
|
66
67
|
register(
|
67
|
-
GeminiPro(
|
68
|
-
|
68
|
+
GeminiPro(
|
69
|
+
model_id,
|
70
|
+
can_google_search=can_google_search,
|
71
|
+
can_schema="flash-thinking" not in model_id,
|
72
|
+
),
|
73
|
+
AsyncGeminiPro(
|
74
|
+
model_id,
|
75
|
+
can_google_search=can_google_search,
|
76
|
+
can_schema="flash-thinking" not in model_id,
|
77
|
+
),
|
69
78
|
)
|
70
79
|
|
71
80
|
|
@@ -79,10 +88,26 @@ def resolve_type(attachment):
|
|
79
88
|
return mime_type
|
80
89
|
|
81
90
|
|
91
|
+
def cleanup_schema(schema):
|
92
|
+
"Gemini supports only a subset of JSON schema"
|
93
|
+
keys_to_remove = ("$schema", "additionalProperties")
|
94
|
+
# Recursively remove them
|
95
|
+
if isinstance(schema, dict):
|
96
|
+
for key in keys_to_remove:
|
97
|
+
schema.pop(key, None)
|
98
|
+
for value in schema.values():
|
99
|
+
cleanup_schema(value)
|
100
|
+
elif isinstance(schema, list):
|
101
|
+
for value in schema:
|
102
|
+
cleanup_schema(value)
|
103
|
+
return schema
|
104
|
+
|
105
|
+
|
82
106
|
class _SharedGemini:
|
83
107
|
needs_key = "gemini"
|
84
108
|
key_env_var = "LLM_GEMINI_KEY"
|
85
109
|
can_stream = True
|
110
|
+
supports_schema = True
|
86
111
|
|
87
112
|
attachment_types = (
|
88
113
|
# Text
|
@@ -169,9 +194,10 @@ class _SharedGemini:
|
|
169
194
|
default=None,
|
170
195
|
)
|
171
196
|
|
172
|
-
def __init__(self, model_id, can_google_search=False):
|
197
|
+
def __init__(self, model_id, can_google_search=False, can_schema=False):
|
173
198
|
self.model_id = model_id
|
174
199
|
self.can_google_search = can_google_search
|
200
|
+
self.supports_schema = can_schema
|
175
201
|
if can_google_search:
|
176
202
|
self.Options = self.OptionsWithGoogleSearch
|
177
203
|
|
@@ -226,6 +252,12 @@ class _SharedGemini:
|
|
226
252
|
if prompt.system:
|
227
253
|
body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
|
228
254
|
|
255
|
+
if prompt.schema:
|
256
|
+
body["generationConfig"] = {
|
257
|
+
"response_mime_type": "application/json",
|
258
|
+
"response_schema": cleanup_schema(copy.deepcopy(prompt.schema)),
|
259
|
+
}
|
260
|
+
|
229
261
|
config_map = {
|
230
262
|
"temperature": "temperature",
|
231
263
|
"max_output_tokens": "maxOutputTokens",
|
llm_gemini-0.12.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
llm_gemini.py,sha256=er-6W-CJEOZdC0O6iBYkWsAstlYhtYASkQUXfqhE7Wk,12916
|
2
|
-
llm_gemini-0.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
-
llm_gemini-0.12.dist-info/METADATA,sha256=CKh9OfBqO_Ep7NU2eyGMnkDyuqwnOaBA-geYJpCugac,7014
|
4
|
-
llm_gemini-0.12.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
|
5
|
-
llm_gemini-0.12.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
-
llm_gemini-0.12.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
-
llm_gemini-0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|