/** * Message in a conversation */ export interface IMessage { role: 'system' | 'user' | 'assistant'; content: string; name?: string; } /** * Configuration for AI request */ export interface IAskConfig { /** AI provider (e.g., 'openai', 'anthropic', 'groq') */ provider?: string; /** Model name (e.g., 'gpt-4', 'claude-3-5-sonnet-latest') */ model?: string; /** System prompt to set context */ systemPrompt?: string; /** Sampling temperature (0-2, default: 0.7) */ temperature?: number; /** Maximum tokens in response */ maxTokens?: number; /** Top P sampling parameter */ topP?: number; /** Frequency penalty (-2 to 2) */ frequencyPenalty?: number; /** Presence penalty (-2 to 2) */ presencePenalty?: number; /** Enable streaming responses */ stream?: boolean; /** User identifier for tracking */ user?: string; } /** * Request payload for completion endpoint */ export interface ICompletionRequest { messages: IMessage[]; systemPrompt?: string; config: IAskConfig; } /** * Non-streaming response */ export interface ICompletionResponse { content: string; provider?: string; model?: string; usage?: { promptTokens?: number; completionTokens?: number; totalTokens?: number; }; } /** * Error response from API */ export interface IErrorResponse { error: string; timestamp?: string; } /** * Configuration options for AskClient */ export interface IAskClientOptions { /** Base URL of the Ask API (e.g., 'https://your-worker.workers.dev/v1') */ baseUrl: string; /** Ask API key for authentication (if using Ask's key management) */ askApiKey?: string; /** Default provider to use if not specified in requests */ defaultProvider?: string; /** Default model to use if not specified in requests */ defaultModel?: string; /** Provider-specific API keys (alternative to askApiKey) */ providerKeys?: { openai?: string; anthropic?: string; groq?: string; google?: string; mistral?: string; openrouter?: string; cohere?: string; xai?: string; deepseek?: string; ai21?: string; cloudflare?: string; }; /** Cloudflare account ID (required if using Cloudflare provider) */ cloudflareAccountId?: string; /** Custom headers to include in all requests */ headers?: Record; /** Enable debug logging */ debug?: boolean; } /** * Stream chunk from SSE response */ export interface IStreamChunk { content: string; done: boolean; }