赞
踩
参考我的另一篇博客:ollama + fastgpt 搭建免费本地知识库-CSDN博客
概述:
QAnything (Question and Answer based on Anything) 是致力于支持任意格式文件或数据库的本地知识库问答系统,可断网安装使用。
您的任何格式的本地文件都可以往里扔,即可获得准确、快速、靠谱的问答体验。
目前已支持格式: PDF(pdf),Word(docx),PPT(pptx),XLS(xlsx),Markdown(md),电子邮件(eml),TXT(txt),图片(jpg,jpeg,png),CSV(csv),网页链接(html),更多格式,敬请期待...
- conda create -n qanything-python python=3.10
- conda activate qanything-python
- git clone -b qanything-python https://github.com/netease-youdao/QAnything.git
- cd QAnything
- pip install -e .
- # 本地已经启动了ollama,这里做个运行测试
- # 因为我的ollama里没有安装llama3模型,所以修改一下run_for_ollama_api_in_M1_mac.sh的参数。改成使用qwen2:latest模型
- #!/bin/bash
- #bash scripts/base_run.sh -s "M1mac" -w 4 -m 19530 -q 8777 -o -b 'http://localhost:11434/v1' -k 'ollama' -n 'llama3' -l '4096'
- bash scripts/base_run.sh -s "M1mac" -w 4 -m 19530 -q 8777 -o -b 'http://localhost:11434/v1' -k 'ollama' -n 'qwen2:latest' -l '4096'
-
- # 启动运行
- bash scripts/run_for_ollama_api_in_M1_mac.sh
报错信息如下:
- (base) ➜ QAnything git:(qanything-python) ✗ bash scripts/run_for_ollama_api_in_M1_mac.sh
- 即将启动后端服务,启动成功后请复制[http://0.0.0.0:8777/qanything/]到浏览器进行测试。
- 运行qanything-server的命令是:
- CUDA_VISIBLE_DEVICES=0 python3 -m qanything_kernel.qanything_server.sanic_api --host 0.0.0.0 --port 8777 --model_size 7B --use_openai_api --openai_api_base http://localhost:11434/v1 --openai_api_key ollama --openai_api_model_name llama3 --openai_api_context_length 4096 --workers 4
- LOCAL DATA PATH: /Users/renlibin/PythonProjects/QAnything/QANY_DB/content
- LOCAL_RERANK_REPO: maidalun/bce-reranker-base_v1
- LOCAL_EMBED_REPO: maidalun/bce-embedding-base_v1
- 2024-06-28 17:34:14,614 - modelscope - INFO - PyTorch version 2.1.2 Found.
- 2024-06-28 17:34:14,614 - modelscope - INFO - Loading ast index from /Users/renlibin/.cache/modelscope/ast_indexer
- 2024-06-28 17:34:14,614 - modelscope - INFO - No valid ast index found from /Users/renlibin/.cache/modelscope/ast_indexer, generating ast index from prebuilt!
- 2024-06-28 17:34:14,691 - modelscope - INFO - Loading done! Current index file version is 1.13.0, with md5 f0dca17f6b67762919fb8486c6f931f5 and a total number of 972 components indexed
- use_cpu: False
- use_openai_api: True
- The server is starting on port: 8777
- onnxruntime 1.18.0 已经安装。
- 2024-06-28 17:34:15,469 使用openai api llama3 无需下载大模型
- Traceback (most recent call last):
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 196, in _run_module_as_main
- return _run_code(code, main_globals, None,
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 86, in _run_code
- exec(code, run_globals)
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/sanic_api.py", line 164, in <module>
- from .handler import *
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/handler.py", line 1, in <module>
- from qanything_kernel.core.local_file import LocalFile
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/core/local_file.py", line 5, in <module>
- from qanything_kernel.utils.loader.my_recursive_url_loader import MyRecursiveUrlLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/__init__.py", line 4, in <module>
- from .self_pdf_loader import PdfLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/self_pdf_loader.py", line 3, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.parser import PdfParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/__init__.py", line 3, in <module>
- from .pdf_parser import HuParser as PdfParser, PlainParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/pdf_parser.py", line 18, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.nlp import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/__init__.py", line 4, in <module>
- from . import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/huqie.py", line 4, in <module>
- import datrie
- ImportError: dlopen(/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so, 0x0002): tried: '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (no such file), '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
- (base) ➜ QAnything git:(qanything-python) ✗ bash scripts/run_for_ollama_api_in_M1_mac.sh
- 即将启动后端服务,启动成功后请复制[http://0.0.0.0:8777/qanything/]到浏览器进行测试。
- 运行qanything-server的命令是:
- CUDA_VISIBLE_DEVICES=0 python3 -m qanything_kernel.qanything_server.sanic_api --host 0.0.0.0 --port 8777 --model_size 7B --use_openai_api --openai_api_base http://localhost:11434/v1 --openai_api_key ollama --openai_api_model_name qwen2 --openai_api_context_length 4096 --workers 4
- LOCAL DATA PATH: /Users/renlibin/PythonProjects/QAnything/QANY_DB/content
- LOCAL_RERANK_REPO: maidalun/bce-reranker-base_v1
- LOCAL_EMBED_REPO: maidalun/bce-embedding-base_v1
- 2024-06-28 17:38:17,124 - modelscope - INFO - PyTorch version 2.1.2 Found.
- 2024-06-28 17:38:17,124 - modelscope - INFO - Loading ast index from /Users/renlibin/.cache/modelscope/ast_indexer
- 2024-06-28 17:38:17,150 - modelscope - INFO - Loading done! Current index file version is 1.13.0, with md5 f0dca17f6b67762919fb8486c6f931f5 and a total number of 972 components indexed
- use_cpu: False
- use_openai_api: True
- The server is starting on port: 8777
- onnxruntime 1.18.0 已经安装。
- 2024-06-28 17:38:17,274 使用openai api qwen2 无需下载大模型
- Traceback (most recent call last):
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 196, in _run_module_as_main
- return _run_code(code, main_globals, None,
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 86, in _run_code
- exec(code, run_globals)
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/sanic_api.py", line 164, in <module>
- from .handler import *
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/handler.py", line 1, in <module>
- from qanything_kernel.core.local_file import LocalFile
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/core/local_file.py", line 5, in <module>
- from qanything_kernel.utils.loader.my_recursive_url_loader import MyRecursiveUrlLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/__init__.py", line 4, in <module>
- from .self_pdf_loader import PdfLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/self_pdf_loader.py", line 3, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.parser import PdfParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/__init__.py", line 3, in <module>
- from .pdf_parser import HuParser as PdfParser, PlainParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/pdf_parser.py", line 18, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.nlp import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/__init__.py", line 4, in <module>
- from . import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/huqie.py", line 4, in <module>
- import datrie
- ImportError: dlopen(/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so, 0x0002): tried: '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (no such file), '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
- (base) ➜ QAnything git:(qanything-python) ✗ clear
- (base) ➜ QAnything git:(qanything-python) ✗ bash scripts/run_for_ollama_api_in_M1_mac.sh
- 即将启动后端服务,启动成功后请复制[http://0.0.0.0:8777/qanything/]到浏览器进行测试。
- 运行qanything-server的命令是:
- CUDA_VISIBLE_DEVICES=0 python3 -m qanything_kernel.qanything_server.sanic_api --host 0.0.0.0 --port 8777 --model_size 7B --use_openai_api --openai_api_base http://localhost:11434/v1 --openai_api_key ollama --openai_api_model_name qwen2:latest --openai_api_context_length 4096 --workers 4
- LOCAL DATA PATH: /Users/renlibin/PythonProjects/QAnything/QANY_DB/content
- LOCAL_RERANK_REPO: maidalun/bce-reranker-base_v1
- LOCAL_EMBED_REPO: maidalun/bce-embedding-base_v1
- 2024-06-28 17:38:56,804 - modelscope - INFO - PyTorch version 2.1.2 Found.
- 2024-06-28 17:38:56,804 - modelscope - INFO - Loading ast index from /Users/renlibin/.cache/modelscope/ast_indexer
- 2024-06-28 17:38:56,830 - modelscope - INFO - Loading done! Current index file version is 1.13.0, with md5 f0dca17f6b67762919fb8486c6f931f5 and a total number of 972 components indexed
- use_cpu: False
- use_openai_api: True
- The server is starting on port: 8777
- onnxruntime 1.18.0 已经安装。
- 2024-06-28 17:38:56,951 使用openai api qwen2:latest 无需下载大模型
- Traceback (most recent call last):
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 196, in _run_module_as_main
- return _run_code(code, main_globals, None,
- File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/runpy.py", line 86, in _run_code
- exec(code, run_globals)
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/sanic_api.py", line 164, in <module>
- from .handler import *
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/qanything_server/handler.py", line 1, in <module>
- from qanything_kernel.core.local_file import LocalFile
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/core/local_file.py", line 5, in <module>
- from qanything_kernel.utils.loader.my_recursive_url_loader import MyRecursiveUrlLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/__init__.py", line 4, in <module>
- from .self_pdf_loader import PdfLoader
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/self_pdf_loader.py", line 3, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.parser import PdfParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/__init__.py", line 3, in <module>
- from .pdf_parser import HuParser as PdfParser, PlainParser
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/parser/pdf_parser.py", line 18, in <module>
- from qanything_kernel.utils.loader.pdf_to_markdown.core.nlp import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/__init__.py", line 4, in <module>
- from . import huqie
- File "/Users/renlibin/PythonProjects/QAnything/qanything_kernel/utils/loader/pdf_to_markdown/core/nlp/huqie.py", line 4, in <module>
- import datrie
- ImportError: dlopen(/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so, 0x0002): tried: '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (no such file), '/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/datrie.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
由报错信息可知,启动用到的库datrie下载了个'x86_64'版本的,而我的电脑是Mac M1 arm架构的,需要的是'arm64'的库。
- # 卸载datrie库
- pip uninstall datrie
-
- # 重新安装arm架构的datrie库
- ARCHFLAGS="-arch arm64" pip install datrie --compile --no-cache-dir
解决问题参考:
重新运行,问题解决!
点击“返回对话”。问问题测试,给出了回答和信息来源,搞定。
参考:
README_zh.md · 网易有道/QAnything - Gitee.com
QAnything/README_zh.md at qanything-python · netease-youdao/QAnything · GitHub
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。