import OpenAI from 'openai';
import type { ApiModerationProvider, ApiProvider, CallApiContextParams, CallApiOptionsParams, ProviderEmbeddingResponse, ProviderModerationResponse, ProviderResponse, TokenUsage } from '../types';
import type { EnvOverrides } from '../types/env';
import type { OpenAiFunction, OpenAiTool } from './openaiUtil';
export declare const OPENAI_CHAT_MODELS: {
    id: string;
    cost: {
        input: number;
        output: number;
    };
}[];
export declare const OPENAI_COMPLETION_MODELS: ({
    id: string;
    cost: {
        input: number;
        output: number;
    };
} | {
    id: string;
    cost?: undefined;
})[];
interface OpenAiSharedOptions {
    apiKey?: string;
    apiKeyEnvar?: string;
    apiHost?: string;
    apiBaseUrl?: string;
    organization?: string;
    cost?: number;
    headers?: {
        [key: string]: string;
    };
}
export type OpenAiCompletionOptions = OpenAiSharedOptions & {
    temperature?: number;
    max_completion_tokens?: number;
    max_tokens?: number;
    top_p?: number;
    frequency_penalty?: number;
    presence_penalty?: number;
    best_of?: number;
    functions?: OpenAiFunction[];
    function_call?: 'none' | 'auto' | {
        name: string;
    };
    tools?: OpenAiTool[];
    tool_choice?: 'none' | 'auto' | 'required' | {
        type: 'function';
        function?: {
            name: string;
        };
    };
    response_format?: {
        type: 'json_object';
    } | {
        type: 'json_schema';
        json_schema: {
            name: string;
            strict: boolean;
            schema: {
                type: 'object';
                properties: Record<string, any>;
                required?: string[];
                additionalProperties: false;
            };
        };
    };
    stop?: string[];
    seed?: number;
    passthrough?: object;
    /**
     * If set, automatically call these functions when the assistant activates
     * these function tools.
     */
    functionToolCallbacks?: Record<OpenAI.FunctionDefinition['name'], (arg: string) => Promise<string>>;
};
export declare function failApiCall(err: any): {
    error: string;
};
export declare function getTokenUsage(data: any, cached: boolean): Partial<TokenUsage>;
export declare class OpenAiGenericProvider implements ApiProvider {
    modelName: string;
    config: OpenAiSharedOptions;
    env?: EnvOverrides;
    constructor(modelName: string, options?: {
        config?: OpenAiSharedOptions;
        id?: string;
        env?: EnvOverrides;
    });
    id(): string;
    toString(): string;
    getOrganization(): string | undefined;
    getApiUrlDefault(): string;
    getApiUrl(): string;
    getApiKey(): string | undefined;
    callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
}
export declare class OpenAiEmbeddingProvider extends OpenAiGenericProvider {
    callEmbeddingApi(text: string): Promise<ProviderEmbeddingResponse>;
}
export declare function formatOpenAiError(data: {
    error: {
        message: string;
        type?: string;
        code?: string;
    };
}): string;
export declare function calculateOpenAICost(modelName: string, config: OpenAiSharedOptions, promptTokens?: number, completionTokens?: number): number | undefined;
export declare class OpenAiCompletionProvider extends OpenAiGenericProvider {
    static OPENAI_COMPLETION_MODELS: ({
        id: string;
        cost: {
            input: number;
            output: number;
        };
    } | {
        id: string;
        cost?: undefined;
    })[];
    static OPENAI_COMPLETION_MODEL_NAMES: string[];
    config: OpenAiCompletionOptions;
    constructor(modelName: string, options?: {
        config?: OpenAiCompletionOptions;
        id?: string;
        env?: EnvOverrides;
    });
    callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
}
export declare class OpenAiChatCompletionProvider extends OpenAiGenericProvider {
    static OPENAI_CHAT_MODELS: {
        id: string;
        cost: {
            input: number;
            output: number;
        };
    }[];
    static OPENAI_CHAT_MODEL_NAMES: string[];
    config: OpenAiCompletionOptions;
    constructor(modelName: string, options?: {
        config?: OpenAiCompletionOptions;
        id?: string;
        env?: EnvOverrides;
    });
    getOpenAiBody(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): {
        body: any;
        config: any;
    };
    callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
}
type OpenAiAssistantOptions = OpenAiSharedOptions & {
    modelName?: string;
    instructions?: string;
    tools?: OpenAI.Beta.Threads.ThreadCreateAndRunParams['tools'];
    /**
     * If set, automatically call these functions when the assistant activates
     * these function tools.
     */
    functionToolCallbacks?: Record<OpenAI.FunctionDefinition['name'], (arg: string) => Promise<string>>;
    metadata?: object[];
    temperature?: number;
    toolChoice?: 'none' | 'auto' | 'required' | {
        type: 'function';
        function?: {
            name: string;
        };
    } | {
        type: 'file_search';
    };
    attachments?: OpenAI.Beta.Threads.Message.Attachment[];
    tool_resources?: OpenAI.Beta.Threads.ThreadCreateAndRunParams['tool_resources'];
};
export declare class OpenAiAssistantProvider extends OpenAiGenericProvider {
    assistantId: string;
    assistantConfig: OpenAiAssistantOptions;
    constructor(assistantId: string, options?: {
        config?: OpenAiAssistantOptions;
        id?: string;
        env?: EnvOverrides;
    });
    callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
}
type OpenAiImageOptions = OpenAiSharedOptions & {
    size?: string;
};
export declare class OpenAiImageProvider extends OpenAiGenericProvider {
    config: OpenAiImageOptions;
    constructor(modelName: string, options?: {
        config?: OpenAiImageOptions;
        id?: string;
        env?: EnvOverrides;
    });
    callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
}
export declare class OpenAiModerationProvider extends OpenAiGenericProvider implements ApiModerationProvider {
    callModerationApi(userPrompt: string, // userPrompt is not supported by OpenAI moderation API
    assistantResponse: string): Promise<ProviderModerationResponse>;
}
export declare const DefaultEmbeddingProvider: OpenAiEmbeddingProvider;
export declare const DefaultGradingProvider: OpenAiChatCompletionProvider;
export declare const DefaultGradingJsonProvider: OpenAiChatCompletionProvider;
export declare const DefaultSuggestionsProvider: OpenAiChatCompletionProvider;
export declare const DefaultModerationProvider: OpenAiModerationProvider;
export {};
//# sourceMappingURL=openai.d.ts.map