llm-gemini 0.12__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.
- {llm_gemini-0.12 → llm_gemini-0.13a0}/PKG-INFO +2 -2
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/PKG-INFO +2 -2
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/requires.txt +1 -1
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.py +23 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/pyproject.toml +2 -2
- {llm_gemini-0.12 → llm_gemini-0.13a0}/LICENSE +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/README.md +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/SOURCES.txt +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/dependency_links.txt +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/entry_points.txt +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/llm_gemini.egg-info/top_level.txt +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/setup.cfg +0 -0
- {llm_gemini-0.12 → llm_gemini-0.13a0}/tests/test_gemini.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
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.
|
14
|
+
Requires-Dist: llm>=0.23a0
|
15
15
|
Requires-Dist: httpx
|
16
16
|
Requires-Dist: ijson
|
17
17
|
Provides-Extra: test
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
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.
|
14
|
+
Requires-Dist: llm>=0.23a0
|
15
15
|
Requires-Dist: httpx
|
16
16
|
Requires-Dist: ijson
|
17
17
|
Provides-Extra: test
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import copy
|
1
2
|
import httpx
|
2
3
|
import ijson
|
3
4
|
import llm
|
@@ -79,10 +80,26 @@ def resolve_type(attachment):
|
|
79
80
|
return mime_type
|
80
81
|
|
81
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
|
+
|
82
98
|
class _SharedGemini:
|
83
99
|
needs_key = "gemini"
|
84
100
|
key_env_var = "LLM_GEMINI_KEY"
|
85
101
|
can_stream = True
|
102
|
+
supports_schema = True
|
86
103
|
|
87
104
|
attachment_types = (
|
88
105
|
# Text
|
@@ -226,6 +243,12 @@ class _SharedGemini:
|
|
226
243
|
if prompt.system:
|
227
244
|
body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
|
228
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
|
+
|
229
252
|
config_map = {
|
230
253
|
"temperature": "temperature",
|
231
254
|
"max_output_tokens": "maxOutputTokens",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "llm-gemini"
|
3
|
-
version = "0.
|
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.
|
12
|
+
"llm>=0.23a0",
|
13
13
|
"httpx",
|
14
14
|
"ijson"
|
15
15
|
]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|