From bb62bc1faa2b91acf9e76e6d28777886d71511b7 Mon Sep 17 00:00:00 2001 From: Antoine Garcia Date: Fri, 17 Nov 2023 11:58:52 +0100 Subject: [PATCH 1/3] feat: add filters to `ChaindeskRetriver` reference: https://docs.chaindesk.ai/api-reference/endpoint/datastores/query --- langchain/src/retrievers/chaindesk.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/langchain/src/retrievers/chaindesk.ts b/langchain/src/retrievers/chaindesk.ts index f2f36a9d11ea..ae1c2b17eaa1 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; + filters?: Record; apiKey?: string; } @@ -30,15 +31,18 @@ export class ChaindeskRetriever extends BaseRetriever { topK?: number; + filters?: Record; + apiKey?: string; - constructor({ datastoreId, apiKey, topK, ...rest }: ChaindeskRetrieverArgs) { + constructor({ datastoreId, apiKey, topK, filters,...rest }: ChaindeskRetrieverArgs) { super(); this.caller = new AsyncCaller(rest); this.datastoreId = datastoreId; this.apiKey = apiKey; this.topK = topK; + this.filters = filters; } async getRelevantDocuments(query: string): Promise { @@ -50,6 +54,7 @@ export class ChaindeskRetriever extends BaseRetriever { body: JSON.stringify({ query, ...(this.topK ? { topK: this.topK } : {}), + ...(this.filters ? { filters: this.filters } : {}), }), headers: { "Content-Type": "application/json", From 0fc590271f1f8b8270fa6d7608f4d3650a7fbc7a Mon Sep 17 00:00:00 2001 From: Antoine Garcia Date: Fri, 17 Nov 2023 18:18:52 +0100 Subject: [PATCH 2/3] rename filter to filters --- langchain/src/retrievers/chaindesk.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/langchain/src/retrievers/chaindesk.ts b/langchain/src/retrievers/chaindesk.ts index ae1c2b17eaa1..88935c05b6ae 100644 --- a/langchain/src/retrievers/chaindesk.ts +++ b/langchain/src/retrievers/chaindesk.ts @@ -7,7 +7,7 @@ export interface ChaindeskRetrieverArgs BaseRetrieverInput { datastoreId: string; topK?: number; - filters?: Record; + filter?: Record; apiKey?: string; } @@ -31,18 +31,18 @@ export class ChaindeskRetriever extends BaseRetriever { topK?: number; - filters?: Record; + filter?: Record; apiKey?: string; - constructor({ datastoreId, apiKey, topK, filters,...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.filters = filters; + this.filter = filter; } async getRelevantDocuments(query: string): Promise { @@ -54,7 +54,7 @@ export class ChaindeskRetriever extends BaseRetriever { body: JSON.stringify({ query, ...(this.topK ? { topK: this.topK } : {}), - ...(this.filters ? { filters: this.filters } : {}), + ...(this.filter ? { filters: this.filter } : {}), }), headers: { "Content-Type": "application/json", From b5dc887123fb02cbf56e12374e0d3fc29ca74c37 Mon Sep 17 00:00:00 2001 From: Antoine Garcia Date: Sun, 19 Nov 2023 12:31:08 +0100 Subject: [PATCH 3/3] run yarn format --- langchain/src/retrievers/chaindesk.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/langchain/src/retrievers/chaindesk.ts b/langchain/src/retrievers/chaindesk.ts index 88935c05b6ae..4e148b711433 100644 --- a/langchain/src/retrievers/chaindesk.ts +++ b/langchain/src/retrievers/chaindesk.ts @@ -35,7 +35,13 @@ export class ChaindeskRetriever extends BaseRetriever { apiKey?: string; - constructor({ datastoreId, apiKey, topK, filter,...rest }: ChaindeskRetrieverArgs) { + constructor({ + datastoreId, + apiKey, + topK, + filter, + ...rest + }: ChaindeskRetrieverArgs) { super(); this.caller = new AsyncCaller(rest);