File size: 588 Bytes
b23eeaf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
import json

url = 'https://sanbo1200-duck2api.hf.space/completions'
headers = {
    'Content-Type': 'application/json'
}
data = {
    "model": "gpt-4o-mini",
    "messages": [
        {"role": "system", "content": "你是一个辅助机器人"},
        {"role": "user", "content": "你的知识库最后什么日期"}
    ],
    "stream": False
}

response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
response.encoding = 'utf-8'
# 打印返回的数据流
for line in response.iter_lines():
    if line:
        print(line.decode('utf-8'))