/**
 * src/models/provider.ts
 * واجهة مزود النماذج الموحدة — Abstract model provider + OpenAI-compatible caller
 */
export interface ChatMessage {
    role: 'system' | 'user' | 'assistant' | 'tool';
    content: string;
    name?: string;
    tool_call_id?: string;
    tool_calls?: ToolCall[];
}
export interface ToolCall {
    id: string;
    type: 'function';
    function: {
        name: string;
        arguments: string;
    };
}
export interface ToolDefinition {
    type: 'function';
    function: {
        name: string;
        description: string;
        parameters: Record<string, unknown>;
    };
}
export interface ChatOptions {
    temperature?: number;
    maxTokens?: number;
    topP?: number;
    stop?: string[];
    tools?: ToolDefinition[];
    toolChoice?: 'auto' | 'none' | {
        type: 'function';
        function: {
            name: string;
        };
    };
    responseFormat?: {
        type: 'json_object' | 'text';
    };
    stream?: boolean;
    /**
     * Per-call timeout in milliseconds. Default 30s — tight enough that a stuck
     * NIM doesn't hang an entire WhatsApp turn (WhatsApp typing indicator dies
     * at 25s anyway). Reasoning models can pass 60_000+ explicitly.
     */
    timeoutMs?: number;
}
export interface ChatResponse {
    content: string;
    tokensInput: number;
    tokensOutput: number;
    model: string;
    latencyMs: number;
    toolCalls?: ToolCall[];
    finishReason?: string;
}
/** واجهة مزود النموذج — كل مزود يطبق هذه الواجهة */
export interface ModelProvider {
    readonly name: string;
    readonly model: string;
    chat(messages: ChatMessage[], options?: ChatOptions): Promise<ChatResponse>;
}
/**
 * دالة مشتركة لاستدعاء أي API متوافق مع OpenAI
 * Used by Together AI (Qwen), DeepSeek, and any OpenAI-compatible endpoint
 */
export declare function callOpenAICompatible(baseUrl: string, apiKey: string, model: string, messages: ChatMessage[], options?: ChatOptions): Promise<ChatResponse>;
export declare class ModelError extends Error {
    readonly statusCode: number;
    readonly model: string;
    constructor(message: string, statusCode: number, model: string);
    /** هل الخطأ قابل لإعادة المحاولة؟ */
    get isRetryable(): boolean;
}
//# sourceMappingURL=provider.d.ts.map