(schema: SchemaUnion)
| 58 | * Removes additionalProperties from a schema object (not supported by Gemini) |
| 59 | */ |
| 60 | export function cleanSchemaForGemini(schema: SchemaUnion): SchemaUnion { |
| 61 | if (schema === null || schema === undefined) return schema |
| 62 | if (typeof schema !== 'object') return schema |
| 63 | if (Array.isArray(schema)) { |
| 64 | return schema.map((item) => cleanSchemaForGemini(item)) |
| 65 | } |
| 66 | |
| 67 | const cleanedSchema: Record<string, unknown> = {} |
| 68 | const schemaObj = schema as Record<string, unknown> |
| 69 | |
| 70 | for (const key in schemaObj) { |
| 71 | if (key === 'additionalProperties') continue |
| 72 | cleanedSchema[key] = cleanSchemaForGemini(schemaObj[key] as SchemaUnion) |
| 73 | } |
| 74 | |
| 75 | return cleanedSchema |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Extracts text content from a Gemini response candidate. |
no outgoing calls
no test coverage detected