llm-gemini 0.7__tar.gz → 0.9__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
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: llm-gemini
3
- Version: 0.7
3
+ Version: 0.9
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License: Apache-2.0
@@ -64,6 +64,9 @@ Other models are:
64
64
  - `gemini-exp-1121` - recent experimental #2
65
65
  - `gemini-exp-1206` - recent experimental #3
66
66
  - `gemini-2.0-flash-exp` - [Gemini 2.0 Flash](https://blog.google/technology/google-deepmind/google-gemini-ai-update-december-2024/#gemini-2-0-flash)
67
+ - `learnlm-1.5-pro-experimental` - "an experimental task-specific model that has been trained to align with learning science principles" - [more details here](https://ai.google.dev/gemini-api/docs/learnlm).
68
+ - `gemini-2.0-flash-thinking-exp-1219` - experimental "thinking" model from December 2024
69
+ - `gemini-2.0-flash-thinking-exp-01-21` - experimental "thinking" model from January 2025
67
70
 
68
71
  ### Images, audio and video
69
72
 
@@ -113,6 +116,20 @@ To enable this feature, use `-o code_execution 1`:
113
116
  llm -m gemini-1.5-pro-latest -o code_execution 1 \
114
117
  'use python to calculate (factorial of 13) * 3'
115
118
  ```
119
+ ### Google search
120
+
121
+ Some Gemini models support [Grounding with Google Search](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini), where the model can run a Google search and use the results as part of answering a prompt.
122
+
123
+ Using this feature may incur additional requirements in terms of how you use the results. Consult [Google's documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini) for more details.
124
+
125
+ To run a prompt with Google search enabled, use `-o google_search 1`:
126
+
127
+ ```bash
128
+ llm -m gemini-1.5-pro-latest -o google_search 1 \
129
+ 'What happened in Ireland today?'
130
+ ```
131
+
132
+ 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.
116
133
 
117
134
  ### Chat
118
135
 
@@ -44,6 +44,9 @@ Other models are:
44
44
  - `gemini-exp-1121` - recent experimental #2
45
45
  - `gemini-exp-1206` - recent experimental #3
46
46
  - `gemini-2.0-flash-exp` - [Gemini 2.0 Flash](https://blog.google/technology/google-deepmind/google-gemini-ai-update-december-2024/#gemini-2-0-flash)
47
+ - `learnlm-1.5-pro-experimental` - "an experimental task-specific model that has been trained to align with learning science principles" - [more details here](https://ai.google.dev/gemini-api/docs/learnlm).
48
+ - `gemini-2.0-flash-thinking-exp-1219` - experimental "thinking" model from December 2024
49
+ - `gemini-2.0-flash-thinking-exp-01-21` - experimental "thinking" model from January 2025
47
50
 
48
51
  ### Images, audio and video
49
52
 
@@ -93,6 +96,20 @@ To enable this feature, use `-o code_execution 1`:
93
96
  llm -m gemini-1.5-pro-latest -o code_execution 1 \
94
97
  'use python to calculate (factorial of 13) * 3'
95
98
  ```
99
+ ### Google search
100
+
101
+ Some Gemini models support [Grounding with Google Search](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini), where the model can run a Google search and use the results as part of answering a prompt.
102
+
103
+ Using this feature may incur additional requirements in terms of how you use the results. Consult [Google's documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini) for more details.
104
+
105
+ To run a prompt with Google search enabled, use `-o google_search 1`:
106
+
107
+ ```bash
108
+ llm -m gemini-1.5-pro-latest -o google_search 1 \
109
+ 'What happened in Ireland today?'
110
+ ```
111
+
112
+ 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.
96
113
 
97
114
  ### Chat
98
115
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: llm-gemini
3
- Version: 0.7
3
+ Version: 0.9
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License: Apache-2.0
@@ -64,6 +64,9 @@ Other models are:
64
64
  - `gemini-exp-1121` - recent experimental #2
65
65
  - `gemini-exp-1206` - recent experimental #3
66
66
  - `gemini-2.0-flash-exp` - [Gemini 2.0 Flash](https://blog.google/technology/google-deepmind/google-gemini-ai-update-december-2024/#gemini-2-0-flash)
67
+ - `learnlm-1.5-pro-experimental` - "an experimental task-specific model that has been trained to align with learning science principles" - [more details here](https://ai.google.dev/gemini-api/docs/learnlm).
68
+ - `gemini-2.0-flash-thinking-exp-1219` - experimental "thinking" model from December 2024
69
+ - `gemini-2.0-flash-thinking-exp-01-21` - experimental "thinking" model from January 2025
67
70
 
68
71
  ### Images, audio and video
69
72
 
@@ -113,6 +116,20 @@ To enable this feature, use `-o code_execution 1`:
113
116
  llm -m gemini-1.5-pro-latest -o code_execution 1 \
114
117
  'use python to calculate (factorial of 13) * 3'
115
118
  ```
119
+ ### Google search
120
+
121
+ Some Gemini models support [Grounding with Google Search](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini), where the model can run a Google search and use the results as part of answering a prompt.
122
+
123
+ Using this feature may incur additional requirements in terms of how you use the results. Consult [Google's documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#web-ground-gemini) for more details.
124
+
125
+ To run a prompt with Google search enabled, use `-o google_search 1`:
126
+
127
+ ```bash
128
+ llm -m gemini-1.5-pro-latest -o google_search 1 \
129
+ 'What happened in Ireland today?'
130
+ ```
131
+
132
+ 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.
116
133
 
117
134
  ### Chat
118
135
 
@@ -23,6 +23,17 @@ SAFETY_SETTINGS = [
23
23
  },
24
24
  ]
25
25
 
26
+ # https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/ground-gemini#supported_models_2
27
+ GOOGLE_SEARCH_MODELS = {
28
+ "gemini-1.5-pro-latest",
29
+ "gemini-1.5-flash-latest",
30
+ "gemini-1.5-pro-001",
31
+ "gemini-1.5-flash-001",
32
+ "gemini-1.5-pro-002",
33
+ "gemini-1.5-flash-002",
34
+ "gemini-2.0-flash-exp",
35
+ }
36
+
26
37
 
27
38
  @llm.hookimpl
28
39
  def register_models(register):
@@ -41,8 +52,15 @@ def register_models(register):
41
52
  "gemini-exp-1121",
42
53
  "gemini-exp-1206",
43
54
  "gemini-2.0-flash-exp",
55
+ "learnlm-1.5-pro-experimental",
56
+ "gemini-2.0-flash-thinking-exp-1219",
57
+ "gemini-2.0-flash-thinking-exp-01-21",
44
58
  ]:
45
- register(GeminiPro(model_id), AsyncGeminiPro(model_id))
59
+ can_google_search = model_id in GOOGLE_SEARCH_MODELS
60
+ register(
61
+ GeminiPro(model_id, can_google_search=can_google_search),
62
+ AsyncGeminiPro(model_id, can_google_search=can_google_search),
63
+ )
46
64
 
47
65
 
48
66
  def resolve_type(attachment):
@@ -50,6 +68,8 @@ def resolve_type(attachment):
50
68
  # https://github.com/simonw/llm/issues/587#issuecomment-2439785140
51
69
  if mime_type == "audio/mpeg":
52
70
  mime_type = "audio/mp3"
71
+ if mime_type == "application/ogg":
72
+ mime_type = "audio/ogg"
53
73
  return mime_type
54
74
 
55
75
 
@@ -59,6 +79,9 @@ class _SharedGemini:
59
79
  can_stream = True
60
80
 
61
81
  attachment_types = (
82
+ # Text
83
+ "text/plain",
84
+ "text/csv",
62
85
  # PDF
63
86
  "application/pdf",
64
87
  # Images
@@ -73,6 +96,7 @@ class _SharedGemini:
73
96
  "audio/aiff",
74
97
  "audio/aac",
75
98
  "audio/ogg",
99
+ "application/ogg",
76
100
  "audio/flac",
77
101
  "audio/mpeg", # Treated as audio/mp3
78
102
  # Video
@@ -133,8 +157,17 @@ class _SharedGemini:
133
157
  default=None,
134
158
  )
135
159
 
136
- def __init__(self, model_id):
160
+ class OptionsWithGoogleSearch(Options):
161
+ google_search: Optional[bool] = Field(
162
+ description="Enables the model to use Google Search to improve the accuracy and recency of responses from the model",
163
+ default=None,
164
+ )
165
+
166
+ def __init__(self, model_id, can_google_search=False):
137
167
  self.model_id = model_id
168
+ self.can_google_search = can_google_search
169
+ if can_google_search:
170
+ self.Options = self.OptionsWithGoogleSearch
138
171
 
139
172
  def build_messages(self, prompt, conversation):
140
173
  messages = []
@@ -154,7 +187,9 @@ class _SharedGemini:
154
187
  if response.prompt.prompt:
155
188
  parts.append({"text": response.prompt.prompt})
156
189
  messages.append({"role": "user", "parts": parts})
157
- messages.append({"role": "model", "parts": [{"text": response.text()}]})
190
+ messages.append(
191
+ {"role": "model", "parts": [{"text": response.text_or_raise()}]}
192
+ )
158
193
 
159
194
  parts = []
160
195
  if prompt.prompt:
@@ -180,6 +215,8 @@ class _SharedGemini:
180
215
  }
181
216
  if prompt.options and prompt.options.code_execution:
182
217
  body["tools"] = [{"codeExecution": {}}]
218
+ if prompt.options and self.can_google_search and prompt.options.google_search:
219
+ body["tools"] = [{"google_search_retrieval": {}}]
183
220
  if prompt.system:
184
221
  body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
185
222
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llm-gemini"
3
- version = "0.7"
3
+ version = "0.9"
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
File without changes