Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

百炼 通义千问tool_calls不适配问题 #1936

Open
5 tasks done
fanmingfei opened this issue Nov 20, 2024 · 1 comment
Open
5 tasks done

百炼 通义千问tool_calls不适配问题 #1936

fanmingfei opened this issue Nov 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fanmingfei
Copy link

fanmingfei commented Nov 20, 2024

例行检查

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,尤其是常见问题部分
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

问题描述
错误信息:
'<400> InternalError.Algo.InvalidParameter: messages with role "tool" must be a response to a preceeding message with "tool_calls".',

直接调用通义千问的api没问题,调用oneapi报错

复现步骤

import OpenAI from "openai";
const openai = new OpenAI({
  // baseURL: 'http://localhost:3001/v1', // 报错
  // apiKey: "sk-fastgpt",
  baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1', //没问题
});

const response = await openai.chat.completions.create({
  model: 'qwen-turbo',
  temperature: undefined,
  max_tokens: Infinity,
  stream: false,
  messages: [
    {
      "role": "user",
      "content": "小明的年龄"
    },
    {
      "role": "assistant",
      "content": "",
      "tool_calls": [
        {
          "id": "oihVoPf6LWRt",
          "type": "function",
          "function": {
            "name": "uVmL4L",
            "arguments": "{\"username\": \"小明\"}"
          }
        }
      ]
    },
    {
      tool_call_id: 'oihVoPf6LWRt',
      role: 'tool',
      name: 'uVmL4L',
      content: '{\n  "result": {\n    "age": 11\n  }\n}'
    }
  ],
  tools: [{
    type: 'function',
    function: {
      "name": "uVmL4L",
      "description": "Sends a GET request with a username query parameter to retrieve the age.",
      "parameters": {
        "type": "object", "properties": { "username": { "type": "string", "description": "The username to look up.", "enum": [] } },
        "required": ["username"]
      }
    }
  }],
  tool_choice: 'auto'
}
);

console.log(JSON.stringify(response.choices[0].message,'',2));
@fanmingfei fanmingfei added the bug Something isn't working label Nov 20, 2024
@fanmingfei fanmingfei changed the title 文心一言tool_calls不适配问题 通义千问tool_calls不适配问题 Nov 20, 2024
@fanmingfei fanmingfei changed the title 通义千问tool_calls不适配问题 百炼 通义千问tool_calls不适配问题 Nov 20, 2024
@fxyyds
Copy link

fxyyds commented Nov 26, 2024

我也是这个问题,你是用的0.6几版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants