Skip to content

Commit

Permalink
fix(community): chroma search without filter (#7183)
Browse files Browse the repository at this point in the history
  • Loading branch information
commenthol authored Nov 12, 2024
1 parent 5d526bc commit c5f336b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/langchain-community/src/vectorstores/chroma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe("Chroma", () => {
expect(mockCollection.query).toHaveBeenCalledWith({
queryEmbeddings: query,
nResults: expectedResultCount,
where: {},
where: undefined,
});
expect(results).toHaveLength(5);
});
Expand Down

0 comments on commit c5f336b

Please sign in to comment.