llm-gemini 0.23__tar.gz → 0.25__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.23
3
+ Version: 0.25
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License-Expression: Apache-2.0
@@ -77,7 +77,7 @@ to_output = []
77
77
  NOTES = {
78
78
  "gemini/gemini-2.5-pro": "Gemini 2.5 Pro",
79
79
  "gemini/gemini-2.5-flash": "Gemini 2.5 Flash",
80
- "gemini/gemini-2.5-flash-lite-preview-06-17": "Gemini 2.5 Lite Preview",
80
+ "gemini/gemini-2.5-flash-lite": "Gemini 2.5 Flash Lite",
81
81
  "gemini/gemini-2.5-flash-preview-05-20": "Gemini 2.5 Flash preview (priced differently from 2.5 Flash)",
82
82
  "gemini/gemini-2.0-flash-thinking-exp-01-21": "Experimental \"thinking\" model from January 2025",
83
83
  "gemini/gemini-1.5-flash-8b-latest": "The least expensive model",
@@ -93,9 +93,9 @@ for line in lines:
93
93
  )
94
94
  cog.out("\n".join(to_output))
95
95
  ]]] -->
96
+ - `gemini/gemini-2.5-flash-lite`: Gemini 2.5 Flash Lite
96
97
  - `gemini/gemini-2.5-pro`: Gemini 2.5 Pro
97
98
  - `gemini/gemini-2.5-flash`: Gemini 2.5 Flash
98
- - `gemini/gemini-2.5-flash-lite-preview-06-17`: Gemini 2.5 Lite Preview
99
99
  - `gemini/gemini-2.5-pro-preview-06-05`
100
100
  - `gemini/gemini-2.5-flash-preview-05-20`: Gemini 2.5 Flash preview (priced differently from 2.5 Flash)
101
101
  - `gemini/gemini-2.5-pro-preview-05-06`
@@ -197,6 +197,27 @@ llm -m gemini-2.0-flash -o google_search 1 \
197
197
 
198
198
  Use `llm logs -c --json` after running a prompt to see the full JSON response, which includes [additional information](https://github.com/simonw/llm-gemini/pull/29#issuecomment-2606201877) about grounded results.
199
199
 
200
+ ### URL context
201
+
202
+ Gemini models support a [URL context](https://ai.google.dev/gemini-api/docs/url-context) tool which, when enabled, allows the models to fetch additional content from URLs as part of their execution.
203
+
204
+ You can enable that with the `-o url_context 1` option - for example:
205
+
206
+ ```bash
207
+ llm -m gemini-2.5-flash -o url_context 1 'Latest headline on simonwillison.net'
208
+ ```
209
+ Extra tokens introduced by this tool will be charged as input tokens. Use `--usage` to see details of those:
210
+ ```bash
211
+ llm -m gemini-2.5-flash -o url_context 1 --usage \
212
+ 'Latest headline on simonwillison.net'
213
+ ```
214
+ Outputs:
215
+ ```
216
+ The latest headline on simonwillison.net as of August 17, 2025, is "TIL: Running a gpt-oss eval suite against LM Studio on a Mac.".
217
+ Token usage: 9,613 input, 87 output, {"candidatesTokenCount": 57, "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 10}], "toolUsePromptTokenCount": 9603, "toolUsePromptTokensDetails": [{"modality": "TEXT", "tokenCount": 9603}], "thoughtsTokenCount": 30}
218
+ ```
219
+ The `"toolUsePromptTokenCount"` key shows how many tokens were used for that URL context.
220
+
200
221
  ### Chat
201
222
 
202
223
  To chat interactively with the model, run `llm chat`:
@@ -54,7 +54,7 @@ to_output = []
54
54
  NOTES = {
55
55
  "gemini/gemini-2.5-pro": "Gemini 2.5 Pro",
56
56
  "gemini/gemini-2.5-flash": "Gemini 2.5 Flash",
57
- "gemini/gemini-2.5-flash-lite-preview-06-17": "Gemini 2.5 Lite Preview",
57
+ "gemini/gemini-2.5-flash-lite": "Gemini 2.5 Flash Lite",
58
58
  "gemini/gemini-2.5-flash-preview-05-20": "Gemini 2.5 Flash preview (priced differently from 2.5 Flash)",
59
59
  "gemini/gemini-2.0-flash-thinking-exp-01-21": "Experimental \"thinking\" model from January 2025",
60
60
  "gemini/gemini-1.5-flash-8b-latest": "The least expensive model",
@@ -70,9 +70,9 @@ for line in lines:
70
70
  )
71
71
  cog.out("\n".join(to_output))
72
72
  ]]] -->
73
+ - `gemini/gemini-2.5-flash-lite`: Gemini 2.5 Flash Lite
73
74
  - `gemini/gemini-2.5-pro`: Gemini 2.5 Pro
