feat: raise error
Some checks failed
sync2gitee / repo-sync (push) Has been cancelled
Typos Check / Spell Check with Typos (push) Has been cancelled

This commit is contained in:
zhangzhanwei 2025-09-29 18:05:43 +08:00 committed by zhanweizhang7
parent f943cc52bb
commit f834569f91

View File

@ -187,11 +187,13 @@ class PromptGenerateSerializer(serializers.Serializer):
def process():
model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id,**application.model_params_setting)
for r in model.stream([SystemMessage(content=system_content),
try:
for r in model.stream([SystemMessage(content=system_content),
*[HumanMessage(content=m.get('content')) if m.get('role') == 'user' else AIMessage(
content=m.get('content')) for m in messages]]):
yield 'data: ' + json.dumps({'content': r.content}) + '\n\n'
yield 'data: ' + json.dumps({'content': r.content}) + '\n\n'
except Exception as e:
yield 'data: ' + json.dumps({'error': str(e)}) + '\n\n'
return to_stream_response_simple(process())