refactor: clean JSON schemas for Gemini function declarations (#371)
Apply cleanJSONSchemaForAntigravity to both Anthropic and OpenAI format tool schemas before converting to Gemini function declarations
This commit is contained in:
parent
3f852775c6
commit
1154244f1d
1 changed files with 4 additions and 2 deletions
|
|
@ -178,19 +178,21 @@ function openaiToGeminiBase(model, body, stream) {
|
|||
for (const t of body.tools) {
|
||||
// Check if already in Anthropic/Claude format (no type field, direct name/description/input_schema)
|
||||
if (t.name && t.input_schema) {
|
||||
const cleanedSchema = cleanJSONSchemaForAntigravity(structuredClone(t.input_schema || { type: "object", properties: {} }));
|
||||
functionDeclarations.push({
|
||||
name: t.name,
|
||||
description: t.description || "",
|
||||
parameters: t.input_schema || { type: "object", properties: {} }
|
||||
parameters: cleanedSchema
|
||||
});
|
||||
}
|
||||
// OpenAI format
|
||||
else if (t.type === "function" && t.function) {
|
||||
const fn = t.function;
|
||||
const cleanedSchema = cleanJSONSchemaForAntigravity(structuredClone(fn.parameters || { type: "object", properties: {} }));
|
||||
functionDeclarations.push({
|
||||
name: fn.name,
|
||||
description: fn.description || "",
|
||||
parameters: fn.parameters || { type: "object", properties: {} }
|
||||
parameters: cleanedSchema
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue