@@ -175,13 +175,16 @@ func (g *geminiClient) send(ctx context.Context, messages []message.Message, too
175
175
176
176
history := geminiMessages [:len (geminiMessages )- 1 ] // All but last message
177
177
lastMsg := geminiMessages [len (geminiMessages )- 1 ]
178
- chat , _ := g . client . Chats . Create ( ctx , g . providerOptions . model . APIModel , & genai.GenerateContentConfig {
178
+ config := & genai.GenerateContentConfig {
179
179
MaxOutputTokens : int32 (g .providerOptions .maxTokens ),
180
180
SystemInstruction : & genai.Content {
181
181
Parts : []* genai.Part {{Text : g .providerOptions .systemMessage }},
182
182
},
183
- Tools : g .convertTools (tools ),
184
- }, history )
183
+ }
184
+ if len (tools ) > 0 {
185
+ config .Tools = g .convertTools (tools )
186
+ }
187
+ chat , _ := g .client .Chats .Create (ctx , g .providerOptions .model .APIModel , config , history )
185
188
186
189
attempts := 0
187
190
for {
@@ -260,13 +263,16 @@ func (g *geminiClient) stream(ctx context.Context, messages []message.Message, t
260
263
261
264
history := geminiMessages [:len (geminiMessages )- 1 ] // All but last message
262
265
lastMsg := geminiMessages [len (geminiMessages )- 1 ]
263
- chat , _ := g . client . Chats . Create ( ctx , g . providerOptions . model . APIModel , & genai.GenerateContentConfig {
266
+ config := & genai.GenerateContentConfig {
264
267
MaxOutputTokens : int32 (g .providerOptions .maxTokens ),
265
268
SystemInstruction : & genai.Content {
266
269
Parts : []* genai.Part {{Text : g .providerOptions .systemMessage }},
267
270
},
268
- Tools : g .convertTools (tools ),
269
- }, history )
271
+ }
272
+ if len (tools ) > 0 {
273
+ config .Tools = g .convertTools (tools )
274
+ }
275
+ chat , _ := g .client .Chats .Create (ctx , g .providerOptions .model .APIModel , config , history )
270
276
271
277
attempts := 0
272
278
eventChan := make (chan ProviderEvent )
@@ -415,26 +421,26 @@ func (g *geminiClient) shouldRetry(attempts int, err error) (bool, int64, error)
415
421
return true , int64 (retryMs ), nil
416
422
}
417
423
418
- func (g * geminiClient ) toolCalls (resp * genai.GenerateContentResponse ) []message.ToolCall {
419
- var toolCalls []message.ToolCall
420
-
421
- if len (resp .Candidates ) > 0 && resp .Candidates [0 ].Content != nil {
422
- for _ , part := range resp .Candidates [0 ].Content .Parts {
423
- if part .FunctionCall != nil {
424
- id := "call_" + uuid .New ().String ()
425
- args , _ := json .Marshal (part .FunctionCall .Args )
426
- toolCalls = append (toolCalls , message.ToolCall {
427
- ID : id ,
428
- Name : part .FunctionCall .Name ,
429
- Input : string (args ),
430
- Type : "function" ,
431
- })
432
- }
433
- }
434
- }
435
-
436
- return toolCalls
437
- }
424
+ // func (g *geminiClient) toolCalls(resp *genai.GenerateContentResponse) []message.ToolCall {
425
+ // var toolCalls []message.ToolCall
426
+ //
427
+ // if len(resp.Candidates) > 0 && resp.Candidates[0].Content != nil {
428
+ // for _, part := range resp.Candidates[0].Content.Parts {
429
+ // if part.FunctionCall != nil {
430
+ // id := "call_" + uuid.New().String()
431
+ // args, _ := json.Marshal(part.FunctionCall.Args)
432
+ // toolCalls = append(toolCalls, message.ToolCall{
433
+ // ID: id,
434
+ // Name: part.FunctionCall.Name,
435
+ // Input: string(args),
436
+ // Type: "function",
437
+ // })
438
+ // }
439
+ // }
440
+ // }
441
+ //
442
+ // return toolCalls
443
+ // }
438
444
439
445
func (g * geminiClient ) usage (resp * genai.GenerateContentResponse ) TokenUsage {
440
446
if resp == nil || resp .UsageMetadata == nil {
0 commit comments