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
16k stars 3.71k forks source link

讯飞3.5无法支持function calling #1493

Closed zhang66893649 closed 6 days ago

zhang66893649 commented 1 month ago

例行检查

问题描述 讯飞星火Spark v3.5如下报文无法支持,返回error,同样的报文请求gpt,正常。

复现步骤 如下报文,model换成Spark3.5

{
    "model": "gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "What is the weather like in Boston?"
        },
        {
            "role": "assistant",
            "content": "None",
            "function_call": {
                "name": "get_current_weather",
                "arguments": "{ \"location\": \"Boston, MA\"}"
            }
        },
        {
            "role": "function",
            "name": "get_current_weather",
            "content": "{\"temperature\": \"22\", \"unit\": \"celsius\", \"description\": \"Sunny\"}"
        }
    ],
    "functions": [
        {
            "name": "get_current_weather",
            "description": "Get the current weather in a given location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The city and state, e.g. San Francisco, CA"
                    },
                    "unit": {
                        "type": "string",
                        "enum": [
                            "celsius",
                            "fahrenheit"
                        ]
                    }
                },
                "required": [
                    "location"
                ]
            }
        }
    ]
}

预期结果

{
    "choices": [
        {
            "content_filter_results": {
                "hate": {
                    "filtered": false,
                    "severity": "safe"
                },
                "self_harm": {
                    "filtered": false,
                    "severity": "safe"
                },
                "sexual": {
                    "filtered": false,
                    "severity": "safe"
                },
                "violence": {
                    "filtered": false,
                    "severity": "safe"
                }
            },
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "The current weather in Boston, MA is sunny with a temperature of 22°C.",
                "role": "assistant"
            }
        }
    ],
    "created": 1717146633,
    "id": "chatcmpl-9UsZN0cEvIfhsPINAz6t2egQvdATo",
    "model": "gpt-4o-2024-05-13",
    "object": "chat.completion",
    "prompt_filter_results": [
        {
            "prompt_index": 0,
            "content_filter_results": {
                "hate": {
                    "filtered": false,
                    "severity": "safe"
                },
                "self_harm": {
                    "filtered": false,
                    "severity": "safe"
                },
                "sexual": {
                    "filtered": false,
                    "severity": "safe"
                },
                "violence": {
                    "filtered": false,
                    "severity": "safe"
                }
            }
        }
    ],
    "system_fingerprint": "fp_5f4bad809a",
    "usage": {
        "completion_tokens": 18,
        "prompt_tokens": 130,
        "total_tokens": 148
    }
}

相关截图 image