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'))