llm-gemini 0.4.2__py3-none-any.whl → 0.5__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.2.dist-info → llm_gemini-0.5.dist-info}/METADATA +2 -2
- llm_gemini-0.5.dist-info/RECORD +7 -0
- llm_gemini.py +15 -0
- llm_gemini-0.4.2.dist-info/RECORD +0 -7
- {llm_gemini-0.4.2.dist-info → llm_gemini-0.5.dist-info}/LICENSE +0 -0
- {llm_gemini-0.4.2.dist-info → llm_gemini-0.5.dist-info}/WHEEL +0 -0
- {llm_gemini-0.4.2.dist-info → llm_gemini-0.5.dist-info}/entry_points.txt +0 -0
- {llm_gemini-0.4.2.dist-info → llm_gemini-0.5.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.5
|
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.19
|
15
15
|
Requires-Dist: httpx
|
16
16
|
Requires-Dist: ijson
|
17
17
|
Provides-Extra: test
|
@@ -0,0 +1,7 @@
|
|
1
|
+
llm_gemini.py,sha256=GFAYIFWCRyM1FhMbvZhm9DvRPmW-GUNlzgkBY-Gcq7g,11295
|
2
|
+
llm_gemini-0.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
+
llm_gemini-0.5.dist-info/METADATA,sha256=Ipci7xoIduAqjP-73H2jstoqj5Qp0KmnMUNifHp8JXg,5335
|
4
|
+
llm_gemini-0.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
5
|
+
llm_gemini-0.5.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
+
llm_gemini-0.5.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
+
llm_gemini-0.5.dist-info/RECORD,,
|
llm_gemini.py
CHANGED
@@ -211,6 +211,19 @@ class _SharedGemini:
|
|
211
211
|
return f'```\n{part["codeExecutionResult"]["output"].strip()}\n```\n'
|
212
212
|
return ""
|
213
213
|
|
214
|
+
def set_usage(self, response):
|
215
|
+
try:
|
216
|
+
usage = response.response_json[-1].pop("usageMetadata")
|
217
|
+
input_tokens = usage.pop("promptTokenCount", None)
|
218
|
+
output_tokens = usage.pop("candidatesTokenCount", None)
|
219
|
+
usage.pop("totalTokenCount", None)
|
220
|
+
if input_tokens is not None:
|
221
|
+
response.set_usage(
|
222
|
+
input=input_tokens, output=output_tokens, details=usage or None
|
223
|
+
)
|
224
|
+
except (IndexError, KeyError):
|
225
|
+
pass
|
226
|
+
|
214
227
|
|
215
228
|
class GeminiPro(_SharedGemini, llm.Model):
|
216
229
|
def execute(self, prompt, stream, response, conversation):
|
@@ -242,6 +255,7 @@ class GeminiPro(_SharedGemini, llm.Model):
|
|
242
255
|
gathered.append(event)
|
243
256
|
events.clear()
|
244
257
|
response.response_json = gathered
|
258
|
+
self.set_usage(response)
|
245
259
|
|
246
260
|
|
247
261
|
class AsyncGeminiPro(_SharedGemini, llm.AsyncModel):
|
@@ -275,6 +289,7 @@ class AsyncGeminiPro(_SharedGemini, llm.AsyncModel):
|
|
275
289
|
gathered.append(event)
|
276
290
|
events.clear()
|
277
291
|
response.response_json = gathered
|
292
|
+
self.set_usage(response)
|
278
293
|
|
279
294
|
|
280
295
|
@llm.hookimpl
|
@@ -1,7 +0,0 @@
|
|
1
|
-
llm_gemini.py,sha256=1lyC3SDLVTgRxsxC6T_l0P3xchq2NjqpFslgjPl83Bg,10699
|
2
|
-
llm_gemini-0.4.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
-
llm_gemini-0.4.2.dist-info/METADATA,sha256=oNq8S0QhfgEDc2st90DplNFDbNy7-5NyxLSGq7e0P_w,5337
|
4
|
-
llm_gemini-0.4.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
5
|
-
llm_gemini-0.4.2.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
|
6
|
-
llm_gemini-0.4.2.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
|
7
|
-
llm_gemini-0.4.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|