UNPKG

ai-functions

Version:

Core AI primitives for building intelligent applications

56 lines 1.84 kB
/** * AI Schemas - Schema-based AI function generation * * This module provides functionality for creating AI functions from * simple schema definitions using the SimpleSchema format. */ import type { SimpleSchema } from './schema.js'; import type { LanguageModel } from 'ai'; /** * Options for AI schema functions (subset of generateObject options) */ export interface AISchemaOptions { /** Model to use (string alias or LanguageModel) */ model?: string | LanguageModel; /** System prompt */ system?: string; /** Generation mode */ mode?: 'auto' | 'json' | 'tool'; /** Temperature (0-2) */ temperature?: number; /** Top P sampling */ topP?: number; /** Top K sampling */ topK?: number; /** Presence penalty */ presencePenalty?: number; /** Frequency penalty */ frequencyPenalty?: number; /** Max tokens to generate */ maxTokens?: number; /** Max retries on failure */ maxRetries?: number; /** Abort signal */ abortSignal?: AbortSignal; /** Custom headers */ headers?: Record<string, string>; } /** * Schema-based functions type */ export type SchemaFunctions<T extends Record<string, SimpleSchema>> = { [K in keyof T]: (prompt?: string, options?: AISchemaOptions) => Promise<InferSimpleSchemaResult<T[K]>>; }; /** * Infer result type from simple schema */ export type InferSimpleSchemaResult<T> = T extends string ? string : T extends [string] ? string[] : T extends { [K: string]: SimpleSchema; } ? { [K in keyof T]: InferSimpleSchemaResult<T[K]>; } : unknown; /** * Create schema-based functions from a map of schemas */ export declare function createSchemaFunctions<T extends Record<string, SimpleSchema>>(schemas: T, defaultOptions?: AISchemaOptions): SchemaFunctions<T>; //# sourceMappingURL=ai-schemas.d.ts.map