mirror of
https://github.com/Tokfinity/InfCode.git
synced 2026-02-12 13:12:45 +00:00
initial
This commit is contained in:
3
_run.py
3
_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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 导出全部模块
|
||||
# Export all modules
|
||||
from .build_image import *
|
||||
from .dockerfiles import *
|
||||
|
||||
|
||||
@@ -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"""
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()}."
|
||||
|
||||
@@ -243,7 +243,7 @@ Terminal time out."""
|
||||
else:
|
||||
response_parts.append("No output")
|
||||
|
||||
response_parts.append("") # 空行分隔
|
||||
response_parts.append("")
|
||||
|
||||
return "\n".join(response_parts)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user