feat: add function and tools support for Gemini (#1358)

* Update model.go

* Support Gemini tool_calls.

* Fix gemini tool calls (also keep support functions).

* Fixed the problem of arguments not being stringified.

Fix panic: candidate.Content.Parts out of range
This commit is contained in:
Wei Tingjiang
2024-04-24 21:26:45 +08:00
committed by GitHub
parent 3d149fedf4
commit 779b747e9e
2 changed files with 57 additions and 10 deletions

View File

@@ -12,9 +12,15 @@ type InlineData struct {
Data string `json:"data"`
}
type FunctionCall struct {
FunctionName string `json:"name"`
Arguments any `json:"args"`
}
type Part struct {
Text string `json:"text,omitempty"`
InlineData *InlineData `json:"inlineData,omitempty"`
Text string `json:"text,omitempty"`
InlineData *InlineData `json:"inlineData,omitempty"`
FunctionCall *FunctionCall `json:"functionCall,omitempty"`
}
type ChatContent struct {
@@ -28,7 +34,7 @@ type ChatSafetySettings struct {
}
type ChatTools struct {
FunctionDeclarations any `json:"functionDeclarations,omitempty"`
FunctionDeclarations any `json:"function_declarations,omitempty"`
}
type ChatGenerationConfig struct {