分段输出followup_info中的信息

This commit is contained in:
Tiger Ren 2024-11-19 12:26:50 +08:00
parent 96815b76a8
commit ade2f4d8c2
1 changed files with 10 additions and 3 deletions

View File

@ -281,11 +281,18 @@ def analysis_stream():
chunk_out = format_chunk(chunk, None, None) chunk_out = format_chunk(chunk, None, None)
yield json.dumps(chunk_out) + '\n' yield json.dumps(chunk_out) + '\n'
followup_info = get_analysis_followup_info(message, accumulated_result,"1843318172036575232")
followup_info += "如有新的销售进展,请补充相关信息,我会为您做进一步分析"
yield json.dumps(format_chunk("", followup_info, "")) + '\n'
logger.info(f'accumulated_result: {accumulated_result}') logger.info(f'accumulated_result: {accumulated_result}')
followup_info = get_analysis_followup_info(message, accumulated_result, "1843318172036575232")
followup_info += "如有新的销售进展,请补充相关信息,我会为您做进一步分析"
logger.info(f'followup_info: {followup_info}') logger.info(f'followup_info: {followup_info}')
# Split followup_info into chunks of approximately 15 characters
chunk_size = 15
chunks = [followup_info[i:i+chunk_size] for i in range(0, len(followup_info), chunk_size)]
# Yield each chunk separately
for chunk in chunks:
yield json.dumps(format_chunk("", chunk, "")) + '\n'
return Response(event_stream(), mimetype='text/event-stream', headers=response_headers) return Response(event_stream(), mimetype='text/event-stream', headers=response_headers)