Skip to content

Commit fb05cad

Browse files
authored
fix: Refreshing the page during the streaming response process of a simple AI agent will permanently lose the current Q&A records #5156 (#5169)
1 parent d3d4b76 commit fb05cad

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ def event_content(response,
142142
'node_type': 'ai-chat-node'})
143143
if not manage.debug:
144144
add_access_num(chat_user_id, chat_user_type, manage.context.get('application_id'))
145-
except Exception as e:
146-
maxkb_logger.error(f'{str(e)}:{traceback.format_exc()}')
147-
all_text = 'Exception:' + str(e)
145+
except BaseException as e:
146+
if isinstance(e, GeneratorExit):
147+
maxkb_logger.error(f'Generator was closed (client disconnected)')
148+
else:
149+
maxkb_logger.error(f'{str(e)}:{traceback.format_exc()}')
150+
all_text = 'Exception:' + str(e)
148151
write_context(step, manage, 0, 0, all_text)
149152
post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text,
150153
all_text, manage, step, padding_problem_text, reasoning_content='')

0 commit comments

Comments
 (0)