import type { AIUsageInfo } from '../../types';
import type { StreamingCallback } from '../../types';
export declare class AIResponseParseError extends Error {
    usage?: AIUsageInfo;
    /**
     * Adapter-extracted content used by Midscene for parsing. This is not the
     * full provider response or choices[0].message.
     */
    rawResponse: string;
    rawChoiceMessage?: unknown;
    constructor(message: string, rawResponse: string, usage?: AIUsageInfo, rawChoiceMessage?: unknown);
}
import { type IModelConfig, type TModelFamily } from '@midscene/shared/env';
import OpenAI from 'openai';
import type { ChatCompletionMessageParam } from 'openai/resources/index';
import { type ModelRuntime } from '../models';
import type { AIArgs } from '../types';
import type { JsonParserSource } from './json';
export { extractJSONFromCodeBlock, normalJsonParser, safeParseJson, } from './json';
export type { JsonParser } from './json';
export declare function createChatClient({ modelConfig, }: {
    modelConfig: IModelConfig;
}): Promise<{
    completion: OpenAI.Chat.Completions;
    modelName: string;
    modelDescription: string;
    modelFamily: TModelFamily | undefined;
}>;
export declare function callAI(messages: ChatCompletionMessageParam[], modelRuntime: ModelRuntime, options?: {
    stream?: boolean;
    onChunk?: StreamingCallback;
    abortSignal?: AbortSignal;
    requiresOriginalImageDetail?: boolean;
}): Promise<{
    content: string;
    reasoning_content?: string;
    rawChoiceMessage?: unknown;
    usage?: AIUsageInfo;
    isStreamed: boolean;
}>;
export declare function callAIWithObjectResponse<T>(messages: ChatCompletionMessageParam[], model: IModelConfig | ModelRuntime, options?: {
    abortSignal?: AbortSignal;
    jsonParserSource?: JsonParserSource;
}): Promise<{
    content: T;
    contentString: string;
    usage?: AIUsageInfo;
    reasoning_content?: string;
    rawChoiceMessage?: unknown;
}>;
export declare function callAIWithStringResponse(msgs: AIArgs, modelRuntime: ModelRuntime, options?: {
    abortSignal?: AbortSignal;
}): Promise<{
    content: string;
    usage?: AIUsageInfo;
    rawChoiceMessage?: unknown;
}>;
