**feat(antigravity): add support for maxOutputTokens and refine Claude model handling**
This commit is contained in:
Luis Pater
2025-12-07 01:55:57 +08:00
parent 7a628426dc
commit fd29ab418a
2 changed files with 7 additions and 2 deletions

View File

@@ -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)

View File

@@ -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")