in gollm/gemini.go [247:287]
func (c *GoogleAIClient) StartChat(systemPrompt string, model string) Chat {
// Some values that are recommended by aistudio
temperature := float32(1.0)
topK := float32(40)
topP := float32(0.95)
maxOutputTokens := int32(8192)
chat := &GeminiChat{
model: model,
client: c.client,
genConfig: &genai.GenerateContentConfig{
SystemInstruction: &genai.Content{
Parts: []*genai.Part{
{Text: systemPrompt},
},
},
Temperature: &temperature,
TopK: &topK,
TopP: &topP,
MaxOutputTokens: maxOutputTokens,
ResponseMIMEType: "text/plain",
},
history: []*genai.Content{},
}
if chat.model == "gemma-3-27b-it" {
// Note: gemma-3-27b-it does not allow system prompt
// xref: https://discuss.ai.google.dev/t/gemma-3-missing-features-despite-announcement/71692
// TODO: remove this hack once gemma-3-27b-it supports system prompt
chat.genConfig.SystemInstruction = nil
chat.history = []*genai.Content{
{Role: "user", Parts: []*genai.Part{{Text: systemPrompt}}},
}
}
if c.responseSchema != nil {
chat.genConfig.ResponseSchema = c.responseSchema
chat.genConfig.ResponseMIMEType = "application/json"
}
return chat
}