Skip to content

能否将openai_api_server.py升级到gpt4的tools调用相兼容的api #64

@anming81

Description

@anming81

System Info / 系統信息

接口兼容性问题,与硬件无关

Who can help? / 谁可以帮助到您?

No response

Information / 问题信息

  • The official example scripts / 官方的示例脚本
  • My own modified scripts / 我自己修改的脚本和任务

Reproduction / 复现过程

  1. 运行basic_demo/openai_api_server.py脚本
  2. 调用/v1/chat/completions接口,传入工具调用的api
    { "messages": [ { "content": "What's the weather like in San Francisco", "role": "user" } ], "model": "glm4", "stream": false, "temperature": 0.8, "tools": [ { "type": "function", "function": { "description": "根据传入的城市获取天气信息", "name": "getCurrentWeather", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "城市名称,如:武汉" } }, "required": [ "location" ] } } } ], "tool_choice": "auto" }
  3. 返回的是gpt3版本的function_call
    { "model": "glm4", "id": "", "object": "chat.completion", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "getCurrentWeather\n{\"location\": \"San Francisco\"}", "name": null, "function_call": { "name": "getCurrentWeather", "arguments": "{\"location\": \"San Francisco\"}" } }, "finish_reason": "function_call" } ], "created": 1717641432, "usage": { "prompt_tokens": 157, "total_tokens": 168, "completion_tokens": 11 } }

Expected behavior / 期待表现

期望能够返回与GPT4最新的tool_calls调用相兼容的api
{ "model": "glm4", "id": "", "object": "chat.completion", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "getCurrentWeather\n ```python\ntool_call(location='San Francisco')\n```", "tool_calls": [ { "id": "call0", "type": "function", "function": { "name": "getCurrentWeather", "arguments": "{\"location\": \"San Francisco\"}" } } ] }, "finish_reason": "tool_calls" } ], "created": 1717635659, "usage": { "prompt_tokens": 162, "total_tokens": 183, "completion_tokens": 21 } }

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions