llm-gemini 0.16__tar.gz → 0.18__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.16
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
@@ -57,9 +57,18 @@ llm -m gemini-2.0-flash "A short joke about a pelican and a walrus"
57
57
  >
58
58
  > The walrus sighs and says, "It's a long story. Let's just say we met through a mutual friend... of the fin."
59
59
 
60
+ You can set the [default model](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-default-model) to avoid the extra `-m` option:
61
+
62
+ ```bash
63
+ llm models default gemini-2.0-flash
64
+ llm "A joke about a pelican and a walrus"
65
+ ```
66
+
60
67
  Other models are:
61
68
 
62
- - `gemini-2.5-pro-exp-03-25` - experimental release of Gemini 2.5 Pro
69
+ - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
70
+ - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
71
+ - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
63
72
  - `gemma-3-27b-it` - [Gemma 3](https://blog.google/technology/developers/gemma-3/) 27B
64
73
  - `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
65
74
  - `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
@@ -79,23 +88,23 @@ Other models are:
79
88
  Gemini models are multi-modal. You can provide images, audio or video files as input like this:
80
89
 
81
90
  ```bash
82
- llm -m gemini-1.5-flash-latest 'extract text' -a image.jpg
91
+ llm -m gemini-2.0-flash 'extract text' -a image.jpg
83
92
  ```
84
93
  Or with a URL:
85
94
  ```bash
86
- llm -m gemini-1.5-flash-8b-latest 'describe image' \
95
+ llm -m gemini-2.0-flash-lite 'describe image' \
87
96
  -a https://static.simonwillison.net/static/2024/pelicans.jpg
88
97
  ```
89
98
  Audio works too:
90
99
 
91
100
  ```bash
92
- llm -m gemini-1.5-pro-latest 'transcribe audio' -a audio.mp3
101
+ llm -m gemini-2.0-flash 'transcribe audio' -a audio.mp3
93
102
  ```
94
103
 
95
104
  And video:
96
105
 
97
106
  ```bash
98
- llm -m gemini-1.5-pro-latest 'describe what happens' -a video.mp4
107
+ llm -m gemini-2.0-flash 'describe what happens' -a video.mp4
99
108
  ```
100
109
  The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gemini-api/docs/file-prompting-strategies) on multi-modal prompting.
101
110
 
@@ -104,7 +113,7 @@ The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gem
104
113
  Use `-o json_object 1` to force the output to be JSON:
105
114
 
106
115
  ```bash
107
- llm -m gemini-1.5-flash-latest -o json_object 1 \
116
+ llm -m gemini-2.0-flash -o json_object 1 \
108
117
  '3 largest cities in California, list of {"name": "..."}'
109
118
  ```
110
119
  Outputs:
@@ -119,7 +128,7 @@ Gemini models can [write and execute code](https://ai.google.dev/gemini-api/docs
119
128
  To enable this feature, use `-o code_execution 1`:
120
129
 
121
130
  ```bash
122
- llm -m gemini-1.5-pro-latest -o code_execution 1 \
131
+ llm -m gemini-2.0-flash -o code_execution 1 \
123
132
  'use python to calculate (factorial of 13) * 3'
124
133
  ```
125
134
  ### Google search
@@ -131,7 +140,7 @@ Using this feature may incur additional requirements in terms of how you use the
131
140
  To run a prompt with Google search enabled, use `-o google_search 1`:
132
141
 
133
142
  ```bash
134
- llm -m gemini-1.5-pro-latest -o google_search 1 \
143
+ llm -m gemini-2.0-flash -o google_search 1 \
135
144
  'What happened in Ireland today?'
136
145
  ```
137
146
 
@@ -142,7 +151,7 @@ Use `llm logs -c --json` after running a prompt to see the full JSON response, w
142
151
  To chat interactively with the model, run `llm chat`:
143
152
 
144
153
  ```bash
145
- llm chat -m gemini-1.5-pro-latest
154
+ llm chat -m gemini-2.0-flash
146
155
  ```
147
156
 
148
157
  ## Embeddings
@@ -205,4 +214,3 @@ You will need to have stored a valid Gemini API key using this command first:
205
214
  llm keys set gemini
206
215
  # Paste key here
207
216
  ```
208
-
@@ -34,9 +34,18 @@ llm -m gemini-2.0-flash "A short joke about a pelican and a walrus"
34
34
  >
35
35
  > The walrus sighs and says, "It's a long story. Let's just say we met through a mutual friend... of the fin."
36
36
 
37
+ You can set the [default model](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-default-model) to avoid the extra `-m` option:
38
+
39
+ ```bash
40
+ llm models default gemini-2.0-flash
41
+ llm "A joke about a pelican and a walrus"
42
+ ```
43
+
37
44
  Other models are:
38
45
 
39
- - `gemini-2.5-pro-exp-03-25` - experimental release of Gemini 2.5 Pro
46
+ - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
47
+ - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
48
+ - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
40
49
  - `gemma-3-27b-it` - [Gemma 3](https://blog.google/technology/developers/gemma-3/) 27B
41
50
  - `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
42
51
  - `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
@@ -56,23 +65,23 @@ Other models are:
56
65
  Gemini models are multi-modal. You can provide images, audio or video files as input like this:
57
66
 
58
67
  ```bash
59
- llm -m gemini-1.5-flash-latest 'extract text' -a image.jpg
68
+ llm -m gemini-2.0-flash 'extract text' -a image.jpg
60
69
  ```
61
70
  Or with a URL:
62
71
  ```bash
63
- llm -m gemini-1.5-flash-8b-latest 'describe image' \
72
+ llm -m gemini-2.0-flash-lite 'describe image' \
64
73
  -a https://static.simonwillison.net/static/2024/pelicans.jpg
65
74
  ```
66
75
  Audio works too:
67
76
 
68
77
  ```bash
69
- llm -m gemini-1.5-pro-latest 'transcribe audio' -a audio.mp3
78
+ llm -m gemini-2.0-flash 'transcribe audio' -a audio.mp3
70
79
  ```
71
80
 
72
81
  And video:
73
82
 
74
83
  ```bash
75
- llm -m gemini-1.5-pro-latest 'describe what happens' -a video.mp4
84
+ llm -m gemini-2.0-flash 'describe what happens' -a video.mp4
76
85
  ```
77
86
  The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gemini-api/docs/file-prompting-strategies) on multi-modal prompting.
78
87
 
@@ -81,7 +90,7 @@ The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gem
81
90
  Use `-o json_object 1` to force the output to be JSON:
82
91
 
83
92
  ```bash
84
- llm -m gemini-1.5-flash-latest -o json_object 1 \
93
+ llm -m gemini-2.0-flash -o json_object 1 \
85
94
  '3 largest cities in California, list of {"name": "..."}'
86
95
  ```
87
96
  Outputs:
@@ -96,7 +105,7 @@ Gemini models can [write and execute code](https://ai.google.dev/gemini-api/docs
96
105
  To enable this feature, use `-o code_execution 1`:
97
106
 
98
107
  ```bash
99
- llm -m gemini-1.5-pro-latest -o code_execution 1 \
108
+ llm -m gemini-2.0-flash -o code_execution 1 \
100
109
  'use python to calculate (factorial of 13) * 3'
101
110
  ```
102
111
  ### Google search
@@ -108,7 +117,7 @@ Using this feature may incur additional requirements in terms of how you use the
108
117
  To run a prompt with Google search enabled, use `-o google_search 1`:
109
118
 
110
119
  ```bash
111
- llm -m gemini-1.5-pro-latest -o google_search 1 \
120
+ llm -m gemini-2.0-flash -o google_search 1 \
112
121
  'What happened in Ireland today?'
113
122
  ```
114
123
 
@@ -119,7 +128,7 @@ Use `llm logs -c --json` after running a prompt to see the full JSON response, w
119
128
  To chat interactively with the model, run `llm chat`:
120
129
 
121
130
  ```bash
122
- llm chat -m gemini-1.5-pro-latest
131
+ llm chat -m gemini-2.0-flash
123
132
  ```
124
133
 
125
134
  ## Embeddings
@@ -182,4 +191,3 @@ You will need to have stored a valid Gemini API key using this command first:
182
191
  llm keys set gemini
183
192
  # Paste key here
184
193
  ```
185
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llm-gemini
3
- Version: 0.16
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
@@ -57,9 +57,18 @@ llm -m gemini-2.0-flash "A short joke about a pelican and a walrus"
57
57
  >
58
58
  > The walrus sighs and says, "It's a long story. Let's just say we met through a mutual friend... of the fin."
59
59
 
60
+ You can set the [default model](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-default-model) to avoid the extra `-m` option:
61
+
62
+ ```bash
63
+ llm models default gemini-2.0-flash
64
+ llm "A joke about a pelican and a walrus"
65
+ ```
66
+
60
67
  Other models are:
61
68
 
62
- - `gemini-2.5-pro-exp-03-25` - experimental release of Gemini 2.5 Pro
69
+ - `gemini-2.5-flash-preview-04-17` - Gemini 2.5 Flash preview
70
+ - `gemini-2.5-pro-exp-03-25` - free experimental release of Gemini 2.5 Pro
71
+ - `gemini-2.5-pro-preview-03-25` - paid preview of Gemini 2.5 Pro
63
72
  - `gemma-3-27b-it` - [Gemma 3](https://blog.google/technology/developers/gemma-3/) 27B
64
73
  - `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
65
74
  - `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
@@ -79,23 +88,23 @@ Other models are:
79
88
  Gemini models are multi-modal. You can provide images, audio or video files as input like this:
80
89
 
81
90
  ```bash
82
- llm -m gemini-1.5-flash-latest 'extract text' -a image.jpg
91
+ llm -m gemini-2.0-flash 'extract text' -a image.jpg
83
92
  ```
84
93
  Or with a URL:
85
94
  ```bash
86
- llm -m gemini-1.5-flash-8b-latest 'describe image' \
95
+ llm -m gemini-2.0-flash-lite 'describe image' \
87
96
  -a https://static.simonwillison.net/static/2024/pelicans.jpg
88
97
  ```
89
98
  Audio works too:
90
99
 
91
100
  ```bash
92
- llm -m gemini-1.5-pro-latest 'transcribe audio' -a audio.mp3
101
+ llm -m gemini-2.0-flash 'transcribe audio' -a audio.mp3
93
102
  ```
94
103
 
95
104
  And video:
96
105
 
97
106
  ```bash
98
- llm -m gemini-1.5-pro-latest 'describe what happens' -a video.mp4
107
+ llm -m gemini-2.0-flash 'describe what happens' -a video.mp4
99
108
  ```
100
109
  The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gemini-api/docs/file-prompting-strategies) on multi-modal prompting.
101
110
 
@@ -104,7 +113,7 @@ The Gemini prompting guide includes [extensive advice](https://ai.google.dev/gem
104
113
  Use `-o json_object 1` to force the output to be JSON:
105
114
 
106
115
  ```bash
107
- llm -m gemini-1.5-flash-latest -o json_object 1 \
116
+ llm -m gemini-2.0-flash -o json_object 1 \
108
117
  '3 largest cities in California, list of {"name": "..."}'
109
118
  ```
110
119
  Outputs:
@@ -119,7 +128,7 @@ Gemini models can [write and execute code](https://ai.google.dev/gemini-api/docs
119
128
  To enable this feature, use `-o code_execution 1`:
120
129
 
121
130
  ```bash
122
- llm -m gemini-1.5-pro-latest -o code_execution 1 \
131
+ llm -m gemini-2.0-flash -o code_execution 1 \
123
132
  'use python to calculate (factorial of 13) * 3'
124
133
  ```
125
134
  ### Google search
@@ -131,7 +140,7 @@ Using this feature may incur additional requirements in terms of how you use the
131
140
  To run a prompt with Google search enabled, use `-o google_search 1`:
132
141
 
133
142
  ```bash
134
- llm -m gemini-1.5-pro-latest -o google_search 1 \
143
+ llm -m gemini-2.0-flash -o google_search 1 \
135
144
  'What happened in Ireland today?'
136
145
  ```
137
146
 
@@ -142,7 +151,7 @@ Use `llm logs -c --json` after running a prompt to see the full JSON response, w
142
151
  To chat interactively with the model, run `llm chat`:
143
152
 
144
153
  ```bash
145
- llm chat -m gemini-1.5-pro-latest
154
+ llm chat -m gemini-2.0-flash
146
155
  ```
147
156
 
148
157
  ## Embeddings
@@ -205,4 +214,3 @@ You will need to have stored a valid Gemini API key using this command first:
205
214
  llm keys set gemini
206
215
  # Paste key here
207
216
  ```
208
-
@@ -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
@@ -68,17 +71,24 @@ def register_models(register):
68
71
  "gemma-3-27b-it",
69
72
  # 25th March 2025:
70
73
  "gemini-2.5-pro-exp-03-25",
74
+ # 4th April 2025 (paid):
75
+ "gemini-2.5-pro-preview-03-25",
76
+ # 17th April 2025:
77
+ "gemini-2.5-flash-preview-04-17",
71
78
  ]:
72
79
  can_google_search = model_id in GOOGLE_SEARCH_MODELS
80
+ can_thinking_budget = model_id in THINKING_BUDGET_MODELS
73
81
  register(
74
82
  GeminiPro(
75
83
  model_id,
76
84
  can_google_search=can_google_search,
85
+ can_thinking_budget=can_thinking_budget,
77
86
  can_schema="flash-thinking" not in model_id,
78
87
  ),
79
88
  AsyncGeminiPro(
80
89
  model_id,
81
90
  can_google_search=can_google_search,
91
+ can_thinking_budget=can_thinking_budget,
82
92
  can_schema="flash-thinking" not in model_id,
83
93
  ),
84
94
  )
@@ -206,12 +216,27 @@ class _SharedGemini:
206
216
  default=None,
207
217
  )
208
218
 
209
- 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
+ ):
210
232
  self.model_id = model_id
211
233
  self.can_google_search = can_google_search
212
234
  self.supports_schema = can_schema
213
235
  if can_google_search:
214
236
  self.Options = self.OptionsWithGoogleSearch
237
+ self.can_thinking_budget = can_thinking_budget
238
+ if can_thinking_budget:
239
+ self.Options = self.OptionsWithThinkingBudget
215
240
 
216
241
  def build_messages(self, prompt, conversation):
217
242
  messages = []
@@ -264,10 +289,18 @@ class _SharedGemini:
264
289
  if prompt.system:
265
290
  body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
266
291
 
292
+ generation_config = {}
293
+
267
294
  if prompt.schema:
268
- body["generationConfig"] = {
269
- "response_mime_type": "application/json",
270
- "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
271
304
  }
272
305
 
273
306
  config_map = {
@@ -277,16 +310,17 @@ class _SharedGemini:
277
310
  "top_k": "topK",
278
311
  }
279
312
  if prompt.options and prompt.options.json_object:
280
- body["generationConfig"] = {"response_mime_type": "application/json"}
313
+ generation_config["response_mime_type"] = "application/json"
281
314
 
282
315
  if any(
283
316
  getattr(prompt.options, key, None) is not None for key in config_map.keys()
284
317
  ):
285
- generation_config = {}
286
318
  for key, other_key in config_map.items():
287
319
  config_value = getattr(prompt.options, key, None)
288
320
  if config_value is not None:
289
321
  generation_config[other_key] = config_value
322
+
323
+ if generation_config:
290
324
  body["generationConfig"] = generation_config
291
325
 
292
326
  return body
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llm-gemini"
3
- version = "0.16"
3
+ version = "0.18"
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