fix: fix voice interupt

This commit is contained in:
0Xiao0
2026-06-12 11:17:12 +08:00
parent 78b9138c17
commit 820dc44053
8 changed files with 537 additions and 48 deletions

View File

@ -109,6 +109,7 @@ class BeaverLLMStream(llm.LLMStream):
) -> None:
super().__init__(beaver_llm, chat_ctx=chat_ctx, tools=tools, conn_options=conn_options)
self._beaver_llm = beaver_llm
self._request_id = shortuuid("beaver_")
async def _run(self) -> None:
user_text = latest_user_text(self.chat_ctx)
@ -116,9 +117,12 @@ class BeaverLLMStream(llm.LLMStream):
reply = await self._beaver_llm._client.send_text(user_text)
if reply:
self._event_ch.send_nowait(
llm.ChatChunk(
id=shortuuid("beaver_"),
delta=llm.ChoiceDelta(role="assistant", content=reply),
)
self._send_text_chunk(reply)
def _send_text_chunk(self, text: str) -> None:
self._event_ch.send_nowait(
llm.ChatChunk(
id=self._request_id,
delta=llm.ChoiceDelta(role="assistant", content=text),
)
)