You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
921 B
32 lines
921 B
import requests
|
|
import json
|
|
|
|
# 请求URL
|
|
url = 'https://goapi.gptnb.me/v1/chat/completions'
|
|
# 令牌
|
|
token = 'sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662'
|
|
|
|
# POST请求的数据
|
|
modelData = {
|
|
"model": "gpt-3.5-turbo",
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "请使用中文帮我编写一个微信朋友圈方案,内容是暑假来了,爸爸妈妈和宝宝一起去帝湾游乐场玩,他们玩了好多种游戏,非常开心。"
|
|
}
|
|
],
|
|
"temperature": 0.7
|
|
}
|
|
|
|
# 发送POST请求
|
|
# JWT授权为啥要在 Authorization标头里加个Bearer 呢
|
|
# https://blog.csdn.net/liuzaixi/article/details/133686087
|
|
headers = {
|
|
'content-type': 'application/json', 'Authorization': 'Bearer '+token
|
|
}
|
|
|
|
response = requests.post(url=url, headers=headers, data=json.dumps(modelData))
|
|
|
|
# 打印返回的响应内容
|
|
print(response.text)
|