This commit is contained in:
2025-08-15 16:12:42 +08:00
parent 04913b776d
commit 8a583f7c68

View File

@@ -35,7 +35,6 @@ try:
)
response.raise_for_status() # 检查请求是否成功
print("流式响应内容:\n")
# 逐块处理响应
for chunk in response.iter_content(chunk_size=None):
if chunk:
@@ -62,7 +61,7 @@ try:
if 'choices' in data and len(data['choices']) > 0:
delta = data['choices'][0].get('delta', {})
content = delta.get('content', '')
if content:
if content and content != '\n':
# 实时输出内容,不换行
print(content, end='', flush=True)