AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Missing Await In Async Similarity_search Example In QdrantVectorStore Docstring

The docstring for QdrantVectorStore contains an asynchronous example that calls asimilarity_search without await, causing users to receive a coroutine object instead of the actual search results.

mediumConfidence 95%LangChain

Origin Analysis

The example code in the docstring omitted the await keyword for the asynchronous method asimilarity_search, leading to incorrect usage that returns a coroutine instead of executed results.
1. Copy the example code from the QdrantVectorStore docstring: ```python from langchain_qdrant import QdrantVectorStore # assume vector_store is already initialized results = vector_store.asimilarity_search(query="thud", k=1) print(results) ``` 2. Run the code. Observe that the output is a coroutine object, not a list of documents.

Fixing Code Block

```python # Fixed async example: add await and wrap in an async function import asyncio from langchain_qdrant import QdrantVectorStore async def main(): # Assume vector_store is already initialized results = await vector_store.asimilarity_search(query="thud", k=1) print(results) asyncio.run(main()) ```
Add the await keyword before the asynchronous call to asimilarity_search to properly execute the coroutine and obtain the results. The example is wrapped in an async function and executed with asyncio.run to provide a complete, runnable snippet.

Edge Case Audit

Users who copy this fix must ensure they are inside an asynchronous context (async def). If the await is used outside an async function, a SyntaxError will occur. Also, different versions of langchain-qdrant may have slightly different APIs; verify that asimilarity_search exists in the installed version. To roll back, simply revert the docstring change or the user's code to the previous version.

Ecosystem Topology