74
75
  - `gemini/gemini-2.5-flash`: Gemini 2.5 Flash
75
- - `gemini/gemini-2.5-flash-lite-preview-06-17`: Gemini 2.5 Lite Preview
76
76
  - `gemini/gemini-2.5-pro-preview-06-05`
77
77
  - `gemini/gemini-2.5-flash-preview-05-20`: Gemini 2.5 Flash preview (priced differently from 2.5 Flash)
78
78
  - `gemini/gemini-2.5-pro-preview-05-06`
@@ -174,6 +174,27 @@ llm -m gemini-2.0-flash -o google_search 1 \
174
174
 
175
175
  Use `llm logs -c --json` after running a prompt to see the full JSON response, which includes [additional information](https://github.com/simonw/llm-gemini/pull/29#issuecomment-2606201877) about grounded results.
176
176
 
177
+ ### URL context
178
+
179
+ Gemini models support a [URL context](https://ai.google.dev/gemini-api/docs/url-context) tool which, when enabled, allows the models to fetch additional content from URLs as part of their execution.
180
+
181
+ You can enable that with the `-o url_context 1` option - for example:
182
+
183
+ ```bash
184
+ llm -m gemini-2.5-flash -o url_context 1 'Latest headline on simonwillison.net'
185
+ ```
186
+ Extra tokens introduced by this tool will be charged as input tokens. Use `--usage` to see details of those:
187
+ ```bash
188
+ llm -m gemini-2.5-flash -o url_context 1 --usage \
189
+ 'Latest headline on simonwillison.net'
190
+ ```
191
+ Outputs:
192
+ ```
193
+ The latest headline on simonwillison.net as of August 17, 2025, is "TIL: Running a gpt-oss eval suite against LM Studio on a Mac.".
194
+ Token usage: 9,613 input, 87 output, {"candidatesTokenCount": 57, "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 10}], "toolUsePromptTokenCount": 9603, "toolUsePromptTokensDetails": [{"modality": "TEXT", "tokenCount": 9603}], "thoughtsTokenCount": 30}
195
+ ```
196
+ The `"toolUsePromptTokenCount"` key shows how many tokens were used for that URL context.
197
+
177
198
  ### Chat
178
199
 
179
200
  To chat interactively with the model, run `llm chat`:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llm-gemini
3
- Version: 0.23
3
+ Version: 0.25
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License-Expression: Apache-2.0
@@ -77,7 +77,7 @@ to_output = []
77
77
  NOTES = {
78
78
  "gemini/gemini-2.5-pro": "Gemini 2.5 Pro",
79
79
  "gemini/gemini-2.5-flash": "Gemini 2.5 Flash",
80
- "gemini/gemini-2.5-flash-lite-preview-06-17": "Gemini 2.5 Lite Preview",
80
+ "gemini/gemini-2.5-flash-lite": "Gemini 2.5 Flash Lite",
81
81
  "gemini/gemini-2.5-flash-preview-05-20": "Gemini 2.5 Flash preview (priced differently from 2.5 Flash)",
82
82
  "gemini/gemini-2.0-flash-thinking-exp-01-21": "Experimental \"thinking\" model from January 2025",
83
83
  "gemini/gemini-1.5-flash-8b-latest": "The least expensive model",
@@ -93,9 +93,9 @@ for line in lines:
93
93
  )
94
94
  cog.out("\n".join(to_output))
95
95
  ]]] -->
96
+ - `gemini/gemini-2.5-flash-lite`: Gemini 2.5 Flash Lite
96
97
  - `gemini/gemini-2.5-pro`: Gemini 2.5 Pro
97
98
  - `gemini/gemini-2.5-flash`: Gemini 2.5 Flash
98
- - `gemini/gemini-2.5-flash-lite-preview-06-17`: Gemini 2.5 Lite Preview
99
99
  - `gemini/gemini-2.5-pro-preview-06-05`
100
100
  - `gemini/gemini-2.5-flash-preview-05-20`: Gemini 2.5 Flash preview (priced differently from 2.5 Flash)
101
101
  - `gemini/gemini-2.5-pro-preview-05-06`
@@ -197,6 +197,27 @@ llm -m gemini-2.0-flash -o google_search 1 \
197
197
 
198
198
  Use `llm logs -c --json` after running a prompt to see the full JSON response, which includes [additional information](https://github.com/simonw/llm-gemini/pull/29#issuecomment-2606201877) about grounded results.
199
199
 
200
+ ### URL context
201
+
202
+ Gemini models support a [URL context](https://ai.google.dev/gemini-api/docs/url-context) tool which, when enabled, allows the models to fetch additional content from URLs as part of their execution.
203
+
204
+ You can enable that with the `-o url_context 1` option - for example:
205
+
206
+ ```bash
207
+ llm -m gemini-2.5-flash -o url_context 1 'Latest headline on simonwillison.net'
208
+ ```
209
+ Extra tokens introduced by this tool will be charged as input tokens. Use `--usage` to see details of those:
210
+ ```bash
211
+ llm -m gemini-2.5-flash -o url_context 1 --usage \
212
+ 'Latest headline on simonwillison.net'
213
+ ```
214
+ Outputs:
215
+ ```
216
+ The latest headline on simonwillison.net as of August 17, 2025, is "TIL: Running a gpt-oss eval suite against LM Studio on a Mac.".
217
+ Token usage: 9,613 input, 87 output, {"candidatesTokenCount": 57, "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 10}], "toolUsePromptTokenCount": 9603, "toolUsePromptTokensDetails": [{"modality": "TEXT", "tokenCount": 9603}], "thoughtsTokenCount": 30}
218
+ ```
219
+ The `"toolUsePromptTokenCount"` key shows how many tokens were used for that URL context.
220
+
200
221
  ### Chat
201
222
 
202
223
  To chat interactively with the model, run `llm chat`:
@@ -44,7 +44,7 @@ GOOGLE_SEARCH_MODELS = {
44
44
  "gemini-2.5-pro-preview-06-05",
45
45
  "gemini-2.5-pro",
46
46
  "gemini-2.5-flash",
47
- "gemini-2.5-flash-lite-preview-06-17",
47
+ "gemini-2.5-flash-lite",
48
48
  }
49
49
 
50
50
  # Older Google models used google_search_retrieval instead of google_search
@@ -69,7 +69,7 @@ THINKING_BUDGET_MODELS = {
69
69
  "gemini-2.5-pro-preview-06-05",
70
70
  "gemini-2.5-pro",
71
71
  "gemini-2.5-flash",
72
- "gemini-2.5-flash-lite-preview-06-17",
72
+ "gemini-2.5-flash-lite",
73
73
  }
74
74
 
75
75
  NO_VISION_MODELS = {"gemma-3-1b-it", "gemma-3n-e4b-it"}
@@ -152,10 +152,10 @@ def register_models(register):
152
152
  "gemini-2.5-flash-preview-05-20",
153
153
  # 5th June 2025:
154
154
  "gemini-2.5-pro-preview-06-05",
155
- # 17th June 2025:
156
- "gemini-2.5-flash-lite-preview-06-17",
157
155
  "gemini-2.5-flash",
158
156
  "gemini-2.5-pro",
157
+ # 22nd July 2025:
158
+ "gemini-2.5-flash-lite",
159
159
  ):
160
160
  can_google_search = model_id in GOOGLE_SEARCH_MODELS
161
161
  can_thinking_budget = model_id in THINKING_BUDGET_MODELS
@@ -272,6 +272,13 @@ class _SharedGemini:
272
272
  ),
273
273
  default=None,
274
274
  )
275
+ url_context: Optional[bool] = Field(
276
+ description=(
277
+ "Enable the URL context tool so the model can fetch content "
278
+ "from URLs mentioned in the prompt"
279
+ ),
280
+ default=None,
281
+ )
275
282
 
276
283
  class OptionsWithGoogleSearch(Options):
277
284
  google_search: Optional[bool] = Field(
@@ -339,8 +346,7 @@ class _SharedGemini:
339
346
  messages.append({"role": "user", "parts": parts})
340
347
  model_parts = []
341
348
  response_text = response.text_or_raise()
342
- if response_text:
343
- model_parts.append({"text": response_text})
349
+ model_parts.append({"text": response_text})
344
350
  tool_calls = response.tool_calls_or_raise()
345
351
  if tool_calls:
346
352
  model_parts.extend(
@@ -405,6 +411,8 @@ class _SharedGemini:
405
411
  else "google_search"
406
412
  )
407
413
  tools.append({tool_name: {}})
414
+ if prompt.options and prompt.options.url_context:
415
+ tools.append({"url_context": {}})
408
416
  if prompt.tools:
409
417
  tools.append(
410
418
  {
@@ -490,6 +498,12 @@ class _SharedGemini:
490
498
  candidates_token_count = usage.get("candidatesTokenCount") or 0
491
499
  thoughts_token_count = usage.get("thoughtsTokenCount") or 0
492
500
  output_tokens = candidates_token_count + thoughts_token_count
501
+ tool_token_count = usage.get("toolUsePromptTokenCount") or 0
502
+ if tool_token_count:
503
+ if input_tokens is None:
504
+ input_tokens = tool_token_count
505
+ else:
506
+ input_tokens += tool_token_count
493
507
  usage.pop("totalTokenCount", None)
494
508
  if input_tokens is not None:
495
509
  response.set_usage(
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llm-gemini"
3
- version = "0.23"
3
+ version = "0.25"
4
4
  description = "LLM plugin to access Google's Gemini family of models"
5
5
  readme = "README.md"
6
6
  authors = [{name = "Simon Willison"}]
File without changes
File without changes