diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index 1d2057e50..bd9c02231 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -114,9 +114,6 @@ class OpenAILLM(BaseLLM): elif hasattr(chunk.choices[0], "usage"): # The usage of some services is an attribute of chunk.choices[0], such as Moonshot usage = CompletionUsage(**chunk.choices[0].usage) - elif "openrouter.ai" in self.config.base_url and chunk_has_usage: - # due to it get token cost from api - usage = chunk.usage has_finished = True log_llm_stream("\n") diff --git a/metagpt/utils/mmdc_playwright.py b/metagpt/utils/mmdc_playwright.py index e7e6e3b2e..53d2c4a2b 100644 --- a/metagpt/utils/mmdc_playwright.py +++ b/metagpt/utils/mmdc_playwright.py @@ -81,10 +81,13 @@ async def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, if "svg" in suffixes: svg_xml = await page.evaluate( """() => { - const svg = document.querySelector('svg'); - const xmlSerializer = new XMLSerializer(); - return xmlSerializer.serializeToString(svg); - }""" + const svg = document.querySelector('svg'); + if (!svg) { + throw new Error('SVG element not found'); + } + const xmlSerializer = new XMLSerializer(); + return xmlSerializer.serializeToString(svg); + }""" ) logger.info(f"Generating {output_file_without_suffix}.svg..") with open(f"{output_file_without_suffix}.svg", "wb") as f: diff --git a/requirements.txt b/requirements.txt index 5344ffb8c..36cf4350e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -81,4 +81,6 @@ volcengine-python-sdk[ark]~=1.0.94 # Solution for installation error in Windows: gymnasium==0.29.1 boto3~=1.34.69 spark_ai_python~=0.3.30 -agentops \ No newline at end of file +agentops +tree_sitter~=0.23.2 +tree_sitter_python~=0.23.2