llm-gemini 0.11__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.11.dist-info → llm_gemini-0.13.dist-info}/METADATA +3 -3
- llm_gemini-0.13.dist-info/RECORD +7 -0
- {llm_gemini-0.11.dist-info → llm_gemini-0.13.dist-info}/WHEEL +1 -1
- llm_gemini.py +37 -4
- llm_gemini-0.11.dist-info/RECORD +0 -7
- {llm_gemini-0.11.dist-info → llm_gemini-0.13.dist-info}/LICENSE +0 -0
- {llm_gemini-0.11.dist-info → llm_gemini-0.13.dist-info}/entry_points.txt +0 -0
- {llm_gemini-0.11.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
|
@@ -69,7 +69,7 @@ Other models are:
|
|
69
69
|
- `gemini-2.0-flash-thinking-exp-1219` - experimental "thinking" model from December 2024
|
70
70
|
- `gemini-2.0-flash-thinking-exp-01-21` - experimental "thinking" model from January 2025
|
71
71
|
- `gemini-2.0-flash` - Gemini 2.0 Flash
|
72
|
-
- `gemini-2.0-flash-lite
|
72
|
+
- `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
|
73
73
|
- `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
|
74
74
|
|
75
75
|
### Images, audio and video
|
@@ -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
|
@@ -58,13 +59,22 @@ def register_models(register):
|
|
58
59
|
"gemini-2.0-flash-thinking-exp-01-21",
|
59
60
|
# Released 5th Feb 2025:
|
60
61
|
"gemini-2.0-flash",
|
61
|
-
"gemini-2.0-flash-lite-preview-02-05",
|
62
62
|
"gemini-2.0-pro-exp-02-05",
|
63
|
+
# Released 25th Feb 2025:
|
64
|
+
"gemini-2.0-flash-lite",
|
63
65
|
]:
|
64
66
|
can_google_search = model_id in GOOGLE_SEARCH_MODELS
|
65
67
|
register(
|
66
|
-
GeminiPro(
|
67
|
-
|
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
|
+
),
|
68
78
|
)
|
69
79
|
|
70
80
|
|
@@ -78,10 +88,26 @@ def resolve_type(attachment):
|
|
78
88
|
return mime_type
|
79
89
|
|
80
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
|
+
|
81
106
|
class _SharedGemini:
|
82
107
|
needs_key = "gemini"
|
83
108
|
key_env_var = "LLM_GEMINI_KEY"
|
84
109
|
can_stream = True
|
110
|
+
supports_schema = True
|
85
111
|
|
86
112
|
attachment_types = (
|
87
113
|
# Text
|
@@ -168,9 +194,10 @@ class _SharedGemini:
|
|
168
194
|
default=None,
|
169
195
|
)
|
170
196
|
|
171
|
-
def __init__(self, model_id, can_google_search=False):
|
197
|
+
def __init__(self, model_id, can_google_search=False, can_schema=False):
|
172
198
|
self.model_id = model_id
|
173
199
|
self.can_google_search = can_google_search
|
200
|
+
self.supports_schema = can_schema
|
174
201
|
if can_google_search:
|
175
202
|
self.Options = self.OptionsWithGoogleSearch
|
176
203
|
|
@@ -225,6 +252,12 @@ class _SharedGemini:
|
|
225
252
|
if prompt.system:
|
226
253
|
body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
|
227
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
|
+
|
228
261
|
config_map = {
|
229
262
|
"temperature": "temperature",
|
230
263
|
"max_output_tokens": "maxOutputTokens",
|
llm_gemini-0.11.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
llm_gemini.py,sha256=tILVMtCj52Tt8VHK1YsTD0n55CpzzW3nMceavTdC9P8,12896
|
2
|
-
llm_gemini-0.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
-
llm_gemini-0.11.dist-info/METADATA,sha256=L_7OzL0ToVpD-pCTCFIOwZuCNU60CdWbx_9psWgTdlM,7028
|
4
|
-
llm_gemini-0.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
5
|
-
llm_gemini-0.11.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
-
llm_gemini-0.11.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
-
llm_gemini-0.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|