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") 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): 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 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)