parent
98df22b802
commit
d96645f4f8
@ -0,0 +1,31 @@
|
|||||||
|
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)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 8.4 KiB |
Loading…
Reference in new issue