diff --git a/langchain/src/retrievers/chaindesk.ts b/langchain/src/retrievers/chaindesk.ts index f2f36a9d11ea..4e148b711433 100644 --- a/langchain/src/retrievers/chaindesk.ts +++ b/langchain/src/retrievers/chaindesk.ts @@ -7,6 +7,7 @@ export interface ChaindeskRetrieverArgs BaseRetrieverInput { datastoreId: string; topK?: number; + filter?: Record; apiKey?: string; } @@ -30,15 +31,24 @@ export class ChaindeskRetriever extends BaseRetriever { topK?: number; + filter?: Record; + apiKey?: string; - constructor({ datastoreId, apiKey, topK, ...rest }: ChaindeskRetrieverArgs) { + constructor({ + datastoreId, + apiKey, + topK, + filter, + ...rest + }: ChaindeskRetrieverArgs) { super(); this.caller = new AsyncCaller(rest); this.datastoreId = datastoreId; this.apiKey = apiKey; this.topK = topK; + this.filter = filter; } async getRelevantDocuments(query: string): Promise { @@ -50,6 +60,7 @@ export class ChaindeskRetriever extends BaseRetriever { body: JSON.stringify({ query, ...(this.topK ? { topK: this.topK } : {}), + ...(this.filter ? { filters: this.filter } : {}), }), headers: { "Content-Type": "application/json",