deepset-ai / haystack

:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
https://haystack.deepset.ai
Apache License 2.0
17.5k stars 1.9k forks source link

ImportError: cannot import name 'FilterPolicy' from 'haystack.document_stores.types' #8314

Closed sahlebrahim closed 3 weeks ago

sahlebrahim commented 2 months ago

Describe the bug

Describe the bug When trying to import PineconeEmbeddingRetriever from haystack_integrations.components.retrievers.pinecone, an error occurs because the import fails because of FilterPolicy not being able to be imported from haystack.document_stores.types Error message ImportError: cannot import name 'FilterPolicy' from 'haystack.document_stores.types'

Additional context i have been installing various versions of haystack to solve this to no avail. To Reproduce from haystack_integrations.components.retrievers.pinecone import PineconeEmbeddingRetriever

System: OS: Windows 11 Pro 23H2 GPU/CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz Haystack version: 2.2.0 DocumentStore: Pinecone Retriever: PineconeEmbeddingRetriever

anakin87 commented 2 months ago

I think FilterPolicy was introduced in haystack-ai==2.3.0. Please update your Haystack version.

To install the latest version, you can use: pip install -U haystack-ai

sahlebrahim commented 2 months ago

@anakin87 i use lower versions because now i have issue ImportError: cannot import name 'HuggingFaceTGIGenerator' from 'haystack.components.generators' which popped up after using 2.3.0 or upper

sahlebrahim commented 2 months ago

@anakin87 fyi i have tranformers==4.43.2 and huggingface_hub==0.23.2

anakin87 commented 2 months ago

HuggingFaceTGIGenerator was deprecated, then removed and can be easily replaced with HuggingFaceAPIGenerator.

You could also pin qdrant-haystack to an older version. You can check the changelog here, but I would not recommend this practice.