import type { BaseNode, Document, NodeWithScore } from "../../Node.js"; import type { ChoiceSelectPrompt } from "../../Prompt.js"; import type { BaseRetriever, RetrieveParams } from "../../Retriever.js"; import type { ServiceContext } from "../../ServiceContext.js"; import { RetrieverQueryEngine } from "../../engines/query/index.js"; import type { BaseNodePostprocessor } from "../../postprocessors/index.js"; import type { StorageContext } from "../../storage/StorageContext.js"; import type { BaseDocumentStore, RefDocInfo } from "../../storage/docStore/types.js"; import type { BaseSynthesizer } from "../../synthesizers/index.js"; import type { QueryEngine } from "../../types.js"; import type { BaseIndexInit } from "../BaseIndex.js"; import { BaseIndex } from "../BaseIndex.js"; import { IndexList } from "../json-to-index-struct.js"; import type { ChoiceSelectParserFunction, NodeFormatterFunction } from "./utils.js"; export declare enum SummaryRetrieverMode { DEFAULT = "default", LLM = "llm" } export interface SummaryIndexOptions { nodes?: BaseNode[]; indexStruct?: IndexList; indexId?: string; serviceContext?: ServiceContext; storageContext?: StorageContext; } /** * A SummaryIndex keeps nodes in a sequential order for use with summarization. */ export declare class SummaryIndex extends BaseIndex { constructor(init: BaseIndexInit); static init(options: SummaryIndexOptions): Promise; static fromDocuments(documents: Document[], args?: { storageContext?: StorageContext; serviceContext?: ServiceContext; }): Promise; asRetriever(options?: { mode: SummaryRetrieverMode; }): BaseRetriever; asQueryEngine(options?: { retriever?: BaseRetriever; responseSynthesizer?: BaseSynthesizer; preFilters?: unknown; nodePostprocessors?: BaseNodePostprocessor[]; }): QueryEngine & RetrieverQueryEngine; static buildIndexFromNodes(nodes: BaseNode[], docStore: BaseDocumentStore, indexStruct?: IndexList): Promise; insertNodes(nodes: BaseNode[]): Promise; deleteRefDoc(refDocId: string, deleteFromDocStore?: boolean): Promise; deleteNodes(nodeIds: string[], deleteFromDocStore: boolean): Promise; getRefDocInfo(): Promise>; } export type ListIndex = SummaryIndex; export type ListRetrieverMode = SummaryRetrieverMode; /** * Simple retriever for SummaryIndex that returns all nodes */ export declare class SummaryIndexRetriever implements BaseRetriever { index: SummaryIndex; constructor(index: SummaryIndex); retrieve({ query }: RetrieveParams): Promise; } /** * LLM retriever for SummaryIndex which lets you select the most relevant chunks. */ export declare class SummaryIndexLLMRetriever implements BaseRetriever { index: SummaryIndex; choiceSelectPrompt: ChoiceSelectPrompt; choiceBatchSize: number; formatNodeBatchFn: NodeFormatterFunction; parseChoiceSelectAnswerFn: ChoiceSelectParserFunction; serviceContext?: ServiceContext; constructor(index: SummaryIndex, choiceSelectPrompt?: ChoiceSelectPrompt, choiceBatchSize?: number, formatNodeBatchFn?: NodeFormatterFunction, parseChoiceSelectAnswerFn?: ChoiceSelectParserFunction, serviceContext?: ServiceContext); retrieve({ query }: RetrieveParams): Promise; } export type ListIndexRetriever = SummaryIndexRetriever; export type ListIndexLLMRetriever = SummaryIndexLLMRetriever;