From 0c0cfe017f69fa216972a88e90e4abb4f4d50dde Mon Sep 17 00:00:00 2001 From: zhaoweiguo Date: Thu, 31 Oct 2024 14:05:05 +0800 Subject: [PATCH 1/3] Update openai_api.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不用对openrouter.ai单独处理 --- metagpt/provider/openai_api.py | 3 --- 1 file changed, 3 deletions(-) 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") From 8ced2e8933fbde57c14d40acd05ee80fc72919f9 Mon Sep 17 00:00:00 2001 From: zhaoweiguo Date: Thu, 31 Oct 2024 15:20:13 +0800 Subject: [PATCH 2/3] Update requirements.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新对tree_sitter_python和tree_sitter的依赖 --- requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 04438651b656fb643db180c08926a01e70f1406f Mon Sep 17 00:00:00 2001 From: voidking Date: Fri, 1 Nov 2024 13:51:24 +0800 Subject: [PATCH 3/3] bugfix: #1547 Before calling serializeToString in mmdc_playwright.py, make sure the SVG element exists. --- metagpt/utils/mmdc_playwright.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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: