From be1805b1515c498d4cae0a00a4cb6682e0b325b4 Mon Sep 17 00:00:00 2001 From: LanWeiFRJ <101687185+LanWeiFRJ@users.noreply.github.com> Date: Wed, 29 Oct 2025 14:16:49 +0800 Subject: [PATCH] initial --- _run.py | 3 +-- src/managers/image_builder/__init__.py | 2 +- src/managers/image_builder/logger_patch.py | 5 +---- src/managers/llm_api/__init__.py | 4 ++-- src/managers/llm_api/api_manager.py | 2 -- src/managers/llm_api/base_client.py | 2 +- src/managers/prompts/prompts_manager.py | 2 +- src/tools/edit_tool.py | 2 +- 8 files changed, 8 insertions(+), 14 deletions(-) diff --git a/_run.py b/_run.py index 6ab9131..febcd19 100644 --- a/_run.py +++ b/_run.py @@ -555,7 +555,7 @@ class Runner: for result in generator_results: if isinstance(result, Exception): - self.logger.error(f"GeneratorLoop 异常: {result}") + self.logger.error(f"GeneratorLoop exception: {result}") else: valid_results.append(result) self.logger.debug( @@ -734,7 +734,6 @@ def run_one_issue(cfg, issue: str) -> dict[str, Any]: if not cfg.get("runner", {}).get("skip_selector", False): runner = Runner(cfg, ids) summary = asyncio.run(runner.run()) - # 打印结果 print("\n" + "=" * 80) print("total results") print("=" * 80) diff --git a/src/managers/image_builder/__init__.py b/src/managers/image_builder/__init__.py index c1ee8d4..a7d402e 100644 --- a/src/managers/image_builder/__init__.py +++ b/src/managers/image_builder/__init__.py @@ -1,4 +1,4 @@ -# 导出全部模块 +# Export all modules from .build_image import * from .dockerfiles import * diff --git a/src/managers/image_builder/logger_patch.py b/src/managers/image_builder/logger_patch.py index 3f8e6e8..ee9ebe1 100644 --- a/src/managers/image_builder/logger_patch.py +++ b/src/managers/image_builder/logger_patch.py @@ -7,7 +7,6 @@ from typing import Union, Optional from swebench.harness.docker_utils import remove_image from src.managers.log.logger import Logger as CustomLogger -# 导入原始的 swebench 函数 from swebench.harness.docker_build import build_instance_image, run_threadpool @@ -19,7 +18,7 @@ def patched_build_instance_images( namespace: str = None, tag: str = None, env_image_tag: str = None, - custom_logger: Optional[Union[logging.Logger, CustomLogger]] = None, # 新增参数 + custom_logger: Optional[Union[logging.Logger, CustomLogger]] = None, ): """ Monkey patched version of build_instance_images that supports custom logger @@ -95,7 +94,6 @@ def patched_build_instance_images( def apply_logger_patch(): - """应用 logger patch""" import swebench.harness.docker_build as docker_build_module original_build_instance_images = docker_build_module.build_instance_images @@ -111,7 +109,6 @@ def restore_logger_patch(original_function): docker_build_module.build_instance_images = original_function -# 上下文管理器版本 class LoggerPatch: """Context manager""" diff --git a/src/managers/llm_api/__init__.py b/src/managers/llm_api/__init__.py index 1823d95..cef60a9 100644 --- a/src/managers/llm_api/__init__.py +++ b/src/managers/llm_api/__init__.py @@ -58,14 +58,14 @@ from src.managers.llm_api.base_client import ( Usage, ) -# 客户端实现 + from src.managers.llm_api.clients.openai.openai_client import OpenAIClient from src.managers.llm_api.clients.anthropic.anthropic_client import AnthropicClient from src.managers.llm_api.clients.deepseek.deepseek_client import DeepSeekClient from src.managers.llm_api.clients.openrouter.openrouter_client import OpenRouterClient from src.managers.llm_api.clients.private.private_client import PrivateModelClient -# API 管理器 + from src.managers.llm_api.api_manager import ( LLMAPIManager, create_manager, diff --git a/src/managers/llm_api/api_manager.py b/src/managers/llm_api/api_manager.py index 788fdf1..63751bf 100644 --- a/src/managers/llm_api/api_manager.py +++ b/src/managers/llm_api/api_manager.py @@ -19,7 +19,6 @@ from .base_client import ( EmbeddingResponse, ) -# 导入所有客户端 from .clients.openai.openai_client import OpenAIClient from .clients.anthropic.anthropic_client import AnthropicClient from .clients.deepseek.deepseek_client import DeepSeekClient @@ -440,7 +439,6 @@ class LLMAPIManager: ) -# 便捷函数 def create_manager( client_name: str, stream: bool = False, logger: Optional[Any] = None, **kwargs ) -> LLMAPIManager: diff --git a/src/managers/llm_api/base_client.py b/src/managers/llm_api/base_client.py index 9b29e4e..bf8e233 100644 --- a/src/managers/llm_api/base_client.py +++ b/src/managers/llm_api/base_client.py @@ -422,7 +422,7 @@ class BaseLLMAPI(ABC): except Exception as e: last_exception = e if attempt < self.max_retries: - delay = self.retry_delay * (2**attempt) # 指数退避 + delay = self.retry_delay * (2**attempt) if self.logger: self.logger.warning( f"{attempt + 1}th try failed,retry after {delay}s: {e}, traceback: {format_exc()}." diff --git a/src/managers/prompts/prompts_manager.py b/src/managers/prompts/prompts_manager.py index 50eea38..d73a8f2 100644 --- a/src/managers/prompts/prompts_manager.py +++ b/src/managers/prompts/prompts_manager.py @@ -243,7 +243,7 @@ Terminal time out.""" else: response_parts.append("No output") - response_parts.append("") # 空行分隔 + response_parts.append("") return "\n".join(response_parts) diff --git a/src/tools/edit_tool.py b/src/tools/edit_tool.py index 3109cb7..d047511 100644 --- a/src/tools/edit_tool.py +++ b/src/tools/edit_tool.py @@ -629,7 +629,7 @@ class TextEditorTool(Tool): file_descriptor: str, init_line: int = 1, expand_tabs: bool = True, - max_lines: Optional[int] = None, # 文件最大行,如果不为None则在返回中提示 + max_lines: Optional[int] = None, ): """Generate output for the CLI based on the content of a file.""" file_content = maybe_truncate(file_content)