llama模型,函数请求报错
1、渠道类型为openai 2、模型为meta/llama-3.1-70b-instruct 3、在请求的时候,带上函数,原始请求体为: { "model" : "meta/llama-3.1-70b-instruct", "messages" : [ { "role" : "user", "content" : "What's the weather like in San Francisco, Tokyo, and Paris?" } ], "tools" : [ { "type" : "function", "function" : { "description" : "Get the current weather in a given location", "name" : "get_current_weather", "parameters" : { "properties" : { "location" : { "description" : "The city and state, e.g. San Francisco, CA", "type" : "string" }, "unit" : { "enum" : [ "celsius", "fahrenheit" ], "type" : "string" } }, "required" : [ "location" ], "type" : "object" } } } ], "tool_choice" : "auto" } 4、经过转发程序处理,实际请求体为: { "model" : "meta/llama-3.1-70b-instruct", "messages" : [ { "role" : "user", "content" : "What's the weather like in San Francisco, Tokyo, and Paris?" } ], "tools" : [ { "id" : "", "type" : "function", "function" : { "description" : "Get the current weather in a given location", "name" : "get_current_weather", "parameters" : { "properties" : { "location" : { "description" : "The city and state, e.g. San Francisco, CA", "type" : "string" }, "unit" : { "enum" : [ "celsius", "fahrenheit" ], "type" : "string" } }, "required" : [ "location" ], "type" : "object" } } } ], "tool_choice" : "auto" }
5、经过对比,发现在 tools 里面多了一个 "id" : ""的属性,导致接口请求报错: openai.BadRequestError: Error code: 400 - {'type': 'about:blank', 'status': 400, 'title': 'Bad Request', 'detail': "[{'type': 'extra_forbidden', 'loc': ('body', 'tools', 0, 'id'), 'msg': 'Extra inputs are not permitted', 'input': ''}]"}
6、不经过转发程序,直接请求meta/llama-3.1-70b-instruct模型,请求体里面没有"id" : ""属性,能正常请求,说明llama类型的模型不支持"id" : ""属性
是否可以优化一下,当原始请求体里面没有id的时候,实际请求的时候,也不带上id