Compare commits

...

2 Commits

Author SHA1 Message Date
RandyZhang
590a5fa2d5
Merge 703859214b into 8df4a2670b 2025-05-15 13:56:03 +00:00
RandyZhang
703859214b 修改thinking config的设置,同时兼容gemini-2.5和gemini-2.0 2025-05-15 21:55:49 +08:00
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) {