mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Fixed: #655
refactor(antigravity): clean up tool key filtering and improve signature caching logic
This commit is contained in:
@@ -147,7 +147,6 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
currentMessageThinkingSignature = signature
|
currentMessageThinkingSignature = signature
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Skip trailing unsigned thinking blocks on last assistant message
|
// Skip trailing unsigned thinking blocks on last assistant message
|
||||||
isUnsigned := !cache.HasValidSignature(signature)
|
isUnsigned := !cache.HasValidSignature(signature)
|
||||||
|
|
||||||
@@ -321,6 +320,7 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
// tools
|
// tools
|
||||||
toolsJSON := ""
|
toolsJSON := ""
|
||||||
toolDeclCount := 0
|
toolDeclCount := 0
|
||||||
|
allowedToolKeys := []string{"name", "description", "behavior", "parameters", "parametersJsonSchema", "response", "responseJsonSchema"}
|
||||||
toolsResult := gjson.GetBytes(rawJSON, "tools")
|
toolsResult := gjson.GetBytes(rawJSON, "tools")
|
||||||
if toolsResult.IsArray() {
|
if toolsResult.IsArray() {
|
||||||
toolsJSON = `[{"functionDeclarations":[]}]`
|
toolsJSON = `[{"functionDeclarations":[]}]`
|
||||||
@@ -333,10 +333,12 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
inputSchema := util.CleanJSONSchemaForAntigravity(inputSchemaResult.Raw)
|
inputSchema := util.CleanJSONSchemaForAntigravity(inputSchemaResult.Raw)
|
||||||
tool, _ := sjson.Delete(toolResult.Raw, "input_schema")
|
tool, _ := sjson.Delete(toolResult.Raw, "input_schema")
|
||||||
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
tool, _ = sjson.SetRaw(tool, "parametersJsonSchema", inputSchema)
|
||||||
tool, _ = sjson.Delete(tool, "strict")
|
for toolKey := range gjson.Parse(tool).Map() {
|
||||||
tool, _ = sjson.Delete(tool, "input_examples")
|
if util.InArray(allowedToolKeys, toolKey) {
|
||||||
tool, _ = sjson.Delete(tool, "type")
|
continue
|
||||||
tool, _ = sjson.Delete(tool, "cache_control")
|
}
|
||||||
|
tool, _ = sjson.Delete(tool, toolKey)
|
||||||
|
}
|
||||||
toolsJSON, _ = sjson.SetRaw(toolsJSON, "0.functionDeclarations.-1", tool)
|
toolsJSON, _ = sjson.SetRaw(toolsJSON, "0.functionDeclarations.-1", tool)
|
||||||
toolDeclCount++
|
toolDeclCount++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user