qdrant / qdrant/qdrant-client

grpc error when searching using langchain

Open
#404 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
304
Avg merge
2d 9h
Merged PRs (30d)
37

Description

Dear all,

I have a qdrant client

import os

from qdrant_client import QdrantClient


def get_vector_db() -> QdrantClient:
    host = os.environ["VECTOR_DB_HOST"]
    port = os.environ["VECTOR_DB_PORT"]
    # 'vectordb' is host name when running all services with docker-compose up
    https = not host.startswith("localhost") and host != "vectordb"
    client = QdrantClient(host=host, port=port, https=https)

    return client

In prod, we had to do that weird conditioning because qdrant don't set https automatically when you pass a url with https

then I use is with langchain

....
self._db = Qdrant(
            client=get_vector_db(),
            collection_name=collection_name,
            embeddings=self._embeddings,
        )

self._chain = ConversationalRetrievalChain.from_llm(
    self._llm,
    retriever=self._db.as_retriever(),
    return_source_documents=True,
    verbose=True,
)

...

When I search

```python
 await chain.acall({"question": question, "chat_history": chat_history})

I got

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 274, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/services/api/routers/api/rag/route.py", line 109, in get_answer
    answer, sources = await qa.get_answer_with_retriever(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/services/api/services/qa.py", line 102, in get_answer_with_retriever
    return await self._get_answer(self._chain, question, chat_history, k, filter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/services/api/services/qa.py", line 79, in _get_answer
    res = await chain.acall({"question": question, "chat_history": chat_history})
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 377, in acall
    raise e
  File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 371, in acall
    await self._acall(inputs, run_manager=run_manager)
  File "/usr/local/lib/python3.11/site-packages/langchain/chains/conversational_retrieval/base.py", line 198, in _acall
    docs = await self._aget_docs(new_question, inputs, run_manager=_run_manager)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/chains/conversational_retrieval/base.py", line 316, in _aget_docs
    docs = await self.retriever.aget_relevant_documents(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/schema/retriever.py", line 269, in aget_relevant_documents
    raise e
  File "/usr/local/lib/python3.11/site-packages/langchain/schema/retriever.py", line 262, in aget_relevant_documents
    result = await self._aget_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/schema/vectorstore.py", line 605, in _aget_relevant_documents
    docs = await self.vectorstore.asimilarity_search(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 55, in wrapper
    return await method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 302, in asimilarity_search
    results = await self.asimilarity_search_with_score(query, k, filter, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 55, in wrapper
    return await method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 408, in asimilarity_search_with_score
    return await self.asimilarity_search_with_score_by_vector(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 55, in wrapper
    return await method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 715, in asimilarity_search_with_score_by_vector
    response = await self._asearch_with_score_by_vector(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/qdrant.py", line 650, in _asearch_with_score_by_vector
    response = await self.client.async_grpc_points.Search(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/grpc/aio/_call.py", line 318, in __await__
    raise _create_rpc_error(
grpc.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:10.217.237.154:6334: Failed to connect to remote host: FD Shutdown"
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-12-13T08:54:23.186589333+00:00", grpc_status:14, grpc_message:"failed to connect to all addresses; last error: UNKNOWN: ipv4:10.217.237.154:6334: Failed to connect to remote host: FD Shutdown"}"
>

Note qdrant is only running on the http port, I don't get it why is using grpc, is this a langchain issue?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing QdrantClient construction and the async search path used by LangChain's Qdrant vector store. Check how the client selects HTTP versus gRPC, especially the configured HTTP port and the attempted gRPC port 6334. Done means the transport choice is explained and the reported configuration or client behavior is corrected or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, python
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.