修改thinking config的设置,同时兼容gemini-2.5和gemini-2.0

This commit is contained in:
RandyZhang 2025-05-15 21:55:36 +08:00
parent cb4ee5e86a
commit 703859214b
2 changed files with 12 additions and 2 deletions

View File

@ -79,5 +79,5 @@ type ChatGenerationConfig struct {
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
CandidateCount int `json:"candidateCount,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
ThinkingConfig *ThinkingConfig `json:"thinkingConfig,omitempty"`
ThinkingConfig *ThinkingConfig `json:"thinkingConfig"`
}

View File

@ -57,7 +57,17 @@ func (a *Adaptor) parseGeminiChatGenerationThinking(model string) (string, *gemi
}
}
}
return modelName, thinkingConfig
if strings.HasPrefix(modelName, "gemini-2.5") {
// 目前2.5的模型支持传递thinking config且默认开启了thinking不希望进入thinking模式需要显式传递thinkingConfig来关闭
return modelName, thinkingConfig
} else {
// 其他模型暂时不支持
if thinkingConfig != nil && (thinkingConfig.IncludeThoughts || thinkingConfig.ThinkingBudget > 0) {
// 为了后续一旦有其他模型支持了thinking这里指定可以指定参数开启
return modelName, thinkingConfig
}
return modelName, nil
}
}
func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (any, error) {