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) {
|
for (const t of body.tools) {
|
||||||
// Check if already in Anthropic/Claude format (no type field, direct name/description/input_schema)
|
// Check if already in Anthropic/Claude format (no type field, direct name/description/input_schema)
|
||||||
if (t.name && t.input_schema) {
|
if (t.name && t.input_schema) {
|
||||||
|
const cleanedSchema = cleanJSONSchemaForAntigravity(structuredClone(t.input_schema || { type: "object", properties: {} }));
|
||||||
functionDeclarations.push({
|
functionDeclarations.push({
|
||||||
name: t.name,
|
name: t.name,
|
||||||
description: t.description || "",
|
description: t.description || "",
|
||||||
parameters: t.input_schema || { type: "object", properties: {} }
|
parameters: cleanedSchema
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// OpenAI format
|
// OpenAI format
|
||||||
else if (t.type === "function" && t.function) {
|
else if (t.type === "function" && t.function) {
|
||||||
const fn = t.function;
|
const fn = t.function;
|
||||||
|
const cleanedSchema = cleanJSONSchemaForAntigravity(structuredClone(fn.parameters || { type: "object", properties: {} }));
|
||||||
functionDeclarations.push({
|
functionDeclarations.push({
|
||||||
name: fn.name,
|
name: fn.name,
|
||||||
description: fn.description || "",
|
description: fn.description || "",
|
||||||
parameters: fn.parameters || { type: "object", properties: {} }
|
parameters: cleanedSchema
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue