llm-gemini 0.18__tar.gz → 0.19__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.4
2
2
  Name: llm-gemini
3
- Version: 0.18
3
+ Version: 0.19
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-pro-preview-05-06` - latest paid Gemini 2.5 Pro preview
69
70
  - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
70
71
  - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
71
72
  - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
@@ -43,6 +43,7 @@ llm "A joke about a pelican and a walrus"
43
43
 
44
44
  Other models are:
45
45
 
46
+ - `gemini-2.5-pro-preview-05-06` - latest paid Gemini 2.5 Pro preview
46
47
  - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
47
48
  - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
48
49
  - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llm-gemini
3
- Version: 0.18
3
+ Version: 0.19
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-pro-preview-05-06` - latest paid Gemini 2.5 Pro preview
69
70
  - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
70
71
  - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
71
72
  - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
@@ -36,7 +36,23 @@ GOOGLE_SEARCH_MODELS = {
36
36
  "gemini-1.5-flash-002",
37
37
  "gemini-2.0-flash-exp",
38
38
  "gemini-2.0-flash",
39
+ "gemini-2.5-pro-preview-03-25",
40
+ "gemini-2.5-pro-exp-03-25",
41
+ "gemini-2.5-flash-preview-04-17",
42
+ "gemini-2.5-pro-preview-05-06",
39
43
  }
44
+
45
+ # Older Google models used google_search_retrieval instead of google_search
46
+ GOOGLE_SEARCH_MODELS_USING_SEARCH_RETRIEVAL = {
47
+ "gemini-1.5-pro-latest",
48
+ "gemini-1.5-flash-latest",
49
+ "gemini-1.5-pro-001",
50
+ "gemini-1.5-flash-001",
51
+ "gemini-1.5-pro-002",
52
+ "gemini-1.5-flash-002",
53
+ "gemini-2.0-flash-exp",
54
+ }
55
+
40
56
  THINKING_BUDGET_MODELS = {
41
57
  "gemini-2.5-flash-preview-04-17",
42
58
  }
@@ -75,6 +91,8 @@ def register_models(register):
75
91
  "gemini-2.5-pro-preview-03-25",
76
92
  # 17th April 2025:
77
93
  "gemini-2.5-flash-preview-04-17",
94
+ # 6th May 2025:
95
+ "gemini-2.5-pro-preview-05-06",
78
96
  ]:
79
97
  can_google_search = model_id in GOOGLE_SEARCH_MODELS
80
98
  can_thinking_budget = model_id in THINKING_BUDGET_MODELS
@@ -285,7 +303,12 @@ class _SharedGemini:
285
303
  if prompt.options and prompt.options.code_execution:
286
304
  body["tools"] = [{"codeExecution": {}}]
287
305
  if prompt.options and self.can_google_search and prompt.options.google_search:
288
- body["tools"] = [{"google_search": {}}]
306
+ tool_name = (
307
+ "google_search_retrieval"
308
+ if self.model_id in GOOGLE_SEARCH_MODELS_USING_SEARCH_RETRIEVAL
309
+ else "google_search"
310
+ )
311
+ body["tools"] = [{tool_name: {}}]
289
312
  if prompt.system:
290
313
  body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
291
314
 
@@ -490,9 +513,12 @@ def register_commands(cli):
490
513
  def models(key):
491
514
  "List of Gemini models pulled from their API"
492
515
  key = llm.get_key(key, "gemini", "LLM_GEMINI_KEY")
493
- response = httpx.get(
494
- f"https://generativelanguage.googleapis.com/v1beta/models?key={key}",
495
- )
516
+ if not key:
517
+ raise click.ClickException(
518
+ "You must set the LLM_GEMINI_KEY environment variable or use --key"
519
+ )
520
+ url = f"https://generativelanguage.googleapis.com/v1beta/models"
521
+ response = httpx.get(url, headers={"x-goog-api-key": key})
496
522
  response.raise_for_status()
497
523
  click.echo(json.dumps(response.json()["models"], indent=2))
498
524
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llm-gemini"
3
- version = "0.18"
3
+ version = "0.19"
4
4
  description = "LLM plugin to access Google's Gemini family of models"
5
5
  readme = "README.md"
6
6
  authors = [{name = "Simon Willison"}]
@@ -1,4 +1,6 @@
1
+ from click.testing import CliRunner
1
2
  import llm
3
+ from llm.cli import cli
2
4
  import nest_asyncio
3
5
  import json
4
6
  import os
@@ -210,3 +212,22 @@ def test_cleanup_schema(schema, expected):
210
212
  # Use a deep copy so the original test data remains unchanged.
211
213
  result = cleanup_schema(schema)
212
214
  assert result == expected
215
+
216
+
217
+ @pytest.mark.vcr
218
+ def test_cli_gemini_models(tmpdir, monkeypatch):
219
+ user_dir = tmpdir / "llm.datasette.io"
220
+ user_dir.mkdir()
221
+ monkeypatch.setenv("LLM_USER_PATH", str(user_dir))
222
+ # With no key set should error nicely
223
+ runner = CliRunner()
224
+ result = runner.invoke(cli, ["gemini", "models"])
225
+ assert result.exit_code == 1
226
+ assert (
227
+ "Error: You must set the LLM_GEMINI_KEY environment variable or use --key\n"
228
+ == result.output
229
+ )
230
+ # Try again with --key
231
+ result2 = runner.invoke(cli, ["gemini", "models", "--key", GEMINI_API_KEY])
232
+ assert result2.exit_code == 0
233
+ assert "gemini-1.5-flash-latest" in result2.output
File without changes
File without changes