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; }; type BaseSynthesizerOptions = { llm?: LLM; promptHelper?: PromptHelper; }; declare abstract class BaseSynthesizer extends PromptMixin { llm: LLM; promptHelper: PromptHelper; protected constructor(options: Partial); protected abstract getResponse(query: MessageContent, textChunks: NodeWithScore[], stream: boolean): Promise>; synthesize(query: SynthesizeQuery, stream: true): Promise>; synthesize(query: SynthesizeQuery, stream?: false): Promise; } declare const responseModeSchema: z.ZodEnum<{ refine: "refine"; compact: "compact"; tree_summarize: "tree_summarize"; multi_modal: "multi_modal"; }>; type ResponseMode = z.infer; /** * 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>; getResponse(query: MessageContent, nodes: NodeWithScore[], stream: false): Promise; private giveResponseSingle; private refineResponseSingle; complete(params: { prompt: string; stream: boolean; }): Promise | 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>; getResponse(query: MessageContent, nodes: NodeWithScore[], stream: false): Promise; } /** * 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>; } 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>; } 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: Mode, options?: BaseSynthesizerOptions & { textQATemplate?: TextQAPrompt; refineTemplate?: RefinePrompt; summaryTemplate?: TreeSummarizePrompt; metadataMode?: MetadataMode; }): InstanceType<(typeof modeToSynthesizer)[Mode]>; declare function createMessageContent(prompt: BasePromptTemplate, nodes: BaseNode[], extraParams?: Record, metadataMode?: MetadataMode): Promise; export { BaseSynthesizer, CompactAndRefine, MultiModal, Refine, TreeSummarize, createMessageContent, getResponseSynthesizer, responseModeSchema }; export type { BaseSynthesizerOptions, ResponseMode, SynthesizeEndEvent, SynthesizeQuery, SynthesizeStartEvent };