MartialBE / one-hub

OpenAI 接口管理 & 分发系统,改自songquanpeng/one-api。支持更多模型,加入统计页面,完善非openai模型的函数调用。
https://one-api-martialbe.vercel.app/
Apache License 2.0
996 stars 197 forks source link

cohere api 不支持 steam 模式 #319

Closed ssfun closed 1 month ago

ssfun commented 1 month ago

例行检查

问题描述 steam 设为 true 时,无法获取正确结果 复现步骤

curl -X POST https://url/v1/chat/completions \
     -H 'Authorization: Bearer sk-key' \
     -H "Content-Type: application/json" \
     -d '{
           "temperature":0.5,
           "model": "command-r-plus",
           "messages": [
             {"role": "system", "content": "小助手"},
             {"role": "user", "content": "回复Hi!"}
           ],
           "stream": true
         }'

得到的结果:

data: [DONE]

stream 设为 false 时,有正确返回

curl -X POST https://url/api/v1/chat/completions \
     -H 'Authorization: Bearer sk-key' \
     -H "Content-Type: application/json" \
     -d '{
           "temperature":0.5,
           "model": "command-r-plus",
           "messages": [
             {"role": "system", "content": "小助手"},
             {"role": "user", "content": "回复Hi!"}
           ],
           "stream": false
         }'

返回结果:

{
    "id":"cc3efeac-a5be-4c82-8306-926c90e5b935",
    "object":"chat.completion",
    "created":1721809537,
    "model":"command-r-plus",
    "choices":[
        {
            "index":0,
            "message":{"role":"assistant","content":"你好!有什么可以帮到你的吗?"},
            "finish_reason":"stop"
        }
    ],
    "usage":
        {
            "prompt_tokens":6,
            "completion_tokens":11,
            "total_tokens":17
        }
}

预期结果 希望优化支持 cohere 的 steam 模式

MartialBE commented 1 month ago

已修复

ssfun commented 1 month ago

最新代码构建版本确认修复,非常感谢!!!