已关闭
[Usage]: mindie的 openai 接口兼容性问题 #202
liangwei2010创建于  2月6日关闭于  3月22日
liangwei2010
liangwei2010
2月6日 创建

在提交新问题之前,请确保您已经在社区中搜索过相关问题,并使用了社区中提供的资源/工具后,仍未找到满意的解决方式。

环境信息

- 操作系统:
- 昇腾硬件信息:910B2 64G
- CANN软件版本
- 安装的对应软件版本:2.3.0-800I-A2-py311-openeuler24.03-lts (官方镜像)

使用场景及问题

mindie 部署了 qwen3-32b,使用 openai 接口调用,content采用数组传多段内容会报错,mindie目前content 只支持使用多模态时使用数组,不支持纯文本时使用数组。
{"error":"Messages token length must be in (0, 1048576], but got 0","error_type":"Input Validation Error"}
image.png
openai官方的接口规范,vllm、sglang 等主流推理引擎都是支持,建议mindie 保持和 openai 接口一致。
需求价值:
1.提供与 openai 完全兼容的接口,这样接入更方便
2.很多前端应用都是使用 openai 兼容的接口调用的,当使用 mindie 发现不兼容,需要做很多前端应用的改造成本过大

欢迎加入社区,感谢您对社区的贡献 🎉!

likedislike
ascend-robotascend-robot成员
2月6日 添加了label:usage
liangwei2010
liangwei2010
3月5日 评论:

这个问题有排期吗?
claude这些工具都无法使用 mindie 启动的模型,希望能尽快排期,与 openai、vllm 等接口保持兼容

likedislike
吴铭泾
吴铭泾成员
3月9日 评论:

当前需求已排至Q2版本,敬请期待~

likedislike
吴铭泾吴铭泾成员
3月9日 issue状态由 TODO 改变为 ACCEPTED
LinWei100
LinWei100
3月9日 评论:

mindie 部署了 qwen3-32b,使用 openai 接口调用,content采用数组传多段内容会报错,mindie目前content 只支持使用多模态时使用数组,不支持纯文本时使用数组。
{"error":"Messages token length must be in (0, 1048576], but got 0","error_type":"Input Validation Error"}

@liangwei2010

您好,可以留一个完整的请求报文吗,截图中的content被截断了。

likedislike
liangwei2010
liangwei2010
3月10日 评论:

@LinWei100

curl -ki https://xxx/v1/chat/completions \
    -X POST \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer xxx" \
    -d '{
        "model": "qwq-32b",
        "max_tokens": 1024,
        "stream": "true",
        "messages": [{
          "role": "system",
          "content": [
          {
            "type":"text",
            "text":"你是一个智能 AI 助手"
          }
          ]
        },
        {
          "role": "user",
          "content": "你是谁"
        }
        ]
      }'

openai官方接口文档:https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create
vllm兼容 openai 接口文档:https://docs.vllm.ai/en/latest/serving/openai_compatible_server/#chat-template

likedislike
LinWei100
LinWei100
3月11日 评论:

怀疑您此前使用的请求体可能存在某些错误导致该异常。
我们使用下列请求在环境上使用 2.3版本搭配qwen3-32B 可以正常返回,没有复现异常返回。

curl -X POST http://localhost:1025/v1/chat/completions     -H "Content-Type: application/json"     -d '{
    "model": "qwen",
    "messages": [
        {
            "role": "system",
            "content": [
                {
                    "type": "text",
                    "text": "Analyze if this message indicates a new conversation topic. If it does, extract a 2-3[boolean) and 'title' (string, or null if isNewTopic is false). only include these fields, no other text"
                }
            ]
        },
        {
            "role": "user",
            "content": "hello"
        }
    ],
    "stream": false,
    "max_tokens": 100,
    "chat_template_kwargs": {
        "enable_thinking": true
    }
}'

响应内容如下

{"id":"endpoint_common_2","object":"chat.completion","created":1773043401,"model":"qwen","choices":[{"index":0,"message":{"role":"assistant","content":"<think>\nOkay, let's see. The user sent \"hello\". I need to determine if this is a new conversation topic.\n\nFirst, \"hello\" is a greeting. Usually, when someone starts a conversation with a greeting, it's the beginning of a new topic. There's no prior context mentioned here. The message is short and doesn't reference any previous discussions. So, it's likely the start of a new conversation. The title could be something generic like \"Greeting\" or \"","tool_calls":[]},"logprobs":null,"finish_reason":"length"}],"usage":{"prompt_tokens":59,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens":100,"completion_tokens_details":{"reasoning_tokens":0},"total_tokens":159,"batch_size":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"queue_wait_time":[6214,1055,240,434,438,512,65,409,126,456,459,359,419,773,253,466,469,468,415,472,352,403,374,197,408,80,300,292,1038,206,509,260,533,454,434,336,159,376,471,441,429,463,448,467,359,359,473,415,354,540,380,89,447,467,431,400,566,514,534,417,388,699,547,469,554,516,504,473,462,509,486,168,225,161,199,174,73,89,171,213,94,155,245,192,255,234,250,259,255,200,263,386,462,451,550,538,504,476,485,507]},"prefill_time":74,"decode_time_arr":[41,24,24,24,24,23,24,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,23,24,24,24,24,24,26,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,24,24,24,24,24,24,24,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24]}
likedislike
吴铭泾
吴铭泾成员
3月22日 评论:

该ISSUE已有开发者回复。如果您还有别的问题,欢迎登录论坛:https://www.hiascend.com/forum/,该ISSUE建议关闭并移至论坛发起更多的讨论~~

likedislike
吴铭泾吴铭泾成员
3月22日 issue状态由 ACCEPTED 改变为 DONE
吴铭泾吴铭泾成员
3月22日 关闭了 issue