Skip to content

Commit 01b7e6b

Browse files
Apply workaround to Chroma query (#890)
* Apply workaround to Chroma query * Update test for Chroma similarity_search_by_vector --------- Co-authored-by: Andrei Bondarev <[email protected]>
1 parent 454f6ba commit 01b7e6b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/langchain/vectorsearch/chroma.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def similarity_search_by_vector(
116116
count = collection.count
117117
n_results = [count, k].min
118118

119-
collection.query(query_embeddings: [embedding], results: n_results)
119+
# workaround mentioned here: https://github.com/mariochavez/chroma/issues/29
120+
collection.query(query_embeddings: [embedding], results: n_results, where: nil, where_document: nil)
120121
end
121122

122123
# Ask a question and return the answer

spec/langchain/vectorsearch/chroma_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
describe "#similarity_search_by_vector" do
124124
before do
125125
allow_any_instance_of(Chroma::Resources::Collection).to receive(:count).and_return(count)
126-
allow_any_instance_of(Chroma::Resources::Collection).to receive(:query).with(query_embeddings: [embedding], results: count).and_return(results)
126+
allow_any_instance_of(Chroma::Resources::Collection).to receive(:query).with(query_embeddings: [embedding], results: count, where: nil, where_document: nil).and_return(results)
127127
end
128128

129129
it "searches for similar texts" do

0 commit comments

Comments
 (0)