AI开发平台ModelArts-Function Calling介绍:使用方式

时间:2025-02-12 15:14:03

使用方式

  • 方式一:在请求体中添加相关函数。
    "tools": [    {        'type': 'function',        'function': {            'name': '对应到实际执行的函数名称',            'description': '此处是函数相关描述',            'parameters': {                '_comments': '此处是函数参数相关描述'            },        }    },    {        '_comments': '其他函数相关说明'    }]
  • 方式二:通过OpenAI库发起请求。
    response = client.chat.completions.create(    model="MaaS模型名称",    messages = messages,    tools=[        {            'type': 'function',            'function': {                'name': '对应到实际执行的函数名称',                'description': '此处是函数相关描述',                'parameters': {                    // 此处是函数参数相关描述                },            }        },        {            // 其他函数相关说明        }    ]    // chat.completions 其他参数)
support.huaweicloud.com/usermanual-maas-modelarts/maas-modelarts-0042.html