Fixed gemini system prompt handling

This commit is contained in:
Matt Low 2024-06-01 19:47:08 +00:00
parent 60a474d516
commit 8467a6d759
2 changed files with 15 additions and 6 deletions

View File

@ -158,8 +158,7 @@ func createGenerateContentRequest(
}
request := &GenerateContentRequest{
Contents: requestContents,
SystemInstructions: system,
Contents: requestContents,
GenerationConfig: &GenerationConfig{
MaxOutputTokens: &params.MaxTokens,
Temperature: &params.Temperature,
@ -167,6 +166,16 @@ func createGenerateContentRequest(
},
}
if system != "" {
request.SystemInstruction = Content{
Parts: []ContentPart{
{
Text: system,
},
},
}
}
if len(params.ToolBag) > 0 {
request.Tools = convertTools(params.ToolBag)
}

View File

@ -34,10 +34,10 @@ type GenerationConfig struct {
}
type GenerateContentRequest struct {
Contents []Content `json:"contents"`
Tools []Tool `json:"tools,omitempty"`
SystemInstructions string `json:"systemInstructions,omitempty"`
GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"`
Contents []Content `json:"contents"`
Tools []Tool `json:"tools,omitempty"`
SystemInstruction Content `json:"systemInstruction,omitempty"`
GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"`
}
type Candidate struct {