llm-gemini 0.4.1__py3-none-any.whl → 0.5a0__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.4.1.dist-info → llm_gemini-0.5a0.dist-info}/METADATA +15 -2
- llm_gemini-0.5a0.dist-info/RECORD +7 -0
- llm_gemini.py +15 -0
- llm_gemini-0.4.1.dist-info/RECORD +0 -7
- {llm_gemini-0.4.1.dist-info → llm_gemini-0.5a0.dist-info}/LICENSE +0 -0
- {llm_gemini-0.4.1.dist-info → llm_gemini-0.5a0.dist-info}/WHEEL +0 -0
- {llm_gemini-0.4.1.dist-info → llm_gemini-0.5a0.dist-info}/entry_points.txt +0 -0
- {llm_gemini-0.4.1.dist-info → llm_gemini-0.5a0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5a0
|
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.19a0
|
15
15
|
Requires-Dist: httpx
|
16
16
|
Requires-Dist: ijson
|
17
17
|
Provides-Extra: test
|
@@ -157,3 +157,16 @@ To run the tests:
|
|
157
157
|
```bash
|
158
158
|
pytest
|
159
159
|
```
|
160
|
+
|
161
|
+
This project uses [pytest-recording](https://github.com/kiwicom/pytest-recording) to record Gemini API responses for the tests.
|
162
|
+
|
163
|
+
If you add a new test that calls the API you can capture the API response like this:
|
164
|
+
```bash
|
165
|
+
PYTEST_GEMINI_API_KEY="$(llm keys get gemini)" pytest --record-mode once
|
166
|
+
```
|
167
|
+
You will need to have stored a valid Gemini API key using this command first:
|
168
|
+
```bash
|
169
|
+
llm keys set gemini
|
170
|
+
# Paste key here
|
171
|
+
```
|
172
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
llm_gemini.py,sha256=bALsCHsTTFaj2mdfZe2hOIc7aAxDFwNMYb7keyy4-20,11268
|
2
|
+
llm_gemini-0.5a0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
+
llm_gemini-0.5a0.dist-info/METADATA,sha256=ON3jk8T7hK9Zp8IF9Z4TxCL-CvN94Eko8Xnb0X-7HhA,5294
|
4
|
+
llm_gemini-0.5a0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
5
|
+
llm_gemini-0.5a0.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
+
llm_gemini-0.5a0.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
+
llm_gemini-0.5a0.dist-info/RECORD,,
|
llm_gemini.py
CHANGED
@@ -210,6 +210,19 @@ class _SharedGemini:
|
|
210
210
|
return f'```\n{part["codeExecutionResult"]["output"].strip()}\n```\n'
|
211
211
|
return ""
|
212
212
|
|
213
|
+
def set_usage(self, response):
|
214
|
+
try:
|
215
|
+
usage = response.response_json[-1].pop("usageMetadata")
|
216
|
+
input_tokens = usage.pop("promptTokenCount", None)
|
217
|
+
output_tokens = usage.pop("candidatesTokenCount", None)
|
218
|
+
usage.pop("totalTokenCount", None)
|
219
|
+
if input_tokens is not None:
|
220
|
+
response.set_usage(
|
221
|
+
input=input_tokens, output=output_tokens, details=usage or None
|
222
|
+
)
|
223
|
+
except (IndexError, KeyError):
|
224
|
+
pass
|
225
|
+
|
213
226
|
|
214
227
|
class GeminiPro(_SharedGemini, llm.Model):
|
215
228
|
def execute(self, prompt, stream, response, conversation):
|
@@ -241,6 +254,7 @@ class GeminiPro(_SharedGemini, llm.Model):
|
|
241
254
|
gathered.append(event)
|
242
255
|
events.clear()
|
243
256
|
response.response_json = gathered
|
257
|
+
self.set_usage(response)
|
244
258
|
|
245
259
|
|
246
260
|
class AsyncGeminiPro(_SharedGemini, llm.AsyncModel):
|
@@ -274,6 +288,7 @@ class AsyncGeminiPro(_SharedGemini, llm.AsyncModel):
|
|
274
288
|
gathered.append(event)
|
275
289
|
events.clear()
|
276
290
|
response.response_json = gathered
|
291
|
+
self.set_usage(response)
|
277
292
|
|
278
293
|
|
279
294
|
@llm.hookimpl
|
@@ -1,7 +0,0 @@
|
|
1
|
-
llm_gemini.py,sha256=_7yQ14ffRpyK3ChAOc6M2ufylg2kUKTQK4C3VKOiUgM,10672
|
2
|
-
llm_gemini-0.4.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
-
llm_gemini-0.4.1.dist-info/METADATA,sha256=OhySg0uA_de-JRZrYIJFZu_uSYVKXEGs4W_x3LkQUvE,4864
|
4
|
-
llm_gemini-0.4.1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
5
|
-
llm_gemini-0.4.1.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
-
llm_gemini-0.4.1.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
-
llm_gemini-0.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|