mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
refactor: reuse placeholder reason description
Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
|||||||
|
|
||||||
var gjsonPathKeyReplacer = strings.NewReplacer(".", "\\.", "*", "\\*", "?", "\\?")
|
var gjsonPathKeyReplacer = strings.NewReplacer(".", "\\.", "*", "\\*", "?", "\\?")
|
||||||
|
|
||||||
|
const placeholderReasonDescription = "Brief explanation of why you are calling this tool"
|
||||||
|
|
||||||
// CleanJSONSchemaForAntigravity transforms a JSON schema to be compatible with Antigravity API.
|
// CleanJSONSchemaForAntigravity transforms a JSON schema to be compatible with Antigravity API.
|
||||||
// It handles unsupported keywords, type flattening, and schema simplification while preserving
|
// It handles unsupported keywords, type flattening, and schema simplification while preserving
|
||||||
// semantic information as description hints.
|
// semantic information as description hints.
|
||||||
@@ -72,7 +74,7 @@ func removePlaceholderFields(jsonStr string) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
desc := gjson.Get(jsonStr, p+".description").String()
|
desc := gjson.Get(jsonStr, p+".description").String()
|
||||||
if desc != "Brief explanation of why you are calling this tool" {
|
if desc != placeholderReasonDescription {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
jsonStr, _ = sjson.Delete(jsonStr, p)
|
jsonStr, _ = sjson.Delete(jsonStr, p)
|
||||||
@@ -502,7 +504,7 @@ func addEmptySchemaPlaceholder(jsonStr string) string {
|
|||||||
// Add placeholder "reason" property
|
// Add placeholder "reason" property
|
||||||
reasonPath := joinPath(propsPath, "reason")
|
reasonPath := joinPath(propsPath, "reason")
|
||||||
jsonStr, _ = sjson.Set(jsonStr, reasonPath+".type", "string")
|
jsonStr, _ = sjson.Set(jsonStr, reasonPath+".type", "string")
|
||||||
jsonStr, _ = sjson.Set(jsonStr, reasonPath+".description", "Brief explanation of why you are calling this tool")
|
jsonStr, _ = sjson.Set(jsonStr, reasonPath+".description", placeholderReasonDescription)
|
||||||
|
|
||||||
// Add to required array
|
// Add to required array
|
||||||
jsonStr, _ = sjson.Set(jsonStr, reqPath, []string{"reason"})
|
jsonStr, _ = sjson.Set(jsonStr, reqPath, []string{"reason"})
|
||||||
|
|||||||
Reference in New Issue
Block a user