CodeFuse-muAgent icon indicating copy to clipboard operation
CodeFuse-muAgent copied to clipboard

if all_embeddings[0].dtype == torch.bfloat16: IndexError: list index out of range

Open yuyaxiong opened this issue 1 year ago • 12 comments

Is there any emb model to suggestion for running the demo? if u can offer hf download path would be very nice. my error is this

Traceback (most recent call last):
  File "/data/yuyaxiong/project/demo/demo.py", line 53, in <module>
    cbh.import_code(do_interpret=do_interpret)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/muagent/codechat/codebase_handler/codebase_handler.py", line 100, in import_code
    code_importer.import_code(static_analysis_res, interpretation, do_interpret=do_interpret)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/muagent/codechat/codebase_handler/code_importer.py", line 43, in import_code
    self.interpretation_to_db(static_analysis_res, interpretation, do_interpret)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/muagent/codechat/codebase_handler/code_importer.py", line 141, in interpretation_to_db
    emb = get_embedding(engine=self.embed_config.embed_engine, text_list=interp_list, model_path=self.embed_config.embed_model_path, embedding_device= self.embed_config.model_device, embed_config=self.embed_config)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/muagent/llm_models/get_embedding.py", line 39, in get_embedding
    emb_res = hfe.get_emb(text_list)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/muagent/llm_models/huggingface_embedding.py", line 36, in get_emb
    emb_res = self.model.embed_documents(text_list)
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/langchain_huggingface/embeddings/huggingface.py", line 87, in embed_documents
    embeddings = self.client.encode(
  File "/home/yuyaxiong/anaconda3/envs/mu_agent/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py", line 565, in encode
    if all_embeddings[0].dtype == torch.bfloat16:
IndexError: list index out of range

yuyaxiong avatar Sep 04 '24 10:09 yuyaxiong

same problem

ccly1996 avatar Sep 06 '24 02:09 ccly1996

Sorry, I've just gotten around to this now as I was dealing with matters related to the waitang meetings last week.

could you give your examles codes or tell me which example you try?

lightislost avatar Sep 11 '24 07:09 lightislost

Sorry, I've just gotten around to this now as I was dealing with matters related to the waitang meetings last week.对不起,我现在才开始讨论这个问题,因为我上周正在处理与 waitang 会议有关的事情。

could you give your examles codes or tell me which example you try?您能提供您的 Examles 代码或告诉我您尝试的是哪个示例吗?

我使用的是examples/muagent_examples/codechat_example.py这个示例

ccly1996 avatar Sep 18 '24 01:09 ccly1996

# 准备conda环境
conda create -n muagent python=3.9

# 0.0.5
pip install codefuse-muagent
# 配置你的test_config.py

import os, openai, base64
from loguru import logger

#
OPENAI_API_BASE = "https://api.openai.com/v1"
os.environ["API_BASE_URL"] = OPENAI_API_BASE
os.environ["OPENAI_API_KEY"] = "sk-xxx"
openai.api_key = "sk-xxx"
os.environ["model_name"] = "gpt-3.5-turbo"
os.environ["model_engine] = "openai"

# 示例
os.environ["embed_model"] = "text2vec-base-chinese"
os.environ["embed_model_path"] = "~/thomas/text2vec-base-chinese"
# 进入文件夹
cd examples/muagent_examples
# 执行代码
python codechat_example.py

按照这个方式是能正常运行的。你看看在配置层面有其他差异么?

lightislost avatar Sep 29 '24 03:09 lightislost

如果没有其他问题,将在下午6点关闭;后续有问题可重新打开

lightislost avatar Oct 09 '24 02:10 lightislost

目前运行的时候没法解析代码文件,显示 image 然后下面会报错 image

ccly1996 avatar Oct 10 '24 02:10 ccly1996

这是 notebook 没启动起来,在~/codefuse-muagent/sandbox/pycodebox.py#337 有一条debug日志,可以去掉屏蔽,重新执行确认下未启动原因。这块儿jupyter写的比较早,后面jupyter官方出了一个sdk。后面会切换成新的

lightislost avatar Oct 10 '24 02:10 lightislost

python codechat_example.py

2024-10-10 11:40:10.046 | DEBUG | muagent.sandbox.pycodebox:start:337 - Traceback (most recent call last):

2024-10-10 11:40:10.047 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/bin/jupyter-notebook", line 7, in

2024-10-10 11:40:10.048 | DEBUG | muagent.sandbox.pycodebox:start:337 - from notebook.notebookapp import main

2024-10-10 11:40:10.048 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 79, in

2024-10-10 11:40:10.048 | DEBUG | muagent.sandbox.pycodebox:start:337 - from .services.contents.manager import ContentsManager

2024-10-10 11:40:10.048 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/notebook/services/contents/manager.py", line 17, in

2024-10-10 11:40:10.049 | DEBUG | muagent.sandbox.pycodebox:start:337 - from nbformat import sign, validate as validate_nb, ValidationError

2024-10-10 11:40:10.049 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/nbformat/init.py", line 11, in

2024-10-10 11:40:10.049 | DEBUG | muagent.sandbox.pycodebox:start:337 - from . import v1, v2, v3, v4

2024-10-10 11:40:10.049 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/nbformat/v4/init.py", line 39, in

2024-10-10 11:40:10.050 | DEBUG | muagent.sandbox.pycodebox:start:337 - from .convert import downgrade, upgrade

2024-10-10 11:40:10.050 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/nbformat/v4/convert.py", line 13, in

2024-10-10 11:40:10.050 | DEBUG | muagent.sandbox.pycodebox:start:337 - from .. import validator

2024-10-10 11:40:10.050 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/nbformat/validator.py", line 15, in

2024-10-10 11:40:10.051 | DEBUG | muagent.sandbox.pycodebox:start:337 - from .json_compat import ValidationError, _validator_for_name, get_current_validator

2024-10-10 11:40:10.051 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/nbformat/json_compat.py", line 11, in

2024-10-10 11:40:10.051 | DEBUG | muagent.sandbox.pycodebox:start:337 - import jsonschema

2024-10-10 11:40:10.051 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/jsonschema/init.py", line 13, in

2024-10-10 11:40:10.052 | DEBUG | muagent.sandbox.pycodebox:start:337 - from jsonschema._format import FormatChecker

2024-10-10 11:40:10.052 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/jsonschema/_format.py", line 11, in

2024-10-10 11:40:10.052 | DEBUG | muagent.sandbox.pycodebox:start:337 - from jsonschema.exceptions import FormatError

2024-10-10 11:40:10.052 | DEBUG | muagent.sandbox.pycodebox:start:337 - File "/home/lvyue/anaconda3/lib/python3.9/site-packages/jsonschema/exceptions.py", line 14, in

2024-10-10 11:40:10.053 | DEBUG | muagent.sandbox.pycodebox:start:337 - from attrs import define

2024-10-10 11:40:10.053 | DEBUG | muagent.sandbox.pycodebox:start:337 - ModuleNotFoundError: No module named 'attrs'

2024-10-10 11:40:10.089 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.090 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.090 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.091 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.091 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.091 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.091 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.092 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.092 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.092 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.092 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.093 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.093 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.093 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.093 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.094 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.094 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.094 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.094 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.094 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.095 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.095 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.095 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.095 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.096 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.096 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.096 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.096 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.097 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.097 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.097 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.097 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.098 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.098 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.098 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.098 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.098 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.099 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.099 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.099 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.099 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.100 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.100 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.100 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.100 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.101 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.101 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.101 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.101 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.102 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.102 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.102 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.102 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.102 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.103 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.103 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.103 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.103 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.104 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.104 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.104 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.104 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.105 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.105 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.105 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.105 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.106 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.107 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.107 | DEBUG | muagent.sandbox.pycodebox:start:337 - 2024-10-10 11:40:10.107 | DEBUG | muagent.sandbox.pycodebox:start:337 - Traceback (most recent call last): File "/data/ly/CodeFuse-muAgent/examples/muagent_examples/codechat_example.py", line 78, in phase = BasePhase( File "/home/lvyue/anaconda3/envs/muagent/lib/python3.9/site-packages/muagent/connector/phase/base_phase.py", line 75, in init self.message_utils = MessageUtils(None, sandbox_server, jupyter_work_path, embed_config, llm_config, kb_root_path, doc_retrieval, code_retrieval, search_retrieval, log_verbose) File "/home/lvyue/anaconda3/envs/muagent/lib/python3.9/site-packages/muagent/connector/message_process.py", line 43, in init self.codebox = PyCodeBox( File "/home/lvyue/anaconda3/envs/muagent/lib/python3.9/site-packages/muagent/sandbox/pycodebox.py", line 35, in init self.start() File "/home/lvyue/anaconda3/envs/muagent/lib/python3.9/site-packages/muagent/sandbox/pycodebox.py", line 344, in start self._check_connect_success() File "/home/lvyue/anaconda3/envs/muagent/lib/python3.9/site-packages/muagent/sandbox/pycodebox.py", line 275, in _check_connect_success raise BaseException(f"can't connect to {self.remote_url}") BaseException: can't connect to http://127.0.0.1:5050 Close connection to 127.0.0.1:9669 failed:'NoneType' object has no attribute 'close'找到了,这个是报错日志

ccly1996 avatar Oct 10 '24 03:10 ccly1996

无法复现你的错误

# 可以确认下notebook版本
pip list|grep notebook
> notebook                                 7.2.2
> notebook_shim                            0.2.4
# 确认能否启动notebook服务
jupyter-notebook --NotebookApp.token=mytoken --port=5050 --ServerApp.disable_check_xsrf=True

lightislost avatar Oct 10 '24 06:10 lightislost

image jupyter可以启动,版本也跟上述相同,但是运行codechat_example.py又报了这个错误 image

安装了faiss-cpu和faiss-gpu也不行

ccly1996 avatar Oct 10 '24 07:10 ccly1996

1、sandbox可以看下 ~CodeFuse-muAgent/tests/sandbox/sandbox_test.py 这个测例看看能不能跑通

2、faiss版本

pip list|grep faiss
> faiss-cpu                                1.8.0.post1

3、确认下python版本,

python --version
> Python 3.9.19

lightislost avatar Oct 11 '24 06:10 lightislost

1、sandbox可以看下 ~CodeFuse-muAgent/tests/sandbox/sandbox_test.py 这个测例看看能不能跑通

2、faiss版本

pip list|grep faiss
> faiss-cpu                                1.8.0.post1

3、确认下python版本,

python --version
> Python 3.9.19

安装faiss-cpu 1.8.0.post1后执行没有在报错,但是卡在这里没有响应 image 运行tests/sandbox/sandbox_test.py后显示如下 image

ccly1996 avatar Oct 11 '24 09:10 ccly1996

说明sandbox是的正常了。后面那些都不像是报错信息,卡住应该是其他问题,可以自己debug下,提供更多信息

lightislost avatar Oct 14 '24 11:10 lightislost

说明sandbox是的正常了。后面那些都不像是报错信息,卡住应该是其他问题,可以自己debug下,提供更多信息

我debug了一下,发现报了一个这个错误 image

模型配置是 OPENAI_API_BASE = "http://localhost:9997/v1" os.environ["API_BASE_URL"] = OPENAI_API_BASE os.environ["OPENAI_API_KEY"] = "sk-xxx" openai.api_key = "sk-xxx" os.environ["model_name"] = "gpt-4-32k" os.environ["model_engine"] = "openai" 这个地址我测试可以使用,但是这里就会报错

ccly1996 avatar Oct 16 '24 06:10 ccly1996