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.67k stars 5.52k forks source link

[BUG] qwen2.5在WEBUI中可以正常调用,通过api调用返回不支持tools call / It works in WEBUI when using the model 'qwen2.5', but an error occurred in api call, it return "only [xxx] support tool calls" #5006

Open mttbyte opened 1 week ago

mttbyte commented 1 week ago

问题描述 在xinference里我切换了模型为qwen2.5-instruct的7b模型,在WEBUI中可以正常使用,但是通过api访问时返回{'detail': "Only ['qwen1.5-chat', 'qwen1.5-moe-chat', 'qwen2-instruct', 'qwen2-moe-instruct', 'glm4-chat', 'glm4-chat-1m'] support tool calls"}

复现问题的步骤

  1. 在xinference里用vllm加载qwen2.5-instruct-7b
  2. 相同代码调用api中的/chat/chat/completions 3.无返回,查看窗口提示 openai.BadRequestError: Error code: 400 - {'detail': "Only ['qwen1.5-chat', 'qwen1.5-moe-chat', 'qwen2-instruct', 'qwen2-moe-instruct', 'glm4-chat', 'glm4-chat-1m'] support tool calls"}

预期的结果 和前端一样正确返回

实际结果 INFO: 127.0.0.1:59766 - "POST /chat/chat/completions HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi result = await app( # type: ignore[func-returns-value] File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in call return await self.app(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/routing.py", line 758, in call await self.middleware_stack(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/routing.py", line 778, in app await route.handle(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle await self.app(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/routing.py", line 79, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/starlette/routing.py", line 74, in app response = await func(request) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/fastapi/routing.py", line 299, in app raise e File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/chatchat/server/api_server/chat_routes.py", line 208, in chat_completions return await openai_request( File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/chatchat/server/api_server/openai_routes.py", line 115, in openai_request result = await method(params) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/openai/resources/chat/completions.py", line 1295, in create return await self._post( File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/openai/_base_client.py", line 1826, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/openai/_base_client.py", line 1519, in request return await self._request( File "/home/sutai/miniconda3/envs/langchain/lib/python3.10/site-packages/openai/_base_client.py", line 1620, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'detail': "Only ['qwen1.5-chat', 'qwen1.5-moe-chat', 'qwen2-instruct', 'qwen2-moe-instruct', 'glm4-chat', 'glm4-chat-1m'] support tool calls"}

环境信息

附加信息 1.发送的json内容: Id: 0 User: Euler Timeout: 600 MaxTokens: 4096 Messages: [{你是人工智能助手 system system} {测试 user Euler}] Stream: false Model: qwen2.5-instruct Temperature: 0.7 TopP: 0.8 RepetitionPenalty: 1.05 Flag: 0 Tools: []

2.曾经代码正确执行过,原因未知

mttbyte commented 6 days ago

目前使用自定义模型定义qwen2base以加载qwen2.5,但agent结果和直接qwen2.5有偏差

wangsiyu666 commented 6 days ago

更新xinference,并重新启动xinference。

mttbyte commented 6 days ago

更新xinference,并重新启动xinference。

成功了,多谢,为何问题居然是出现在xinference里……