songquanpeng / one-api

OpenAI 接口管理 & 分发系统,支持 Azure、Anthropic Claude、Google PaLM 2 & Gemini、智谱 ChatGLM、百度文心一言、讯飞星火认知、阿里通义千问、360 智脑以及腾讯混元,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用. OpenAI key management & redistribution system, using a single API for all LLMs, and features an English UI.
https://openai.justsong.cn/
MIT License
18.22k stars 4.12k forks source link

Missing tool_call_id #1572

Closed BrandonStudio closed 3 months ago

BrandonStudio commented 3 months ago

例行检查

问题描述 请求到one-api的messages里面的tool_call_id再次发出时会被删除

复现步骤 使用插件进行多轮交互, Q: 现在几点? A: 调用插件 T: 返回插件结果(本步少tool_call_id) A: 生成响应(本步报错)

预期结果 messages按原样传递给上游Azure

相关截图 原始请求(到one-api的) image 实际请求(one-api到上游的)

{
  "messages": [
    {
      "role": "system",
      "content": "## Tools\n\nYou can use these tools below:\n\n### Current Time Assistant\n\nA plugin to provide current time information\n\nThe APIs you can use:\n\n#### current-datetime-assistant____getCurrentTime\n\n获取当前时间,格式为年-月-日 时:分:秒,并记住这个时间作为系统时间"
    },
    {
      "role": "user",
      "content": "你好,现在几点?"
    },
    {
      "role": "assistant",
      "content": "",
      "tool_calls": [
        {
          "id": "call_IQxu32ZXQjnbsfTq1tS4py7R",
          "type": "function",
          "function": {
            "name": "current-datetime-assistant____getCurrentTime",
            "arguments": "{\"asktime\":\"现在的时间\",\"timezone\":\"Asia/Shanghai\"}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "content": "{\"currentTime\":\"2024-06-27T11:41:06.849+08:00\",\"dayOfWeek\":\"Thursday\"}",
      "name": "current-datetime-assistant____getCurrentTime"
    }
  ],
  "model": "gpt-4o-global",
  "stream": true,
  "temperature": 0.6,
  "top_p": 1,
  "tools": [
    {
      "type": "function",
      "function": {
        "description": "获取当前时间,格式为年-月-日 时:分:秒,并记住这个时间作为系统时间",
        "name": "current-datetime-assistant____getCurrentTime",
        "parameters": {
          "properties": {
            "asktime": {
              "description": "发起当前日期时间的请求",
              "type": "string"
            },
            "timezone": {
              "description": "默认为'Asia/Shanghai', 如果用户指定城市或地区,则用相应的时区",
              "type": "string"
            }
          },
          "required": [
            "asktime",
            "timezone"
          ],
          "type": "object"
        }
      }
    }
  ],
  "user": "265f0d5e-ad51-4dc9-9db4-4a40384d73a0"
}

Related to https://github.com/lobehub/lobe-chat/issues/2741