fix: fix voice interupt
This commit is contained in:
@ -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),
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user