解决retrieve接口返回content-type不正确的问题

This commit is contained in:
Tiger Ren 2024-10-10 16:48:10 +08:00
parent f36bad3a1d
commit 2c7d706777
1 changed files with 6 additions and 3 deletions

View File

@ -46,9 +46,12 @@ def retrive_stream():
knowledge_id = data.get('knowledge_id', '')
prompt_template = data.get('prompt_template', '')
response = zhipu_service.retrive_sse(message, knowledge_id, None)
print(f'response: {response}')
return response
def event_stream():
for chunk in zhipu_service.retrive_sse(message, knowledge_id, None):
if chunk:
yield chunk
return Response(event_stream(), content_type='text/event-stream')
@zhipu_controller.route('/zhipu/analysis/stream', methods=['POST'])