Clamp Claude maxOutputTokens to 64000
This commit is contained in:
@@ -490,9 +490,23 @@ func parseToolResultContent(content json.RawMessage, isError bool) string {
|
||||
}
|
||||
|
||||
// buildGenerationConfig 构建 generationConfig
|
||||
const (
|
||||
defaultMaxOutputTokens = 64000
|
||||
maxOutputTokensUpperBound = 65000
|
||||
maxOutputTokensClaude = 64000
|
||||
)
|
||||
|
||||
func maxOutputTokensLimit(model string) int {
|
||||
if strings.HasPrefix(model, "claude-") {
|
||||
return maxOutputTokensClaude
|
||||
}
|
||||
return maxOutputTokensUpperBound
|
||||
}
|
||||
|
||||
func buildGenerationConfig(req *ClaudeRequest) *GeminiGenerationConfig {
|
||||
maxLimit := maxOutputTokensLimit(req.Model)
|
||||
config := &GeminiGenerationConfig{
|
||||
MaxOutputTokens: 64000, // 默认最大输出
|
||||
MaxOutputTokens: defaultMaxOutputTokens, // 默认最大输出
|
||||
StopSequences: DefaultStopSequences,
|
||||
}
|
||||
|
||||
@@ -516,6 +530,10 @@ func buildGenerationConfig(req *ClaudeRequest) *GeminiGenerationConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if config.MaxOutputTokens > maxLimit {
|
||||
config.MaxOutputTokens = maxLimit
|
||||
}
|
||||
|
||||
// 其他参数
|
||||
if req.Temperature != nil {
|
||||
config.Temperature = req.Temperature
|
||||
|
||||
Reference in New Issue
Block a user