API使用示例,解放开发者双手
关于函数调用功能,OpenAI给出了以下几个示例。
1.请求转换
“给Anya发邮件,看她是否想在下周五喝咖啡”这样的请求转换为函数调用:
send_email(to: string, body: string)
“波士顿的天气如何?”转换为函数调用:
get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')。
2.将自然语言转换为API调用或数据库查询
本月前十名的客户是谁?
get_customers_by_revenue(start_date: string, end_date: string, limit: int)
Acme公司上个月下了多少订单,能转换为SQL查询:
sql_query(query: string)
3.从文本中提取结构化数据
定义函数提取Wikipedia文章中提到的所有人物:
extract_people_data(people: [{name: string, birthday: string, location: string}]) |