/** * Next.js Integration - AI SDK Wrapper * * Provides route handlers and React hooks for Next.js applications. */ export interface RouteHandlerConfig { /** Agent or handler function */ handler: (input: any) => Promise; /** Enable streaming (default: true) */ streaming?: boolean; /** Maximum duration in seconds */ maxDuration?: number; /** CORS configuration */ cors?: boolean | { origin?: string | string[]; methods?: string[]; }; } /** * Create a Next.js App Router route handler. * * @example app/api/chat/route.ts * ```typescript * import { createRouteHandler } from 'praisonai/ai'; * import { streamText } from 'praisonai/ai'; * * export const POST = createRouteHandler({ * handler: async (input) => { * return await streamText({ * model: 'gpt-4o', * messages: input.messages * }); * } * }); * ``` * * @example With Agent * ```typescript * import { createRouteHandler } from 'praisonai/ai'; * import { Agent } from 'praisonai'; * * const agent = new Agent({ instructions: 'You are helpful' }); * * export const POST = createRouteHandler({ * handler: async (input) => { * return await agent.chat(input.message); * } * }); * ``` */ export declare function createRouteHandler(config: RouteHandlerConfig): (request: Request) => Promise; /** * Create a Next.js Pages Router API handler. * * @example pages/api/chat.ts * ```typescript * import { createPagesHandler } from 'praisonai/ai'; * import { streamText } from 'praisonai/ai'; * * export default createPagesHandler({ * handler: async (input) => { * return await streamText({ * model: 'gpt-4o', * messages: input.messages * }); * } * }); * ``` */ export declare function createPagesHandler(config: RouteHandlerConfig): (req: any, res: any) => Promise; /** * Configuration for useChat hook wrapper. */ export interface UseChatConfig { /** API endpoint */ api?: string; /** Initial messages */ initialMessages?: Array<{ role: string; content: string; }>; /** On error callback */ onError?: (error: Error) => void; /** On finish callback */ onFinish?: (message: any) => void; /** Custom headers */ headers?: Record; /** Custom body */ body?: Record; } /** * Note: For React hooks (useChat, useCompletion, useObject), * use the AI SDK React package directly: * * ```typescript * import { useChat } from 'ai/react'; * * function ChatComponent() { * const { messages, input, handleInputChange, handleSubmit } = useChat({ * api: '/api/chat' * }); * * return ( *
* {messages.map(m =>
{m.content}
)} * *
* ); * } * ``` * * The praisonai package focuses on server-side functionality. * For client-side React hooks, install and use 'ai/react' directly. */ /** * Export runtime configuration for Next.js edge runtime. */ export declare const runtime = "edge"; /** * Export max duration configuration. */ export declare const maxDuration = 30;