@@ -50,7 +50,7 @@ If you use Gemini through a proxy service, change the URL base."
50
50
51
51
; ; https://ai.google.dev/gemini-api/docs/tokens
52
52
; ; A token is equivalent to _about_ 4 characters.
53
- (cl-defun chatgpt-shell-google-make-model (&key version short-version path token-width context-window )
53
+ (cl-defun chatgpt-shell-google-make-model (&key version short-version path token-width context-window grounding-search )
54
54
" Create a Google model.
55
55
56
56
Set VERSION, SHORT-VERSION, PATH, TOKEN-WIDTH, CONTEXT-WINDOW and
@@ -72,6 +72,7 @@ VALIDATE-COMMAND handler."
72
72
(:path . , path )
73
73
(:token-width . , token-width )
74
74
(:context-window . , context-window )
75
+ (:grounding-search . , grounding-search )
75
76
(:url-base . chatgpt-shell-google-api-url-base)
76
77
(:handler . chatgpt-shell-google--handle-gemini-command)
77
78
(:filter . chatgpt-shell-google--extract-gemini-response)
@@ -88,6 +89,7 @@ VALIDATE-COMMAND handler."
88
89
(list (chatgpt-shell-google-make-model :version " gemini-2.0-flash"
89
90
:short-version " 2.0-flash"
90
91
:path " /v1beta/models/gemini-2.0-flash"
92
+ :grounding-search t
91
93
:token-width 4
92
94
:context-window 1048576 )
93
95
(chatgpt-shell-google-make-model :version " gemini-1.5-pro-latest"
150
152
" Create the API headers."
151
153
(list " Content-Type: application/json; charset=utf-8" ))
152
154
153
- (cl-defun chatgpt-shell-google--make-payload (&key _model context settings )
155
+ (cl-defun chatgpt-shell-google--make-payload (&key model context settings )
154
156
" Create the API payload using MODEL CONTEXT and SETTINGS."
155
157
(chatgpt-shell-google--make-gemini-payload
156
158
:context context
157
- :temperature ( map-elt settings :temperature )
158
- :system-prompt ( map-elt settings :system-prompt ) ))
159
+ :model model
160
+ :settings settings ))
159
161
160
162
(cl-defun chatgpt-shell-google--handle-gemini-command (&key model command context shell settings )
161
163
" Handle Gemini COMMAND (prompt) using MODEL, CONTEXT, SHELL, and SETTINGS."
167
169
:data (chatgpt-shell-google--make-gemini-payload
168
170
:prompt command
169
171
:context context
170
- :temperature ( map-elt settings :temperature )
171
- :system-prompt ( map-elt settings :system-prompt ) )
172
+ :model model
173
+ :settings settings )
172
174
:headers (list " Content-Type: application/json; charset=utf-8" )
173
175
:filter #'chatgpt-shell-google--extract-gemini-response
174
176
:shell shell))
175
177
176
- (cl-defun chatgpt-shell-google--make-gemini-payload (&key prompt context system-prompt temperature )
178
+ (cl-defun chatgpt-shell-google--make-gemini-payload (&key prompt context settings model )
177
179
" Create the request payload.
178
180
179
181
Compose using PROMPT, CONTEXT, SYSTEM-PROMPT and TEMPERATURE."
180
182
(append
181
- (when system-prompt
182
- `((system_instruction . ((parts . ((text . , system-prompt )))))))
183
+ (when ( map-elt settings : system-prompt)
184
+ `((system_instruction . ((parts . ((text . ,( map-elt settings : system-prompt) )))))))
183
185
`((contents . ,(vconcat
184
186
(chatgpt-shell-google--gemini-user-model-messages
185
187
(append context
186
188
(when prompt
187
- (list (cons prompt nil )))))))
188
- (generation_config . ((temperature . ,(or temperature 1 ))
189
+ (list (cons prompt nil ))))))))
190
+ (when (map-elt model :grounding-search )
191
+ '((tools . ((google_search . ())))))
192
+ `((generation_config . ((temperature . ,(or (map-elt settings :temperature ) 1 ))
189
193
; ; 1 is most diverse output.
190
194
(topP . 1 ))))))
191
195
0 commit comments