llm-gemini 0.11__tar.gz → 0.13a0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: llm-gemini
3
- Version: 0.11
3
+ Version: 0.13a0
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.22
14
+ Requires-Dist: llm>=0.23a0
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-preview-02-05` - 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
@@ -48,7 +48,7 @@ Other models are:
48
48
  - `gemini-2.0-flash-thinking-exp-1219` - experimental "thinking" model from December 2024
49
49
  - `gemini-2.0-flash-thinking-exp-01-21` - experimental "thinking" model from January 2025
50
50
  - `gemini-2.0-flash` - Gemini 2.0 Flash
51
- - `gemini-2.0-flash-lite-preview-02-05` - Gemini 2.0 Flash-Lite
51
+ - `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
52
52
  - `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
53
53
 
54
54
  ### Images, audio and video
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: llm-gemini
3
- Version: 0.11
3
+ Version: 0.13a0
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.22
14
+ Requires-Dist: llm>=0.23a0
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-preview-02-05` - 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
@@ -1,4 +1,4 @@
1
- llm>=0.22
1
+ llm>=0.23a0
2
2
  httpx
3
3
  ijson
4
4
 
@@ -1,3 +1,4 @@
1
+ import copy
1
2
  import httpx
2
3
  import ijson
3
4
  import llm
@@ -58,8 +59,9 @@ 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(
@@ -78,10 +80,26 @@ def resolve_type(attachment):
78
80
  return mime_type
79
81
 
80
82
 
83
+ def cleanup_schema(schema):
84
+ "Gemini supports only a subset of JSON schema"
85
+ keys_to_remove = ("$schema", "additionalProperties")
86
+ # Recursively remove them
87
+ if isinstance(schema, dict):
88
+ for key in keys_to_remove:
89
+ schema.pop(key, None)
90
+ for value in schema.values():
91
+ cleanup_schema(value)
92
+ elif isinstance(schema, list):
93
+ for value in schema:
94
+ cleanup_schema(value)
95
+ return schema
96
+
97
+
81
98
  class _SharedGemini:
82
99
  needs_key = "gemini"
83
100
  key_env_var = "LLM_GEMINI_KEY"
84
101
  can_stream = True
102
+ supports_schema = True
85
103
 
86
104
  attachment_types = (
87
105
  # Text
@@ -225,6 +243,12 @@ class _SharedGemini:
225
243
  if prompt.system:
226
244
  body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
227
245
 
246
+ if prompt.schema:
247
+ body["generationConfig"] = {
248
+ "response_mime_type": "application/json",
249
+ "response_schema": cleanup_schema(copy.deepcopy(prompt.schema)),
250
+ }
251
+
228
252
  config_map = {
229
253
  "temperature": "temperature",
230
254
  "max_output_tokens": "maxOutputTokens",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llm-gemini"
3
- version = "0.11"
3
+ version = "0.13a0"
4
4
  description = "LLM plugin to access Google's Gemini family of models"
5
5
  readme = "README.md"
6
6
  authors = [{name = "Simon Willison"}]
@@ -9,7 +9,7 @@ classifiers = [
9
9
  "License :: OSI Approved :: Apache Software License"
10
10
  ]
11
11
  dependencies = [
12
- "llm>=0.22",
12
+ "llm>=0.23a0",
13
13
  "httpx",
14
14
  "ijson"
15
15
  ]
File without changes
File without changes