AIAnytime / Haystack-and-Mistral-7B-RAG-Implementation

Haystack and Mistral 7B RAG Implementation. It is based on completely open-source stack.
MIT License
74 stars 40 forks source link

cannot import name 'Document' from 'haystack' #1

Open sdelahaies opened 1 year ago

sdelahaies commented 1 year ago

Hello, very nice video, and very nice tutorial on alternatives to langchain.

I am having troubles with haystack however, I tried to overcome dependency issues but couldn't get ingest.py to work properly and no magic solution seems to fix them right now.

Could you share the packages version for the requirements? This might solve the problem.

By the way, as you suggest I want to use multilingual-e5 to test a french chatbot.

sdelahaies commented 1 year ago

setting an environment with python 3.10 (instead of python 3.11) seems to fix the problem

tareeesh2001 commented 1 year ago

i am still getting the same error with python 3.10.9 error while running ingest.py: Traceback (most recent call last): File "/Users/sairohith/Downloads/Haystack-and-Mistral-7B-RAG-Implementation/ingest.py", line 1, in from haystack.nodes import EmbeddingRetriever, MarkdownConverter, PreProcessor, AnswerParser, PromptModel, PromptNode, PromptTemplate File "/Users/sairohith/anaconda3/envs/tg/lib/python3.10/site-packages/haystack/nodes/init.py", line 3, in from haystack.nodes.answer_generator import BaseGenerator, OpenAIAnswerGenerator File "/Users/sairohith/anaconda3/envs/tg/lib/python3.10/site-packages/haystack/nodes/answer_generator/init.py", line 2, in from haystack.nodes.answer_generator.openai import OpenAIAnswerGenerator File "/Users/sairohith/anaconda3/envs/tg/lib/python3.10/site-packages/haystack/nodes/answer_generator/openai.py", line 6, in from haystack import Document ImportError: cannot import name 'Document' from 'haystack' (/Users/sairohith/anaconda3/envs/tg/lib/python3.10/site-packages/haystack/init.py)

Can anyone give a solution to this?

sdelahaies commented 1 year ago

Hi, here is the list of packages of my environment in which it is running fine

Package Version


aiohttp 3.8.5 aiosignal 1.3.1 anyio 3.7.1 appdirs 1.4.4 async-timeout 4.0.3 attrs 23.1.0 Authlib 1.2.1 backoff 2.2.1 boilerpy3 1.0.6 cached-property 1.5.2 canals 0.7.0 cattrs 23.1.2 certifi 2023.7.22 cffi 1.16.0 charset-normalizer 3.3.0 click 8.1.7 cmake 3.27.6 cryptography 41.0.4 diskcache 5.6.3 docopt 0.6.2 Events 0.5 exceptiongroup 1.1.3 farm-haystack 1.21.0 fastapi 0.103.2 filelock 3.12.4 frozenlist 1.4.0 fsspec 2023.9.2 h11 0.14.0 haystack-ai 0.55.0 huggingface-hub 0.17.3 idna 3.4 inflect 7.0.0 Jinja2 3.1.2 joblib 1.3.2 jsonschema 4.19.1 jsonschema-specifications 2023.7.1 lazy-imports 0.3.1 lit 17.0.1 llama_cpp_python 0.2.11 llvmlite 0.41.0 MarkupSafe 2.1.3 monotonic 1.6 more-itertools 10.1.0 mpmath 1.3.0 multidict 6.0.4 networkx 3.1 nltk 3.8.1 num2words 0.5.12 numba 0.58.0 numpy 1.25.2 nvidia-cublas-cu11 11.10.3.66 nvidia-cuda-cupti-cu11 11.7.101 nvidia-cuda-nvrtc-cu11 11.7.99 nvidia-cuda-runtime-cu11 11.7.99 nvidia-cudnn-cu11 8.5.0.96 nvidia-cufft-cu11 10.9.0.58 nvidia-curand-cu11 10.2.10.91 nvidia-cusolver-cu11 11.4.0.1 nvidia-cusparse-cu11 11.7.4.91 nvidia-nccl-cu11 2.14.3 nvidia-nvtx-cu11 11.7.91 openai 0.28.1 openai-whisper 20230918 packaging 23.2 pandas 2.1.1 Pillow 10.0.1 pip 23.2.1 platformdirs 3.11.0 posthog 3.0.2 prompthub-py 4.0.0 pycparser 2.21 pydantic 1.10.13 pynvml 11.5.0 pypdf 3.16.2 python-dateutil 2.8.2 python-dotenv 1.0.0 python-multipart 0.0.6 pytz 2023.3.post1 PyYAML 6.0.1 quantulum3 0.9.0 rank-bm25 0.2.2 referencing 0.30.2 regex 2023.8.8 requests 2.31.0 requests-cache 0.9.8 rpds-py 0.10.3 safetensors 0.3.3 scikit-learn 1.3.1 scipy 1.11.3 sentence-transformers 2.2.2 sentencepiece 0.1.99 setuptools 68.0.0 six 1.16.0 sniffio 1.3.0 sseclient-py 1.8.0 starlette 0.27.0 sympy 1.12 tenacity 8.2.3 threadpoolctl 3.2.0 tiktoken 0.5.1 tokenizers 0.13.3 torch 2.0.1 torchvision 0.15.2 tqdm 4.66.1 transformers 4.32.1 triton 2.0.0 typing_extensions 4.8.0 tzdata 2023.3 url-normalize 1.4.3 urllib3 2.0.6 uvicorn 0.23.2 validators 0.22.0 weaviate-client 3.24.1 wheel 0.41.2 yarl 1.9.2

tareeesh2001 commented 1 year ago

Fixed it by updating requirements.txt. Remove "farm-haystack" and keep only "farm-haystack[weaviate]". You need to pip uninstall farm-haystack. It seems there is some conflict, when both libs are installed and some classes are not visible