UNPKG

ai-sdk-ollama

Version:

Vercel AI SDK Provider for Ollama using official ollama-js library

38 lines 1.44 kB
/** * Reconciling a model's output with the schema it was asked for. * * Two jobs: invent a value that satisfies a schema when generation fails * outright, and coerce near-misses (a number sent as a string, a scalar sent * where an array was asked for) into the shape the schema wants. */ import type { JSONSchema7 } from '@ai-sdk/provider'; interface ZodSchema { parse(data: unknown): unknown; safeParse(data: unknown): { success: boolean; data?: unknown; error?: unknown; }; } export declare function isZodSchema(schema: unknown): schema is ZodSchema; /** * Generate fallback values for a JSON schema or Zod schema */ export declare function generateFallbackValues(schema: JSONSchema7 | unknown): Record<string, unknown>; /** * Attempt to fix type mismatches in generated objects */ export declare function fixTypeMismatches(object: Record<string, unknown>, schema: JSONSchema7 | unknown): Record<string, unknown>; /** * Attempt to coerce the parsed object to match the expected schema type. * This handles cases where Ollama returns: * - An array when an object is expected * - A raw array when {elements: [...]} wrapper is expected * - An object when an array is expected */ export declare function coerceToSchemaType(parsedObject: unknown, schema: JSONSchema7 | unknown): { coerced: unknown; wasCoerced: boolean; }; export {}; //# sourceMappingURL=json-schema-coercion.d.ts.map