UNPKG

@langchain/community

Version:
1 lines • 3.16 kB
{"version":3,"file":"base.d.ts","names":["BaseRetriever","BaseRetrieverInput","AsyncCaller","AsyncCallerParams","DocumentInterface","RemoteRetrieverAuth","RemoteRetrieverValues","Record","RemoteRetrieverParams","RemoteRetriever","Promise"],"sources":["../../../src/retrievers/remote/base.d.ts"],"sourcesContent":["import { BaseRetriever, type BaseRetrieverInput } from \"@langchain/core/retrievers\";\nimport { AsyncCaller, type AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\nimport type { DocumentInterface } from \"@langchain/core/documents\";\n/**\n * Type for the authentication method used by the RemoteRetriever. It can\n * either be false (no authentication) or an object with a bearer token.\n */\nexport type RemoteRetrieverAuth = false | {\n bearer: string;\n};\n/**\n * Type for the JSON response values from the remote server.\n */\nexport type RemoteRetrieverValues = Record<string, any>;\n/**\n * Interface for the parameters required to initialize a RemoteRetriever\n * instance.\n */\nexport interface RemoteRetrieverParams extends AsyncCallerParams, BaseRetrieverInput {\n /**\n * The URL of the remote retriever server\n */\n url: string;\n /**\n * The authentication method to use, currently implemented is\n * - false: no authentication\n * - { bearer: string }: Bearer token authentication\n */\n auth: RemoteRetrieverAuth;\n}\n/**\n * Abstract class for interacting with a remote server to retrieve\n * relevant documents based on a given query.\n */\nexport declare abstract class RemoteRetriever extends BaseRetriever implements RemoteRetrieverParams {\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n url: string;\n auth: RemoteRetrieverAuth;\n headers: Record<string, string>;\n asyncCaller: AsyncCaller;\n constructor(fields: RemoteRetrieverParams);\n /**\n * Abstract method that should be implemented by subclasses to create the\n * JSON body of the request based on the given query.\n * @param query The query based on which the JSON body of the request is created.\n * @returns The JSON body of the request.\n */\n abstract createJsonBody(query: string): RemoteRetrieverValues;\n /**\n * Abstract method that should be implemented by subclasses to process the\n * JSON response from the server and convert it into an array of Document\n * instances.\n * @param json The JSON response from the server.\n * @returns An array of Document instances.\n */\n abstract processJsonResponse(json: RemoteRetrieverValues): DocumentInterface[];\n _getRelevantDocuments(query: string): Promise<DocumentInterface[]>;\n}\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;AAOA;AAMA;AAKiBQ,KAXLH,mBAAAA,GAW0B,KAAA,GAAA;EAU5BA,MAAAA,EAAAA,MAAAA;CAVqCF;;AAAqC;AAgBpF;AAKUE,KA1BEC,qBAAAA,GAAwBC,MA0B1BF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;AAkB6BC,UAvCtBE,qBAAAA,SAA8BL,iBAuCRG,EAvC2BL,kBAuC3BK,CAAAA;EAAwBF;;;EAvBTJ,GAAAA,EAAAA,MAAAA;EAAyBQ;AAAqB;;;;QAN1FH;;;;;;uBAMoBI,eAAAA,SAAwBT,aAAAA,YAAyBQ;;;;;QAKrEH;WACGE;eACIL;sBACOM;;;;;;;0CAOoBF;;;;;;;;qCAQLA,wBAAwBF;wCACrBM,QAAQN"}