From b2e8be2d785d5b7b8c9146a7d5888c92bb4e3cd9 Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Thu, 22 Aug 2024 12:05:12 +0800 Subject: [PATCH 1/4] fix base_llm.py obfuscate error --- metagpt/provider/base_llm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metagpt/provider/base_llm.py b/metagpt/provider/base_llm.py index 813e77d95..75d8bfe00 100644 --- a/metagpt/provider/base_llm.py +++ b/metagpt/provider/base_llm.py @@ -300,7 +300,6 @@ class BaseLLM(ABC): if compress_type == CompressType.NO_COMPRESS: return messages - current_token_count = 0 max_token = TOKEN_MAX.get(self.config.model, max_token) keep_token = int(max_token * threshold) compressed = [] @@ -318,7 +317,7 @@ class BaseLLM(ABC): # system_msgs = [msg for msg in messages if msg["role"] == system_msg_val] # user_assistant_msgs = [msg for msg in messages if msg["role"] != system_msg_val] compressed.extend(system_msgs) - current_token_count += self.count_tokens(system_msgs) + current_token_count = self.count_tokens(system_msgs) if compress_type in [CompressType.POST_CUT_BY_TOKEN, CompressType.POST_CUT_BY_MSG]: # Under keep_token constraint, keep as many latest messages as possible From fef8bfd9bc48a4cab789ad8cb16a87c9d34d176b Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Thu, 22 Aug 2024 20:51:29 +0800 Subject: [PATCH 2/4] fix env serialized error --- metagpt/base/base_role.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metagpt/base/base_role.py b/metagpt/base/base_role.py index 49dbcd617..2f6c9f963 100644 --- a/metagpt/base/base_role.py +++ b/metagpt/base/base_role.py @@ -8,7 +8,10 @@ class BaseRole: """Abstract base class for all roles.""" name: str - is_idle: bool + + @property + def is_idle(self) -> bool: + raise NotImplementedError @abstractmethod def think(self): From 62140a6d560008f3e350785e239c08f0d6bd8a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Mon, 26 Aug 2024 16:42:26 +0800 Subject: [PATCH 3/4] feat: png -> svg --- metagpt/utils/mermaid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.py index 64996717e..008bb849d 100644 --- a/metagpt/utils/mermaid.py +++ b/metagpt/utils/mermaid.py @@ -38,7 +38,7 @@ async def mermaid_to_file( Returns: int: 0 if the conversion is successful, -1 if the conversion fails. """ - suffixes = suffixes or ["png"] + suffixes = suffixes or ["svg"] # Write the Mermaid code to a temporary file config = config if config else Config.default() dir_name = os.path.dirname(output_file_without_suffix) From 128552b9fbd6423919ea5594018ab1f25339e8dd Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Mon, 26 Aug 2024 17:41:56 +0800 Subject: [PATCH 4/4] svg reporter --- metagpt/actions/design_api.py | 2 +- metagpt/actions/write_prd.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/actions/design_api.py b/metagpt/actions/design_api.py index 86fa699bb..68a66d5a4 100644 --- a/metagpt/actions/design_api.py +++ b/metagpt/actions/design_api.py @@ -231,7 +231,7 @@ class WriteDesign(Action): async def _save_mermaid_file(self, data: str, pathname: Path): pathname.parent.mkdir(parents=True, exist_ok=True) await mermaid_to_file(self.config.mermaid.engine, data, pathname) - image_path = pathname.parent / f"{pathname.name}.png" + image_path = pathname.parent / f"{pathname.name}.svg" if image_path.exists(): await GalleryReporter().async_report(image_path, "path") diff --git a/metagpt/actions/write_prd.py b/metagpt/actions/write_prd.py index 4b2015145..7a04520d6 100644 --- a/metagpt/actions/write_prd.py +++ b/metagpt/actions/write_prd.py @@ -278,7 +278,7 @@ class WritePRD(Action): pathname = output_filename or self.repo.workdir / COMPETITIVE_ANALYSIS_FILE_REPO / Path(prd_doc.filename).stem pathname.parent.mkdir(parents=True, exist_ok=True) await mermaid_to_file(self.config.mermaid.engine, quadrant_chart, pathname) - image_path = pathname.parent / f"{pathname.name}.png" + image_path = pathname.parent / f"{pathname.name}.svg" if image_path.exists(): await GalleryReporter().async_report(image_path, "path")