UNPKG

@langchain/core

Version:
1 lines 6.3 kB
{"version":3,"file":"index.d.ts","names":["CallbackManagerForRetrieverRun","Callbacks","DocumentInterface","Runnable","RunnableInterface","RunnableConfig","BaseRetrieverInput","Record","BaseRetrieverInterface","Metadata","BaseRetriever","Promise"],"sources":["../../src/retrievers/index.d.ts"],"sourcesContent":["import { CallbackManagerForRetrieverRun, Callbacks } from \"../callbacks/manager.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { Runnable, type RunnableInterface } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\n/**\n * Input configuration options for initializing a retriever that extends\n * the `BaseRetriever` class. This interface provides base properties\n * common to all retrievers, allowing customization of callback functions,\n * tagging, metadata, and logging verbosity.\n *\n * Fields:\n * - `callbacks` (optional): An array of callback functions that handle various\n * events during retrieval, such as logging, error handling, or progress updates.\n *\n * - `tags` (optional): An array of strings used to add contextual tags to\n * retrieval operations, allowing for easier categorization and tracking.\n *\n * - `metadata` (optional): A record of key-value pairs to store additional\n * contextual information for retrieval operations, which can be useful\n * for logging or auditing purposes.\n *\n * - `verbose` (optional): A boolean flag that, if set to `true`, enables\n * detailed logging and output during the retrieval process. Defaults to `false`.\n */\nexport interface BaseRetrieverInput {\n callbacks?: Callbacks;\n tags?: string[];\n metadata?: Record<string, unknown>;\n verbose?: boolean;\n}\n/**\n * Interface for a base retriever that defines core functionality for\n * retrieving relevant documents from a source based on a query.\n *\n * The `BaseRetrieverInterface` standardizes the `getRelevantDocuments` method,\n * enabling retrieval of documents that match the query criteria.\n *\n * @template Metadata - The type of metadata associated with each document,\n * defaulting to `Record<string, any>`.\n */\nexport interface BaseRetrieverInterface<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nMetadata extends Record<string, any> = Record<string, any>> extends RunnableInterface<string, DocumentInterface<Metadata>[]> {\n}\n/**\n * Abstract base class for a document retrieval system, designed to\n * process string queries and return the most relevant documents from a source.\n *\n * `BaseRetriever` provides common properties and methods for derived retrievers,\n * such as callbacks, tagging, and verbose logging. Custom retrieval systems\n * should extend this class and implement `_getRelevantDocuments` to define\n * the specific retrieval logic.\n *\n * @template Metadata - The type of metadata associated with each document,\n * defaulting to `Record<string, any>`.\n */\nexport declare abstract class BaseRetriever<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nMetadata extends Record<string, any> = Record<string, any>> extends Runnable<string, DocumentInterface<Metadata>[]> implements BaseRetrieverInterface {\n /**\n * Optional callbacks to handle various events in the retrieval process.\n */\n callbacks?: Callbacks;\n /**\n * Tags to label or categorize the retrieval operation.\n */\n tags?: string[];\n /**\n * Metadata to provide additional context or information about the retrieval\n * operation.\n */\n metadata?: Record<string, unknown>;\n /**\n * If set to `true`, enables verbose logging for the retrieval process.\n */\n verbose?: boolean;\n /**\n * Constructs a new `BaseRetriever` instance with optional configuration fields.\n *\n * @param fields - Optional input configuration that can include `callbacks`,\n * `tags`, `metadata`, and `verbose` settings for custom retriever behavior.\n */\n constructor(fields?: BaseRetrieverInput);\n /**\n * TODO: This should be an abstract method, but we'd like to avoid breaking\n * changes to people currently using subclassed custom retrievers.\n * Change it on next major release.\n */\n /**\n * Placeholder method for retrieving relevant documents based on a query.\n *\n * This method is intended to be implemented by subclasses and will be\n * converted to an abstract method in the next major release. Currently, it\n * throws an error if not implemented, ensuring that custom retrievers define\n * the specific retrieval logic.\n *\n * @param _query - The query string used to search for relevant documents.\n * @param _callbacks - (optional) Callback manager for managing callbacks\n * during retrieval.\n * @returns A promise resolving to an array of `DocumentInterface` instances relevant to the query.\n * @throws {Error} Throws an error indicating the method is not implemented.\n */\n _getRelevantDocuments(_query: string, _callbacks?: CallbackManagerForRetrieverRun): Promise<DocumentInterface<Metadata>[]>;\n /**\n * Executes a retrieval operation.\n *\n * @param input - The query string used to search for relevant documents.\n * @param options - (optional) Configuration options for the retrieval run,\n * which may include callbacks, tags, and metadata.\n * @returns A promise that resolves to an array of `DocumentInterface` instances\n * representing the most relevant documents to the query.\n */\n invoke(input: string, options?: RunnableConfig): Promise<DocumentInterface<Metadata>[]>;\n}\n"],"mappings":";;;;;;;;;AAwBA;;;;AAGqB;AAarB;;;;;;;AAEqF;AAcrF;;;;;AAEqFE,UAlCpEI,kBAAAA,CAkCoEJ;EAAiB,SAItFD,CAAAA,EArCAA,SAqCAA;EAAS,IASVM,CAAAA,EAAAA,MAAAA,EAAAA;EAAM,QAWID,CAAAA,EAvDVC,MAuDUD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAkB,OAoBYN,CAAAA,EAAAA,OAAAA;;;;;;;;;;AA5C8F;;UAlBpIQ;;iBAEAD,sBAAsBA,6BAA6BH,0BAA0BF,kBAAkBO;;;;;;;;;;;;;uBAclFC;;iBAEbH,sBAAsBA,6BAA6BJ,iBAAiBD,kBAAkBO,wBAAwBD;;;;cAI/GP;;;;;;;;;aASDM;;;;;;;;;;;uBAWUD;;;;;;;;;;;;;;;;;;;;qDAoB8BN,iCAAiCW,QAAQT,kBAAkBO;;;;;;;;;;kCAU9EJ,iBAAiBM,QAAQT,kBAAkBO"}