mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Fixed: #424
**feat(antigravity): add support for maxOutputTokens and refine Claude model handling**
This commit is contained in:
@@ -724,7 +724,7 @@ func geminiToAntigravity(modelName string, payload []byte, projectID string) []b
|
|||||||
|
|
||||||
template, _ = sjson.Delete(template, "request.safetySettings")
|
template, _ = sjson.Delete(template, "request.safetySettings")
|
||||||
template, _ = sjson.Set(template, "request.toolConfig.functionCallingConfig.mode", "VALIDATED")
|
template, _ = sjson.Set(template, "request.toolConfig.functionCallingConfig.mode", "VALIDATED")
|
||||||
template, _ = sjson.Delete(template, "request.generationConfig.maxOutputTokens")
|
|
||||||
if !strings.HasPrefix(modelName, "gemini-3-") {
|
if !strings.HasPrefix(modelName, "gemini-3-") {
|
||||||
if thinkingLevel := gjson.Get(template, "request.generationConfig.thinkingConfig.thinkingLevel"); thinkingLevel.Exists() {
|
if thinkingLevel := gjson.Get(template, "request.generationConfig.thinkingConfig.thinkingLevel"); thinkingLevel.Exists() {
|
||||||
template, _ = sjson.Delete(template, "request.generationConfig.thinkingConfig.thinkingLevel")
|
template, _ = sjson.Delete(template, "request.generationConfig.thinkingConfig.thinkingLevel")
|
||||||
@@ -732,7 +732,7 @@ func geminiToAntigravity(modelName string, payload []byte, projectID string) []b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(modelName, "claude-sonnet-") {
|
if strings.Contains(modelName, "claude") {
|
||||||
gjson.Get(template, "request.tools").ForEach(func(key, tool gjson.Result) bool {
|
gjson.Get(template, "request.tools").ForEach(func(key, tool gjson.Result) bool {
|
||||||
tool.Get("functionDeclarations").ForEach(func(funKey, funcDecl gjson.Result) bool {
|
tool.Get("functionDeclarations").ForEach(func(funKey, funcDecl gjson.Result) bool {
|
||||||
if funcDecl.Get("parametersJsonSchema").Exists() {
|
if funcDecl.Get("parametersJsonSchema").Exists() {
|
||||||
@@ -744,6 +744,8 @@ func geminiToAntigravity(modelName string, payload []byte, projectID string) []b
|
|||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
template, _ = sjson.Delete(template, "request.generationConfig.maxOutputTokens")
|
||||||
}
|
}
|
||||||
|
|
||||||
return []byte(template)
|
return []byte(template)
|
||||||
|
|||||||
@@ -181,6 +181,9 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
if v := gjson.GetBytes(rawJSON, "top_k"); v.Exists() && v.Type == gjson.Number {
|
if v := gjson.GetBytes(rawJSON, "top_k"); v.Exists() && v.Type == gjson.Number {
|
||||||
out, _ = sjson.Set(out, "request.generationConfig.topK", v.Num)
|
out, _ = sjson.Set(out, "request.generationConfig.topK", v.Num)
|
||||||
}
|
}
|
||||||
|
if v := gjson.GetBytes(rawJSON, "max_tokens"); v.Exists() && v.Type == gjson.Number {
|
||||||
|
out, _ = sjson.Set(out, "request.generationConfig.maxOutputTokens", v.Num)
|
||||||
|
}
|
||||||
|
|
||||||
outBytes := []byte(out)
|
outBytes := []byte(out)
|
||||||
outBytes = common.AttachDefaultSafetySettings(outBytes, "request.safetySettings")
|
outBytes = common.AttachDefaultSafetySettings(outBytes, "request.safetySettings")
|
||||||
|
|||||||
Reference in New Issue
Block a user