@@ -55,7 +55,7 @@ If you use Gemini through a proxy service, change the URL base."
55
55
56
56
; ; https://ai.google.dev/gemini-api/docs/tokens
57
57
; ; A token is equivalent to _about_ 4 characters.
58
- (cl-defun chatgpt-shell-google-make-model (&key version short-version path token-width context-window )
58
+ (cl-defun chatgpt-shell-google-make-model (&key version short-version path token-width context-window grounding-search )
59
59
" Create a Google model.
60
60
61
61
Set VERSION, SHORT-VERSION, PATH, TOKEN-WIDTH, CONTEXT-WINDOW and
@@ -77,6 +77,7 @@ VALIDATE-COMMAND handler."
77
77
(:path . , path )
78
78
(:token-width . , token-width )
79
79
(:context-window . , context-window )
80
+ (:grounding-search . , grounding-search )
80
81
(:url-base . chatgpt-shell-google-api-url-base)
81
82
(:handler . chatgpt-shell-google--handle-gemini-command)
82
83
(:filter . chatgpt-shell-google--extract-gemini-response)
@@ -93,6 +94,7 @@ VALIDATE-COMMAND handler."
93
94
(list (chatgpt-shell-google-make-model :version " gemini-2.0-flash"
94
95
:short-version " 2.0-flash"
95
96
:path " /v1beta/models/gemini-2.0-flash"
97
+ :grounding-search t
96
98
:token-width 4
97
99
:context-window 1048576 )
98
100
(chatgpt-shell-google-make-model :version " gemini-1.5-pro-latest"
155
157
" Create the API headers."
156
158
(list " Content-Type: application/json; charset=utf-8" ))
157
159
158
- (cl-defun chatgpt-shell-google--make-payload (&key _model context settings )
160
+ (cl-defun chatgpt-shell-google--make-payload (&key model context settings )
159
161
" Create the API payload using MODEL CONTEXT and SETTINGS."
160
162
(chatgpt-shell-google--make-gemini-payload
161
163
:context context
162
- :temperature ( map-elt settings :temperature )
163
- :system-prompt ( map-elt settings :system-prompt ) ))
164
+ :model model
165
+ :settings settings ))
164
166
165
167
(cl-defun chatgpt-shell-google--handle-gemini-command (&key model command context shell settings )
166
168
" Handle Gemini COMMAND (prompt) using MODEL, CONTEXT, SHELL, and SETTINGS."
172
174
:data (chatgpt-shell-google--make-gemini-payload
173
175
:prompt command
174
176
:context context
175
- :temperature ( map-elt settings :temperature )
176
- :system-prompt ( map-elt settings :system-prompt ) )
177
+ :model model
178
+ :settings settings )
177
179
:headers (list " Content-Type: application/json; charset=utf-8" )
178
180
:filter #'chatgpt-shell-google--extract-gemini-response
179
181
:shell shell))
180
182
181
- (cl-defun chatgpt-shell-google--make-gemini-payload (&key prompt context system-prompt temperature )
183
+ (cl-defun chatgpt-shell-google--make-gemini-payload (&key prompt context settings model )
182
184
" Create the request payload.
183
185
184
186
Compose using PROMPT, CONTEXT, SYSTEM-PROMPT and TEMPERATURE."
185
187
(append
186
- (when system-prompt
187
- `((system_instruction . ((parts . ((text . , system-prompt )))))))
188
+ (when ( map-elt settings : system-prompt)
189
+ `((system_instruction . ((parts . ((text . ,( map-elt settings : system-prompt) )))))))
188
190
`((contents . ,(vconcat
189
191
(chatgpt-shell-google--gemini-user-model-messages
190
192
(append context
191
193
(when prompt
192
194
(list (cons prompt nil ))))))))
193
- (when chatgpt-shell-google-enable- grounding-search
195
+ (when ( map-elt model : grounding-search)
194
196
'((tools . ((google_search . ())))))
195
- `((generation_config . ((temperature . ,(or temperature 1 ))
197
+ `((generation_config . ((temperature . ,(or ( map-elt settings : temperature) 1 ))
196
198
; ; 1 is most diverse output.
197
199
(topP . 1 ))))))
198
200
0 commit comments