chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
31.3k stars 5.45k forks source link

UnboundLocalError: cannot access local variable 'metadata' where it is not associated with a value #4556

Closed lvjinwang closed 2 months ago

lvjinwang commented 2 months ago

问题描述 / Problem Description chatchat配置oneapi平台之后,多功能对话报错;本地测试http://127.0.0.1:7861/chat/chat/completions接口,功能是正常的;oneapi的http://127.0.0.1:3000/v1/chat/completions接口也是正常的

2024-07-17 23:49:51.950 Uncaught app exception Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 600, in _run_script exec(code, module.dict) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chatchat/webui.py", line 73, in dialogue_page(api=api, is_lite=is_lite) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chatchat/webui_pages/dialogue/dialogue.py", line 524, in dialogue_page chat_box.update_msg(text, streaming=False, metadata=metadata) ^^^^^^^^ UnboundLocalError: cannot access local variable 'metadata' where it is not associated with a value

复现问题的步骤 / Steps to Reproduce

  1. 执行 '...' / Run '...'
  2. 点击 '...' / Click '...'
  3. 滚动到 '...' / Scroll to '...'
  4. 问题出现 / Problem occurs

预期的结果 / Expected Result 描述应该出现的结果 / Describe the expected result.

实际结果 / Actual Result 描述实际发生的结果 / Describe the actual result.

环境信息 / Environment Information

liunux4odoo commented 2 months ago

你 streamlit-chatbox 版本是多少?

lvjinwang commented 2 months ago

你 streamlit-chatbox 版本是多少? 1.1.12.post4

liunux4odoo commented 2 months ago

找到原因了,你把下面这行往右缩进一下:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chatchat/webui_pages/dialogue/dialogue.py", line 524, in dialogue_page
chat_box.update_msg(text, streaming=False, metadata=metadata)

我们会尽快修复

lvjinwang commented 2 months ago

找到原因了,你把下面这行往右缩进一下:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chatchat/webui_pages/dialogue/dialogue.py", line 524, in dialogue_page
chat_box.update_msg(text, streaming=False, metadata=metadata)

我们会尽快修复

我昨晚就缩进了,但是没有用诶

lvjinwang commented 2 months ago

找到原因了,你把下面这行往右缩进一下:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/chatchat/webui_pages/dialogue/dialogue.py", line 524, in dialogue_page
chat_box.update_msg(text, streaming=False, metadata=metadata)

我们会尽快修复

缩进之后,chatchat服务不报错,但是oneapi报错这个 [ERR] 2024/07/18 - 11:55:21 | 2024071811552167157500086965007 | relay error (channel id 5, user id: 1): Could not find acceptable representation

lvjinwang commented 2 months ago

多功能对话和 rag 对话,oneapi 都会报这个错,我这边用的是智谱清言渠道

liunux4odoo commented 2 months ago

看起来是模型访问有问题。

lvjinwang commented 2 months ago

看起来是模型访问有问题。

大佬,我在oneapi看了下chatchat的调用curl,发现curl里面有设置 -H 'Accept: application/json',这样的话,就不能stream调用了吧,一直会报错,我把curl粘贴出来之后,把这个header去掉,用post就能调通oneapi了

lvjinwang commented 2 months ago

看起来是模型访问有问题。

我在oneapi的func RelayTextHelper(c gin.Context) model.ErrorWithStatusCode { command, _ := http2curl.GetCurlCommand(c.Request) logger.Infof(c, "RelayTextHelper curl: \n%s", command.String())

c.Request.Header.Set("Accept", "*/*")

这个位置,设置了header,chatchat的多功能对话可以正常使用了

liunux4odoo commented 2 months ago

那看起来这是 oneapi 的问题啊,其它模型平台没有这个问题。