'commit'
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user