modelscope / agentscope

Start building LLM-empowered multi-agent applications in an easier way.
https://doc.agentscope.io/
Apache License 2.0
4.86k stars 297 forks source link

rag_example.py中运行遇到的问题 #312

Closed PopRang closed 3 months ago

PopRang commented 3 months ago
image

请问怎么解决呢

FredericW commented 3 months ago

Please double-check if the sphinx packages are well installed.

PopRang commented 3 months ago

请仔细检查 sphinx 包是否已正确安装。

我使用pip install sphinx安装的,需要指定哪个版本吗 正在运行 Sphinx v7.3.7

Extension error: 无法导入扩展 sphinxcontrib.mermaid (exception: No module named 'sphinxcontrib.mermaid') 后续还是上面那个报错

FredericW commented 3 months ago

sphinx 7.7.3 should work. Regarding your issue, please try "pip install sphinxcontrib-mermaid"

PopRang commented 3 months ago

sphinx 7.7.3 should work. Regarding your issue, please try "pip install sphinxcontrib-mermaid" sphinx最新是v7.3.7吧?升级7.7.3告知我没有这个版本 关于sphinx的依赖都安装好了,现在启动没有关于无法导入扩展之类的错误。但是还是出现了 python rag_example.py 2024-06-21 18:02:46.599 | INFO | agentscope.models:read_model_configs:186 - Load configs for model wrapper: qwen_emb_config, qwen_config 2024-06-21 18:02:46.604 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_config] 2024-06-21 18:02:46.605 | INFO | agentscope.utils.monitor:register:417 - Register metric [qwen-max.call_counter] to SqliteMonitor with unit [times] and quota [None] 2024-06-21 18:02:46.607 | INFO | agentscope.utils.monitor:register:417 - Register metric [qwen-max.prompt_tokens] to SqliteMonitor with unit [token] and quota [None] 2024-06-21 18:02:46.609 | INFO | agentscope.utils.monitor:register:417 - Register metric [qwen-max.completion_tokens] to SqliteMonitor with unit [token] and quota [None] 2024-06-21 18:02:46.610 | INFO | agentscope.utils.monitor:register:417 - Register metric [qwen-max.total_tokens] to SqliteMonitor with unit [token] and quota [None] 2024-06-21 18:02:46.612 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_config] 2024-06-21 18:02:46.613 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_config] 2024-06-21 18:02:46.615 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_config] 2024-06-21 18:02:46.616 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_config] 2024-06-21 18:02:46.617 | INFO | agentscope.rag.knowledge_bank:init:48 - Loading configs from configs/knowledge_config.json bank {'knowledge_id': 'agentscope_code_rag', 'emb_model_config_name': 'qwen_emb_config', 'chunk_size': 2048, 'chunk_overlap': 40, 'data_processing': [{'load_data': {'loader': {'create_object': True, 'module': 'llama_index.core', 'class': 'SimpleDirectoryReader', 'init_args': {'input_dir': '../../src/agentscope', 'recursive': True, 'required_exts': ['.py']}}}, 'store_and_index': {'transformations': [{'create_object': True, 'module': 'llama_index.core.node_parser', 'class': 'CodeSplitter', 'init_args': {'language': 'python', 'chunk_lines': 100}}]}}]} 2024-06-21 18:02:46.618 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_emb_config] 2024-06-21 18:02:46.618 | INFO | agentscope.utils.monitor:register:417 - Register metric [text-embedding-v2.call_counter] to SqliteMonitor with unit [times] and quota [None] 2024-06-21 18:02:46.620 | INFO | agentscope.utils.monitor:register:417 - Register metric [text-embedding-v2.total_tokens] to SqliteMonitor with unit [token] and quota [None] bank {'knowledge_id': 'agentscope_api_rag', 'emb_model_config_name': 'qwen_emb_config', 'chunk_size': 1024, 'chunk_overlap': 40, 'data_processing': [{'load_data': {'loader': {'create_object': True, 'module': 'llama_index.core', 'class': 'SimpleDirectoryReader', 'init_args': {'input_dir': '../../docs/docstring_html/', 'required_exts': ['.html']}}}}]} 2024-06-21 18:02:58.610 | INFO | agentscope.rag.llama_index_knowledge:_load_index:263 - index loaded from /Users/wr/Documents/字节/agentscope/examples/conversation_with_RAG_agents/runs/agentscope_code_rag 2024-06-21 18:02:58.610 | INFO | agentscope.rag.llama_index_knowledge:_get_retriever:445 - similarity_top_k=5 2024-06-21 18:02:58.610 | INFO | agentscope.rag.llama_index_knowledge:_get_retriever:453 - retriever is ready. 2024-06-21 18:02:58.611 | INFO | agentscope.rag.llama_index_knowledge:_init_rag:245 - RAG with knowledge ids: agentscope_code_rag initialization completed!

2024-06-21 18:02:58.611 | INFO | agentscope.rag.knowledge_bank:add_data_as_knowledge:131 - data loaded for knowledge_id = agentscope_code_rag. 2024-06-21 18:02:58.620 | INFO | agentscope.models.model:init:201 - Initialize model by configuration [qwen_emb_config] 2024-06-21 18:02:58.622 | INFO | agentscope.rag.knowledge:_prepare_args_from_config:131 - load and build object: SimpleDirectoryReader Traceback (most recent call last): File "/Users/wr/Documents/字节/agentscope/examples/conversation_with_RAG_agents/rag_example.py", line 148, in main() File "/Users/wr/Documents/字节/agentscope/examples/conversation_with_RAG_agents/rag_example.py", line 70, in main knowledge_bank = KnowledgeBank(configs="configs/knowledge_config.json") File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/knowledge_bank.py", line 54, in init self._init_knowledge() File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/knowledge_bank.py", line 60, in _init_knowledge self.add_data_as_knowledge( File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/knowledge_bank.py", line 123, in add_data_as_knowledge self.stored_knowledge[knowledge_id] = LlamaIndexKnowledge( File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/llama_index_knowledge.py", line 222, in init self._init_rag() File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/llama_index_knowledge.py", line 243, in _init_rag self._data_to_index() File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/llama_index_knowledge.py", line 281, in _data_to_index documents = self._data_to_docs(config=config) File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/llama_index_knowledge.py", line 323, in _data_to_docs loader = self._set_loader(config=config).get("loader") File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/llama_index_knowledge.py", line 377, in _set_loader loader = self._prepare_args_from_config( File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/knowledge.py", line 154, in _prepare_args_from_config prepared_args[key] = self._prepare_args_from_config(value) File "/Users/wr/Documents/字节/agentscope/src/agentscope/rag/knowledge.py", line 134, in _prepare_args_from_config return cur_class(**init_args) File "/opt/miniconda3/envs/agentscope_new/lib/python3.9/site-packages/llama_index/core/readers/file/base.py", line 263, in init self.input_files = self._add_files(self.input_dir) File "/opt/miniconda3/envs/agentscope_new/lib/python3.9/site-packages/llama_index/core/readers/file/base.py", line 345, in _add_files raise ValueError(f"No files found in {input_dir}.") ValueError: No files found in ../../docs/docstring_html.

PopRang commented 3 months ago

conda list | grep sphinx

sphinx 7.3.7 pypi_0 pypi sphinx-rtd-theme 2.0.0 pypi_0 pypi sphinxcontrib-applehelp 1.0.8 pypi_0 pypi sphinxcontrib-devhelp 1.0.6 pypi_0 pypi sphinxcontrib-htmlhelp 2.0.5 pypi_0 pypi sphinxcontrib-jquery 4.1 pypi_0 pypi sphinxcontrib-jsmath 1.0.1 pypi_0 pypi sphinxcontrib-mermaid 0.9.2 pypi_0 pypi sphinxcontrib-qthelp 1.0.7 pypi_0 pypi sphinxcontrib-serializinghtml 1.1.10 pypi_0 pypi

pan-x-c commented 3 months ago

两种可能的解决方案:

  1. 去掉运行路径中的中文字符
  2. 卸载当前环境中的 agentscope 以及 sphinx 并以 pip install -e .[full] 形式重新安装 agentscope
PopRang commented 3 months ago

感谢,解决了这个问题,谢谢两位老师