Adding vecrtors to qdrant gives a validation error

23 Views Asked by At

I am getting an error from qdrant when I try to add vectors. Error below

UnexpectedResponse Traceback (most recent call last) in
----> 3 add_vectors(embeddings, payload)

6 frames /usr/local/lib/python3.10/dist-packages/qdrant_client/http/api_client.py in send(self, request, type_) 95 except ValidationError as e: 96 raise ResponseHandlingException(e) ---> 97 raise UnexpectedResponse.for_response(response) 98 99 def send_inner(self, request: Request) -> Response:

UnexpectedResponse: Unexpected Response: 422 (Unprocessable Entity) Raw response content: b'{"status":{"error":"Validation error in path parameters: [name: value \"status=<CollectionStatus.GREEN: 'green'> optimizer_status=<OptimizersStatusOneOf.OK: 'ok'> vectors_count=0 indexed_vectors_co ...'

below is my code:

raw_text ="some long text...."

`def get_chunks(raw_text):

text_splitter = CharacterTextSplitter(       
  separator="\n",       
  chunk_size=100,        
  chunk_overlap=50,        
  length_function=len)
  chunks = text_splitter.split_text(raw_text)    

return chunks`

`def get_embeddings(chunks, embedding_model_name="text-embedding-ada-002"):

points = []    
client = OpenAI( api_key=os.environ['OPENAI_API_KEY'],  )   
embeddings = []    
for chunk in chunks:        
  embeddings.append(client.embeddings.create(
  input = chunk,model=embedding_model_name).data[0].embedding)
      
return embeddings

=========================================================== `def add_vectors(vectors, payload):

   client = qdrant_client.QdrantClient(

       os.getenv("QDRANT_HOST"),

       api_key=os.getenv("QDRANT_API_KEY")

      )

  collection = client.get_collection(os.getenv("QDRANT_COLLECTION"))

  # Create a list of PointStruct objects

  points = [

        models.PointStruct(

            id=str(i),  # Assign unique IDs to points

            payload=payload,

            vector=vector

          )

     for i, vector in enumerate(vectors)

]



# Insert the points into the vector store

client.upsert(

    collection_name=collection,  # Replace with your collection name

    points=points

)`

==============================================================

then I make below calls:

chunks = get_chunks(raw_text)
embeddings = get_embeddings(chunks)
payload = {"user": "gxxxx"}
add_vectors(embeddings, payload)

and thats when I get the error mentioned above. What is the issue here?

I have tried all kinds of suggestions from internet

0

There are 0 best solutions below