import { PromptMixin, PromptTemplate, ModuleRecord } from '@llamaindex/core/prompts'; import { QueryType, QueryBundle } from '@llamaindex/core/query-engine'; import { ToolMetadata, LLM } from '@llamaindex/core/llms'; import { BaseOutputParser } from '@llamaindex/core/schema'; /** * Top level types to avoid circular dependencies */ /** * StructuredOutput is just a combo of the raw output and the parsed output. */ interface StructuredOutput { rawOutput: string; parsedOutput: T; } type ToolMetadataOnlyDescription = Pick; interface SingleSelection { index: number; reason: string; } type SelectorResult = { selections: SingleSelection[]; }; type MetadataType = string | ToolMetadataOnlyDescription; declare abstract class BaseSelector extends PromptMixin { select(choices: MetadataType[], query: QueryType): Promise; abstract _select(choices: ToolMetadataOnlyDescription[], query: QueryType): Promise; } type Answer = { choice: number; reason: string; }; type SingleSelectPrompt = PromptTemplate<[ "context", "query", "numChoices" ]>; type MultiSelectPrompt = PromptTemplate<[ "contextList", "query", "maxOutputs", "numChoices" ]>; /** * A selector that uses the LLM to select a single or multiple choices from a list of choices. */ declare class LLMMultiSelector extends BaseSelector { llm: LLM; prompt: MultiSelectPrompt; maxOutputs: number; outputParser: BaseOutputParser>; constructor(init: { llm: LLM; prompt?: MultiSelectPrompt; maxOutputs?: number; outputParser?: BaseOutputParser>; }); _getPrompts(): { prompt: MultiSelectPrompt; }; _updatePrompts(prompts: { prompt: MultiSelectPrompt; }): void; protected _getPromptModules(): ModuleRecord; /** * Selects a single choice from a list of choices. * @param choices * @param query */ _select(choices: ToolMetadataOnlyDescription[], query: QueryBundle): Promise; asQueryComponent(): unknown; } /** * A selector that uses the LLM to select a single choice from a list of choices. */ declare class LLMSingleSelector extends BaseSelector { llm: LLM; prompt: SingleSelectPrompt; outputParser: BaseOutputParser>; constructor(init: { llm: LLM; prompt?: SingleSelectPrompt; outputParser?: BaseOutputParser>; }); _getPrompts(): Record; _updatePrompts(prompts: Record): void; /** * Selects a single choice from a list of choices. * @param choices * @param query */ _select(choices: ToolMetadataOnlyDescription[], query: QueryBundle): Promise; asQueryComponent(): unknown; protected _getPromptModules(): {}; } declare const getSelectorFromContext: (isMulti?: boolean) => BaseSelector; export { BaseSelector, LLMMultiSelector, LLMSingleSelector, getSelectorFromContext }; export type { SelectorResult, SingleSelection };