llm-gemini 0.17__py3-none-any.whl → 0.18__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llm-gemini
3
- Version: 0.17
3
+ Version: 0.18
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License: Apache-2.0
@@ -66,6 +66,7 @@ llm "A joke about a pelican and a walrus"
66
66
 
67
67
  Other models are:
68
68
 
69
+ - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
69
70
  - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
70
71
  - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
71
72
  - `gemma-3-27b-it` - [Gemma 3](https://blog.google/technology/developers/gemma-3/) 27B
@@ -0,0 +1,7 @@
1
+ llm_gemini.py,sha256=eoMPxKnWgEN3Li1HDsKIgKnXT5AL4stDhWc1MU6uIRE,17558
2
+ llm_gemini-0.18.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
+ llm_gemini-0.18.dist-info/METADATA,sha256=X3NSwwbxo8TIAgyf3PA13WUzSWKTxXc38EhpD2VK_ds,8047
4
+ llm_gemini-0.18.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
5
+ llm_gemini-0.18.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
6
+ llm_gemini-0.18.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
7
+ llm_gemini-0.18.dist-info/RECORD,,
llm_gemini.py CHANGED
@@ -37,6 +37,9 @@ GOOGLE_SEARCH_MODELS = {
37
37
  "gemini-2.0-flash-exp",
38
38
  "gemini-2.0-flash",
39
39
  }
40
+ THINKING_BUDGET_MODELS = {
41
+ "gemini-2.5-flash-preview-04-17",
42
+ }
40
43
 
41
44
 
42
45
  @llm.hookimpl
@@ -70,17 +73,22 @@ def register_models(register):
70
73
  "gemini-2.5-pro-exp-03-25",
71
74
  # 4th April 2025 (paid):
72
75
  "gemini-2.5-pro-preview-03-25",
76
+ # 17th April 2025:
77
+ "gemini-2.5-flash-preview-04-17",
73
78
  ]:
74
79
  can_google_search = model_id in GOOGLE_SEARCH_MODELS
80
+ can_thinking_budget = model_id in THINKING_BUDGET_MODELS
75
81
  register(
76
82
  GeminiPro(
77
83
  model_id,
78
84
  can_google_search=can_google_search,
85
+ can_thinking_budget=can_thinking_budget,
79
86
  can_schema="flash-thinking" not in model_id,
80
87
  ),
81
88
  AsyncGeminiPro(
82
89
  model_id,
83
90
  can_google_search=can_google_search,
91
+ can_thinking_budget=can_thinking_budget,
84
92
  can_schema="flash-thinking" not in model_id,
85
93
  ),
86
94
  )
@@ -208,12 +216,27 @@ class _SharedGemini:
208
216
  default=None,
209
217
  )
210
218
 
211
- def __init__(self, model_id, can_google_search=False, can_schema=False):
219
+ class OptionsWithThinkingBudget(OptionsWithGoogleSearch):
220
+ thinking_budget: Optional[int] = Field(
221
+ description="Indicates the thinking budget in tokens. Set to 0 to disable.",
222
+ default=None,
223
+ )
224
+
225
+ def __init__(
226
+ self,
227
+ model_id,
228
+ can_google_search=False,
229
+ can_thinking_budget=False,
230
+ can_schema=False,
231
+ ):
212
232
  self.model_id = model_id
213
233
  self.can_google_search = can_google_search
214
234
  self.supports_schema = can_schema
215
235
  if can_google_search:
216
236
  self.Options = self.OptionsWithGoogleSearch
237
+ self.can_thinking_budget = can_thinking_budget
238
+ if can_thinking_budget:
239
+ self.Options = self.OptionsWithThinkingBudget
217
240
 
218
241
  def build_messages(self, prompt, conversation):
219
242
  messages = []
@@ -266,10 +289,18 @@ class _SharedGemini:
266
289
  if prompt.system:
267
290
  body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
268
291
 
292
+ generation_config = {}
293
+
269
294
  if prompt.schema:
270
- body["generationConfig"] = {
271
- "response_mime_type": "application/json",
272
- "response_schema": cleanup_schema(copy.deepcopy(prompt.schema)),
295
+ generation_config.update(
296
+ {
297
+ "response_mime_type": "application/json",
298
+ "response_schema": cleanup_schema(copy.deepcopy(prompt.schema)),
299
+ }
300
+ )
301
+ if self.can_thinking_budget and prompt.options.thinking_budget is not None:
302
+ generation_config["thinking_config"] = {
303
+ "thinking_budget": prompt.options.thinking_budget
273
304
  }
274
305
 
275
306
  config_map = {
@@ -279,16 +310,17 @@ class _SharedGemini:
279
310
  "top_k": "topK",
280
311
  }
281
312
  if prompt.options and prompt.options.json_object:
282
- body["generationConfig"] = {"response_mime_type": "application/json"}
313
+ generation_config["response_mime_type"] = "application/json"
283
314
 
284
315
  if any(
285
316
  getattr(prompt.options, key, None) is not None for key in config_map.keys()
286
317
  ):
287
- generation_config = {}
288
318
  for key, other_key in config_map.items():
289
319
  config_value = getattr(prompt.options, key, None)
290
320
  if config_value is not None:
291
321
  generation_config[other_key] = config_value
322
+
323
+ if generation_config:
292
324
  body["generationConfig"] = generation_config
293
325
 
294
326
  return body
@@ -1,7 +0,0 @@
1
- llm_gemini.py,sha256=pZGkm61gSK9DSIubZxmW4YVUnjTS4JuKUtK0yqo9ms4,16511
2
- llm_gemini-0.17.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
- llm_gemini-0.17.dist-info/METADATA,sha256=elmIQKpgDA2SaG8SINSBx5s6mztvvVNZtL46BFvTUJo,7985
4
- llm_gemini-0.17.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
5
- llm_gemini-0.17.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
6
- llm_gemini-0.17.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
7
- llm_gemini-0.17.dist-info/RECORD,,