This commit is contained in:
taylorxie
2026-03-09 23:06:06 +08:00
parent 87d9ab789c
commit 1070cf517f

View File

@@ -167,6 +167,7 @@ class AiBotPlugin(AbsExtraConfigPlugin):
async for chunk in platform.create_chat_completion_stream(self, evt):
accumulated += chunk
if len(accumulated) - last_edit_len >= EDIT_THRESHOLD:
try:
display = accumulated + ""
new_content = TextMessageEventContent(
msgtype=MessageType.TEXT,
@@ -177,6 +178,8 @@ class AiBotPlugin(AbsExtraConfigPlugin):
new_content.set_edit(response_event_id)
await self.client.send_message(evt.room_id, new_content)
last_edit_len = len(accumulated)
except Exception as edit_err:
self.log.warning(f"Streaming mid-edit failed (skipping): {edit_err}")
except Exception as e:
self.log.exception(f"Streaming error: {e}")
if not accumulated: