import { PromptHelper } from '../../indices/dist/index.js';
import { LLM, MessageContent, MessageContentDetail } from '../../llms/dist/index.js';
import { PromptMixin, TextQAPrompt, RefinePrompt, ModuleRecord, TreeSummarizePrompt, BasePromptTemplate } from '../../prompts/dist/index.js';
import { NodeWithScore, EngineResponse, MetadataMode, BaseNode } from '../../schema/dist/index.js';
import { QueryType } from '../../query-engine/dist/index.js';
import { z } from 'zod';

type SynthesizeQuery = {
    query: QueryType;
    nodes: NodeWithScore[];
    additionalSourceNodes?: NodeWithScore[];
};
type SynthesizeStartEvent = {
    id: string;
    query: SynthesizeQuery;
};
type SynthesizeEndEvent = {
    id: string;
    query: SynthesizeQuery;
    response: EngineResponse | AsyncIterable<EngineResponse>;
};

type BaseSynthesizerOptions = {
    llm?: LLM;
    promptHelper?: PromptHelper;
};
declare abstract class BaseSynthesizer extends PromptMixin {
    llm: LLM;
    promptHelper: PromptHelper;
    protected constructor(options: Partial<BaseSynthesizerOptions>);
    protected abstract getResponse(query: MessageContent, textChunks: NodeWithScore[], stream: boolean): Promise<EngineResponse | AsyncIterable<EngineResponse>>;
    synthesize(query: SynthesizeQuery, stream: true): Promise<AsyncIterable<EngineResponse>>;
    synthesize(query: SynthesizeQuery, stream?: false): Promise<EngineResponse>;
}

declare const responseModeSchema: z.ZodEnum<["refine", "compact", "tree_summarize", "multi_modal"]>;
type ResponseMode = z.infer<typeof responseModeSchema>;
/**
 * A response builder that uses the query to ask the LLM generate a better response using multiple text chunks.
 */
declare class Refine extends BaseSynthesizer {
    textQATemplate: TextQAPrompt;
    refineTemplate: RefinePrompt;
    constructor(options: BaseSynthesizerOptions & {
        textQATemplate?: TextQAPrompt | undefined;
        refineTemplate?: RefinePrompt | undefined;
    });
    protected _getPromptModules(): ModuleRecord;
    protected _getPrompts(): {
        textQATemplate: TextQAPrompt;
        refineTemplate: RefinePrompt;
    };
    protected _updatePrompts(prompts: {
        textQATemplate: TextQAPrompt;
        refineTemplate: RefinePrompt;
    }): void;
    getResponse(query: MessageContent, nodes: NodeWithScore[], stream: true): Promise<AsyncIterable<EngineResponse>>;
    getResponse(query: MessageContent, nodes: NodeWithScore[], stream: false): Promise<EngineResponse>;
    private giveResponseSingle;
    private refineResponseSingle;
    complete(params: {
        prompt: string;
        stream: boolean;
    }): Promise<AsyncIterable<string> | string>;
}
/**
 * CompactAndRefine is a slight variation of Refine that first compacts the text chunks into the smallest possible number of chunks.
 */
declare class CompactAndRefine extends Refine {
    getResponse(query: MessageContent, nodes: NodeWithScore[], stream: true): Promise<AsyncIterable<EngineResponse>>;
    getResponse(query: MessageContent, nodes: NodeWithScore[], stream: false): Promise<EngineResponse>;
}
/**
 * TreeSummarize repacks the text chunks into the smallest possible number of chunks and then summarizes them, then recursively does so until there's one chunk left.
 */
declare class TreeSummarize extends BaseSynthesizer {
    summaryTemplate: TreeSummarizePrompt;
    constructor(options: BaseSynthesizerOptions & {
        summaryTemplate?: TreeSummarizePrompt;
    });
    protected _getPromptModules(): ModuleRecord;
    protected _getPrompts(): {
        summaryTemplate: TreeSummarizePrompt;
    };
    protected _updatePrompts(prompts: {
        summaryTemplate: TreeSummarizePrompt;
    }): void;
    getResponse(query: MessageContent, nodes: NodeWithScore[], stream: boolean): Promise<EngineResponse | AsyncIterable<EngineResponse>>;
}
declare class MultiModal extends BaseSynthesizer {
    metadataMode: MetadataMode;
    textQATemplate: TextQAPrompt;
    constructor({ textQATemplate, metadataMode, ...options }?: BaseSynthesizerOptions & {
        textQATemplate?: TextQAPrompt;
        metadataMode?: MetadataMode;
    });
    protected _getPromptModules(): ModuleRecord;
    protected _getPrompts(): {
        textQATemplate: TextQAPrompt;
    };
    protected _updatePrompts(promptsDict: {
        textQATemplate: TextQAPrompt;
    }): void;
    protected getResponse(query: MessageContent, nodes: NodeWithScore[], stream: boolean): Promise<EngineResponse | AsyncIterable<EngineResponse>>;
}
declare const modeToSynthesizer: {
    readonly compact: typeof CompactAndRefine;
    readonly refine: typeof Refine;
    readonly tree_summarize: typeof TreeSummarize;
    readonly multi_modal: typeof MultiModal;
};
declare function getResponseSynthesizer<Mode extends ResponseMode>(mode: Mode, options?: BaseSynthesizerOptions & {
    textQATemplate?: TextQAPrompt;
    refineTemplate?: RefinePrompt;
    summaryTemplate?: TreeSummarizePrompt;
    metadataMode?: MetadataMode;
}): InstanceType<(typeof modeToSynthesizer)[Mode]>;

declare function createMessageContent(prompt: BasePromptTemplate, nodes: BaseNode[], extraParams?: Record<string, string>, metadataMode?: MetadataMode): Promise<MessageContentDetail[]>;

export { BaseSynthesizer, type BaseSynthesizerOptions, CompactAndRefine, MultiModal, Refine, type ResponseMode, type SynthesizeEndEvent, type SynthesizeQuery, type SynthesizeStartEvent, TreeSummarize, createMessageContent, getResponseSynthesizer, responseModeSchema };
