langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
95.26k stars 15.46k forks source link

The Qdrant Vector Store, for filtering is not using the right imports. #28012

Open andresnatanael opened 2 weeks ago

andresnatanael commented 2 weeks ago

URL

https://python.langchain.com/docs/integrations/vectorstores/qdrant/

Checklist

Issue with current documentation:

The code https://github.com/langchain-ai/langchain/blob/master/docs/docs/integrations/vectorstores/qdrant.ipynb

from qdrant_client.http import models

results = vector_store.similarity_search(
    query="Who are the best soccer players in the world?",
    k=1,
    filter=models.Filter(
        should=[
            models.FieldCondition(
                key="page_content",
                match=models.MatchValue(
                    value="The top 10 soccer players in the world right now."
                ),
            ),
        ]
    ),
)
for doc in results:
    print(f"* {doc.page_content} [{doc.metadata}]")

Uses a wrong import the right is:

from qdrant_client import models

from qdrant_client import models

results = vector_store.similarity_search(
    query="Who are the best soccer players in the world?",
    k=1,
    filter=models.Filter(
        should=[
            models.FieldCondition(
                key="page_content",
                match=models.MatchValue(
                    value="The top 10 soccer players in the world right now."
                ),
            ),
        ]
    ),
)
for doc in results:
    print(f"* {doc.page_content} [{doc.metadata}]")

Source:

https://qdrant.tech/documentation/concepts/filtering/

Idea or request for content:

Please update the import since I changed with the one used in the Qdrant documentation the metadata filtering started working fine.

Source File: https://github.com/langchain-ai/langchain/blob/master/docs/docs/integrations/vectorstores/qdrant.ipynb

ZhangShenao commented 2 days ago

Try to fix it in #28286