chatgpt-mirai-qq-bot icon indicating copy to clipboard operation
chatgpt-mirai-qq-bot copied to clipboard

[BUG] ChatGLM3-6B无法通过本项目OpenAi方式调用,且也无法使用ChatGLM-6B的调用格式调用

Open YChaiyi opened this issue 1 year ago • 2 comments

提交 issue 前,请先确认:

  • [x] 我已看过 FAQ,此问题不在列表中
  • [x] 我已看过其他 issue,他们不能解决我的问题
  • [x] 我认为这不是 Mirai 或者 OpenAI 的 BUG

表现
在确定ChatGLM-3-6B接口能通过OpenAi调用格式正常调用的情况下,无法通过本项目正常调用,在Webui中配置如下 屏幕截图(42) 保存配置后本项目后台报错:2024-01-01 15:22:24.955 | ERROR | framework.accounts.manager:login_account:59 - [AccountManager] 登录失败: openai-api 保存配置后GLM后台报错:INFO: 192.168.1.26:62926 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request

运行环境:

  • 操作系统:Windows 10
  • Docker: 无
  • 项目版本: v3.0.0-alpha2

复现步骤
描述你是如何触发这个 BUG 的

  1. Go to 'http://127.0.0.1:8080/#/accounts'
  2. Click on 'OpenAI API 账号设置、配置设置'
  3. See error

预期行为
本项目显示:账户正常 GLM输出:INFO: 127.0.0.1:58586 - "POST /v1/chat/completions HTTP/1.1" 200 OK

截图
屏幕截图(42) botpy.log

其他内容
此处填写其他内容,没有可跳过

YChaiyi avatar Jan 01 '24 07:01 YChaiyi

附上ChatGLM3-6B官方API调用方式:https://github.com/THUDM/ChatGLM3/blob/main/openai_api_demo/openai_api_request.py

YChaiyi avatar Jan 01 '24 07:01 YChaiyi

因为glm3的数据结构变了,所以需要根据数据结构修改framework\llm\thudm\chatglm_6b.py的async def ask(self, prompt: str)方法,将请求和响应按glm3的格式修改,在ask里面打印response就可以知道响应格式,在chatglm3 api demo的api_server.py里参考ChatCompletionRequest修改ask的请求格式即可

inorixu avatar May 20 '24 03:05 inorixu