目录
主要任务:调试模型与链接文心一言API接口
- 搭建知识库
- 设置模型参数以及关键词
- 接入外部API
import requests
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
API_URL = "https://tcj443h498i2p5p7.aistudio-hub.baidu.com/chat/completions"
headers = {
# 请前往 https://aistudio.baidu.com/index/accessToken 查看 访问令牌
"Authorization": "06ccc8bc7d13dfc3b6ce4854734a238b63b9a088 ",
"Content-Type": "application/json"
}
output = query({
"messages": [
{
"role": "user",
"content": "开始考试"
}
]
})
print(output.get("result"))
- 成功返回结果