mariochavez / chroma

Ruby client for Chroma DB
MIT License
68 stars 6 forks source link

Why where is mandatory param? Shouldn't it be optional as per chromadb? #29

Open vikas-0 opened 3 weeks ago

vikas-0 commented 3 weeks ago

ERROR -- : message=Client error response code=400 body={"error":"InvalidArgumentError","message":"Expected where to have exactly one operator, got {}"} /usr/local/rvm/gems/default/gems/irb-1.14.1/lib/irb.rb:1260:in `full_message': InvalidArgumentError (Chroma::APIError)

matsubo commented 2 weeks ago

My situation

I've got same error.

>  question_embedding  = [1.8638756275177002,
 -0.023308515548706055,
 -2.544995069503784,
 1.411717176437378,
 1.2810852527618408,
 1.5934257507324219,
 0.3053443729877472,
 -1.9993882179260254,
 0.11245744675397873,
 -0.8461968302726746,
 -2.4017527103424072,
 -1.3157418966293335,
 -4.111044406890869,
 -0.6862623691558838,
 0.6185646653175354,
 -1.1491460800170898]
> collection = Chroma::Resources::Collection.get(collection_name)
> collection.query(query_embeddings: question_embedding)

Then I got following error from the

E, [2024-11-13T23:36:07.016314 #154] ERROR -- : message=Client error response code=400 body={"error":"InvalidArgumentError","message":"Expected where to have exactly one operator, got {}"}
(my-rag):115:in `<main>': InvalidArgumentError (Chroma::APIError)

Server version

> Chroma::Resources::Database.version
=> "0.5.18"

I've also tried following option according to the option shown in the python library but the errror message does not change.

     collection.query(
        query_embeddings: [ question_embedding ],
        where: {"metadata_field": "is_equal_to_this"}
      )

Temporary solution

I specified where and where_document key with nil then the server responses success.

collection = Chroma::Resources::Collection.get(collection_name)
collection.query(
  query_embeddings: question_embedding,
  where: nil,
  where_document: nil
)

The ChromaDB server does not allow empty array or hash.

justi commented 8 hours ago

I've got the same error.

@matsubo thanks for workaround.