add
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import re
|
||||
|
||||
from typing import Type
|
||||
@@ -176,7 +177,10 @@ class AiBotPlugin(AbsExtraConfigPlugin):
|
||||
formatted_body=markdown.render(display)
|
||||
)
|
||||
new_content.set_edit(response_event_id)
|
||||
await self.client.send_message(evt.room_id, new_content)
|
||||
await asyncio.wait_for(
|
||||
self.client.send_message(evt.room_id, new_content),
|
||||
timeout=5.0
|
||||
)
|
||||
last_edit_len = len(accumulated)
|
||||
except Exception as edit_err:
|
||||
self.log.warning(f"Streaming mid-edit failed (skipping): {edit_err}")
|
||||
@@ -195,7 +199,10 @@ class AiBotPlugin(AbsExtraConfigPlugin):
|
||||
formatted_body=markdown.render(accumulated)
|
||||
)
|
||||
final_content.set_edit(response_event_id)
|
||||
await self.client.send_message(evt.room_id, final_content)
|
||||
await asyncio.wait_for(
|
||||
self.client.send_message(evt.room_id, final_content),
|
||||
timeout=15.0
|
||||
)
|
||||
|
||||
def get_ai_platform(self) -> Platform:
|
||||
use_platform = self.config.cur_platform
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import json
|
||||
from collections import deque
|
||||
|
||||
@@ -185,7 +186,10 @@ class Anthropic(Platform):
|
||||
if response.status != 200:
|
||||
raise ValueError(f"Error: {await response.text()}")
|
||||
while True:
|
||||
line_bytes = await response.content.readline()
|
||||
try:
|
||||
line_bytes = await asyncio.wait_for(response.content.readline(), timeout=60.0)
|
||||
except asyncio.TimeoutError:
|
||||
break
|
||||
if not line_bytes:
|
||||
break
|
||||
line = line_bytes.decode("utf-8").strip()
|
||||
|
||||
Reference in New Issue
Block a user