這裡要注意,如果你去找 Call 3rd API 故意回傳空的,代表 OpenAI 的 Summary 會沒有「參考資料」 參考以下: ` {“role”: “function”, “name”: “get_poi”, “content”: “{}”}` 。 也就是説,他會開始使用自己知道的相關資訊。(但是可能不是你期待的)。 curl ht
\\n[Your Name]\"\n}" } },"finish_reason": "function_call" } ],"usage": {"prompt_tokens": 86,"completion_tokens": 82,"total_tokens": 168 }}GPT模型会返回需要调用的函数名 send_email和对应的参数(放在arguments字段)。{"to_address": "cobus@humanfirst.ai","subject...
我们先调用API来体验下。 curl--location'https://api.openai.com/v1/chat/completions' \ --header'Content-Type: application/json' \ --header'Authorization: Bearer sk-xxxx' \ --data'{ "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "Send Cobus from humanfi...
"}, {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}"}}, {"role": "function", "name": "get_current_weather", "content": "{\"temperature\": "22", \"unit\": \"celsius\", \...
这些用例是通过/v1/chat/completions中的新参数functions和function_call实现的,允许开发人员通过JSON模式描述函数,并可选择要求其调用特定函数。请查看开发文档[1];如果发现函数调用可以优化的案例,可以提交到evals[2]中。 函数调用的官方示例(我测试过以后会再写一个自己的示例) 询问天气:What’s the weather like...
curl https://api.openai.com/v1/chat/completions-u:$OPENAI_API_KEY-H'Content-Type: application/json'-d '{"model":"gpt-3.5-turbo-0613","messages":[{"role":"user","content":"What is the weather like in Boston?"},{"role":"assistant","content":null,"function_call":{"name":"get...
function call示例 此处以天气查询工具与时间查询工具为例,向您展示通过OpenAI接口兼容实现function call的功能。示例代码可以实现多轮工具调用。 from openai import OpenAI from datetime import datetime import json import os client = OpenAI( # 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:api_key="...
It would be great to have it before the end of the week.\\n\\nThanks,\\n[Your Name]\"\n}"} },"finish_reason":"function_call"} ],"usage": {"prompt_tokens":86,"completion_tokens":82,"total_tokens":168}} GPT模型会返回需要调用的函数名send_email和对应的参数(放在arguments字段)。
function call:控制模型如何响应函数调用。“none"表示模型不调用函数,而是直接回应给最终用户。“auto"表示模型可以选择在最终用户和调用函数之间进行切换。如果使用{“name”:“my_function”}指定特定的函数,模型将强制调用该函数。当没有函数存在时,默认值为"none”。如果存在函数,默认值为"auto”。 注意:被调用的...
狗狗坐在地上,', 'function_call': None, 'role': None, 'tool_calls': None}, 'finish_reason': None, 'index': 0, 'logprobs': None}], 'created': 1721823365, 'model': 'qwen-vl-plus', 'object': 'chat.completion.chunk', 'service_tier': None, 'system_fingerprint': None, 'usage...