【function call】大模型的hello function call
1. 所有的大模型的function call 功能就是将function 也当作输入到大模型中
2. 不同的平台或者模型调用的方式可能不一样
一个硅基流动的例子
import requests
from openai import OpenAIclient = OpenAI(api_key="sk-vuffqulyakrzccyqenavdryxyamqkhemidvgaihdqmehmhlv", # 从https://cloud.siliconflow.cn/account/ak获取base_url="https://api.siliconflow.cn/v1"
)# 使用 WeatherAPI 的天气查询函数
def get_weather(city: str):# 使用 WeatherAPI 的 API 来获取天气信息api_key = "e6fc3642f396444b98c111750251604" # 替换为你自己的 WeatherAPI APIKEYbase_url = "http://api.weatherapi.com/v1/current.json"params = {'key': api_key,'q': city,'aqi': 'no' # 不需要空气质量数据}# 调用天气 APIresponse = requests