|
1 | 1 | import type { ModelMessage, ToolResultPart } from "ai" |
2 | 2 | import { mergeDeep, unique } from "remeda" |
3 | 3 | import type { JSONSchema7 } from "@ai-sdk/provider" |
4 | | -import type { JSONSchema } from "zod/v4/core" |
5 | 4 | import type * as Provider from "./provider" |
6 | 5 | import type * as ModelsDev from "./models" |
7 | 6 | import { iife } from "@/util/iife" |
@@ -1281,7 +1280,7 @@ export function maxOutputTokens(model: Provider.Model): number { |
1281 | 1280 | return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX |
1282 | 1281 | } |
1283 | 1282 |
|
1284 | | -export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JSONSchema7): JSONSchema7 { |
| 1283 | +export function schema(model: Provider.Model, schema: JSONSchema7): JSONSchema7 { |
1285 | 1284 | /* |
1286 | 1285 | if (["openai", "azure"].includes(providerID)) { |
1287 | 1286 | if (schema.type === "object" && schema.properties) { |
@@ -1312,7 +1311,10 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS |
1312 | 1311 | return result |
1313 | 1312 | } |
1314 | 1313 |
|
1315 | | - schema = sanitizeMoonshot(schema) as JSONSchema.BaseSchema | JSONSchema7 |
| 1314 | + const sanitized = sanitizeMoonshot(schema) |
| 1315 | + if (typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized)) { |
| 1316 | + schema = sanitized |
| 1317 | + } |
1316 | 1318 | } |
1317 | 1319 |
|
1318 | 1320 | // Convert integer enums to string enums for Google/Gemini |
@@ -1394,7 +1396,7 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS |
1394 | 1396 | schema = sanitizeGemini(schema) |
1395 | 1397 | } |
1396 | 1398 |
|
1397 | | - return schema as JSONSchema7 |
| 1399 | + return schema |
1398 | 1400 | } |
1399 | 1401 |
|
1400 | 1402 | export * as ProviderTransform from "./transform" |
0 commit comments