|
| 1 | +import { Document } from '../documents/index.ts' |
| 2 | + |
| 3 | +/** |
| 4 | + * Input configuration options for initializing a retriever that extends |
| 5 | + * the `BaseRetriever` class. This interface provides base properties |
| 6 | + * common to all retrievers, allowing customization of callback functions, |
| 7 | + * tagging, metadata, and logging verbosity. |
| 8 | + * |
| 9 | + * Fields: |
| 10 | + * |
| 11 | + * - `tags` (optional): An array of strings used to add contextual tags to |
| 12 | + * retrieval operations, allowing for easier categorization and tracking. |
| 13 | + * |
| 14 | + * - `metadata` (optional): A record of key-value pairs to store additional |
| 15 | + * contextual information for retrieval operations, which can be useful |
| 16 | + * for logging or auditing purposes. |
| 17 | + * |
| 18 | + */ |
| 19 | +export interface RetrieverInput { |
| 20 | + tags?: string[] |
| 21 | + metadata?: Record<string, unknown> |
| 22 | +} |
| 23 | + |
| 24 | +/** |
| 25 | + * Interface for a base retriever that defines core functionality for |
| 26 | + * retrieving relevant documents from a source based on a query. |
| 27 | + * |
| 28 | + * The `BaseRetrieverInterface` standardizes the `getRelevantDocuments` method, |
| 29 | + * enabling retrieval of documents that match the query criteria. |
| 30 | + * |
| 31 | + * @template Metadata - The type of metadata associated with each document, |
| 32 | + * defaulting to `Record<string, any>`. |
| 33 | + */ |
| 34 | +export interface Retriever< |
| 35 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 36 | + Metadata extends Record<string, any> = Record<string, any> |
| 37 | +> { |
| 38 | + /** |
| 39 | + * Retrieves documents relevant to a given query, allowing optional |
| 40 | + * configurations for customization. |
| 41 | + * |
| 42 | + * @param query - A string representing the query to search for relevant documents. |
| 43 | + * @param config - (optional) Configuration options for the retrieval process, |
| 44 | + * which may include callbacks and additional context settings. |
| 45 | + * @returns A promise that resolves to an array of `DocumentInterface` instances, |
| 46 | + * each containing metadata specified by the `Metadata` type parameter. |
| 47 | + */ |
| 48 | + getRelevantDocuments(query: string): Promise<Document<Metadata>[]> |
| 49 | +} |
0 commit comments