From ec36d298f05ce6f93cc951c2e5577abe9d4d1cae Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Thu, 25 Apr 2024 22:38:21 +0800 Subject: [PATCH] stop llm stream report if task done --- metagpt/report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/report.py b/metagpt/report.py index 5bc0ec03d..db755d803 100644 --- a/metagpt/report.py +++ b/metagpt/report.py @@ -146,14 +146,14 @@ class ResourceReporter(BaseModel): async def __aexit__(self, *args, **kwargs): """Exit the asynchronous streaming callback context.""" - await self.async_report(None, END_MARKER_NAME) self.is_chunk = False if self.enable_llm_stream: self._llm_task.cancel() self._llm_task = None + await self.async_report(None, END_MARKER_NAME) async def _llm_stream_report(self, queue: asyncio.Queue): - while True: + while self.is_chunk: await self.async_report(await queue.get(), "content") async def wait_llm_stream_report(self):