diff --git a/libs/langchain-community/src/vectorstores/chroma.ts b/libs/langchain-community/src/vectorstores/chroma.ts index f7dd250872b2..fd9cc08eaa9f 100644 --- a/libs/langchain-community/src/vectorstores/chroma.ts +++ b/libs/langchain-community/src/vectorstores/chroma.ts @@ -354,6 +354,7 @@ export class Chroma extends VectorStore { throw new Error("cannot provide both `filter` and `this.filter`"); } const _filter = filter ?? this.filter; + const where = _filter === undefined ? undefined : { ..._filter }; const collection = await this.ensureCollection(); @@ -362,7 +363,7 @@ export class Chroma extends VectorStore { const result = await collection.query({ queryEmbeddings: query, nResults: k, - where: { ..._filter }, + where, }); const { ids, distances, documents, metadatas } = result; diff --git a/libs/langchain-community/src/vectorstores/tests/chroma.test.ts b/libs/langchain-community/src/vectorstores/tests/chroma.test.ts index 023c36560df1..3fc58c3bedcc 100644 --- a/libs/langchain-community/src/vectorstores/tests/chroma.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/chroma.test.ts @@ -128,7 +128,7 @@ describe("Chroma", () => { expect(mockCollection.query).toHaveBeenCalledWith({ queryEmbeddings: query, nResults: expectedResultCount, - where: {}, + where: undefined, }); expect(results).toHaveLength(5); });