Skip to content

Conversation

lukacerr
Copy link

@lukacerr lukacerr commented Sep 4, 2025

.ainvoke requires async _aget_relevant_documents implementation to work properly.

Exhibit:

Traceback (most recent call last):
  File "/home/luka/Documents/nexata/llm/.venv/lib/python3.13/site-packages/grpclib/server.py", line 445, in request_handler
    await method_func(stream)
  File "/home/luka/Documents/nexata/llm/lib/nexata/__init__.py", line 54, in __rpc_health
    response = await self.health(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/luka/Documents/nexata/llm/src/services/health.py", line 28, in health
    doc = await ret.ainvoke("das")
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/luka/Documents/nexata/llm/.venv/lib/python3.13/site-packages/langchain_core/retrievers.py", line 326, in ainvoke
    result = await self._aget_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        input, run_manager=run_manager, **kwargs_
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/luka/Documents/nexata/llm/.venv/lib/python3.13/site-packages/langchain_core/vectorstores/base.py", line 1119, in _aget_relevant_documents
    raise ValueError(msg)
ValueError: search_type of vector not allowed.

Code that replicates the given error:

# Vector store initialization
vstore = AzureCosmosDBNoSqlVectorSearch(
    search_type="vector",
    database_name="nexata",
    container_name="vectors",
    cosmos_client=CosmosClient(
        getenv("AZURE_COSMOS_DB_ENDPOINT", "https://127.0.0.1:8081"),
        getenv("AZURE_COSMOS_DB_KEY", ""),
    ),
    embedding=embeddings,
    vector_embedding_policy={
        "vectorEmbeddings": [
            {
                "path": "/embedding",
                "dataType": "float32",
                "distanceFunction": "cosine",
                "dimensions": 1536,
            }
        ]
    },
    indexing_policy={
        "automatic": True,
        "indexingMode": "consistent",
        "includedPaths": [{"path": "/*"}],
        "excludedPaths": [{"path": '/"_etag"/?'}],
        "vectorIndexes": [{"path": "/embedding", "type": "diskANN"}],
        "fullTextIndexes": [{"path": "/text"}],
    },
    cosmos_container_properties={
        "partition_key": PartitionKey("/metadata/tenant_id"),
    },
    cosmos_database_properties={},
    vector_search_fields={
        "text_field": "text",
        "embedding_field": "embedding",
    },
    full_text_policy={
        "defaultLanguage": "en-US",
        "fullTextPaths": [
            {"path": "/text", "language": "en-US"},
        ],
    },
    full_text_search_enabled=True,
)

ret = vstore.as_retriever(search_type="vector")

# Later, in an async function...
doc = await ret.ainvoke("das")  # ValueError: search_type of vector not allowed.

@marlenezw
Copy link
Collaborator

Hi @aayush3011, do you have any bandwidth to review this? It's a super helpful addition. Linting looks like it's failing because of a signature mismatch.

@marlenezw
Copy link
Collaborator

@aayush3011 I'm wanting to merge or close all PR's in the coming days. Please take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants