import OpenAI from 'openai'; import { CopilotKitServiceAdapter, CopilotKitResponse } from '../types/service-adapter.js'; /** * CopilotRuntime Adapter for OpenAI. * * * ```jsx CopilotRuntime Example * const copilotKit = new CopilotRuntime(); * return copilotKit.response(req, new OpenAIAdapter()); * ``` * * * You can easily set the model to use by passing it to the constructor. * ```jsx * const copilotKit = new CopilotRuntime(); * return copilotKit.response( * req, * new OpenAIAdapter({ model: "gpt-4o" }), * ); * ``` * * To use your custom OpenAI instance, pass the `openai` property. * ```jsx * const openai = new OpenAI({ * organization: "your-organization-id", * apiKey: "your-api-key" * }); * * const copilotKit = new CopilotRuntime(); * return copilotKit.response( * req, * new OpenAIAdapter({ openai }), * ); * ``` * */ interface OpenAIAdapterParams { /** * An optional OpenAI instance to use. */ openai?: OpenAI; /** * The model to use. */ model?: string; } declare class OpenAIAdapter implements CopilotKitServiceAdapter { private model; private _openai; get openai(): OpenAI; constructor(params?: OpenAIAdapterParams); getResponse(forwardedProps: any): Promise; } export { OpenAIAdapter, OpenAIAdapterParams };