mirror of
https://github.com/Tokfinity/InfCode.git
synced 2026-05-26 17:48:00 +02:00
initial
This commit is contained in:
@@ -555,7 +555,7 @@ class Runner:
|
|||||||
|
|
||||||
for result in generator_results:
|
for result in generator_results:
|
||||||
if isinstance(result, Exception):
|
if isinstance(result, Exception):
|
||||||
self.logger.error(f"GeneratorLoop 异常: {result}")
|
self.logger.error(f"GeneratorLoop exception: {result}")
|
||||||
else:
|
else:
|
||||||
valid_results.append(result)
|
valid_results.append(result)
|
||||||
self.logger.debug(
|
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):
|
if not cfg.get("runner", {}).get("skip_selector", False):
|
||||||
runner = Runner(cfg, ids)
|
runner = Runner(cfg, ids)
|
||||||
summary = asyncio.run(runner.run())
|
summary = asyncio.run(runner.run())
|
||||||
# 打印结果
|
|
||||||
print("\n" + "=" * 80)
|
print("\n" + "=" * 80)
|
||||||
print("total results")
|
print("total results")
|
||||||
print("=" * 80)
|
print("=" * 80)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 导出全部模块
|
# Export all modules
|
||||||
from .build_image import *
|
from .build_image import *
|
||||||
from .dockerfiles import *
|
from .dockerfiles import *
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from typing import Union, Optional
|
|||||||
from swebench.harness.docker_utils import remove_image
|
from swebench.harness.docker_utils import remove_image
|
||||||
from src.managers.log.logger import Logger as CustomLogger
|
from src.managers.log.logger import Logger as CustomLogger
|
||||||
|
|
||||||
# 导入原始的 swebench 函数
|
|
||||||
from swebench.harness.docker_build import build_instance_image, run_threadpool
|
from swebench.harness.docker_build import build_instance_image, run_threadpool
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ def patched_build_instance_images(
|
|||||||
namespace: str = None,
|
namespace: str = None,
|
||||||
tag: str = None,
|
tag: str = None,
|
||||||
env_image_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
|
Monkey patched version of build_instance_images that supports custom logger
|
||||||
@@ -95,7 +94,6 @@ def patched_build_instance_images(
|
|||||||
|
|
||||||
|
|
||||||
def apply_logger_patch():
|
def apply_logger_patch():
|
||||||
"""应用 logger patch"""
|
|
||||||
import swebench.harness.docker_build as docker_build_module
|
import swebench.harness.docker_build as docker_build_module
|
||||||
|
|
||||||
original_build_instance_images = docker_build_module.build_instance_images
|
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
|
docker_build_module.build_instance_images = original_function
|
||||||
|
|
||||||
|
|
||||||
# 上下文管理器版本
|
|
||||||
class LoggerPatch:
|
class LoggerPatch:
|
||||||
"""Context manager"""
|
"""Context manager"""
|
||||||
|
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ from src.managers.llm_api.base_client import (
|
|||||||
Usage,
|
Usage,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 客户端实现
|
|
||||||
from src.managers.llm_api.clients.openai.openai_client import OpenAIClient
|
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.anthropic.anthropic_client import AnthropicClient
|
||||||
from src.managers.llm_api.clients.deepseek.deepseek_client import DeepSeekClient
|
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.openrouter.openrouter_client import OpenRouterClient
|
||||||
from src.managers.llm_api.clients.private.private_client import PrivateModelClient
|
from src.managers.llm_api.clients.private.private_client import PrivateModelClient
|
||||||
|
|
||||||
# API 管理器
|
|
||||||
from src.managers.llm_api.api_manager import (
|
from src.managers.llm_api.api_manager import (
|
||||||
LLMAPIManager,
|
LLMAPIManager,
|
||||||
create_manager,
|
create_manager,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from .base_client import (
|
|||||||
EmbeddingResponse,
|
EmbeddingResponse,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 导入所有客户端
|
|
||||||
from .clients.openai.openai_client import OpenAIClient
|
from .clients.openai.openai_client import OpenAIClient
|
||||||
from .clients.anthropic.anthropic_client import AnthropicClient
|
from .clients.anthropic.anthropic_client import AnthropicClient
|
||||||
from .clients.deepseek.deepseek_client import DeepSeekClient
|
from .clients.deepseek.deepseek_client import DeepSeekClient
|
||||||
@@ -440,7 +439,6 @@ class LLMAPIManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# 便捷函数
|
|
||||||
def create_manager(
|
def create_manager(
|
||||||
client_name: str, stream: bool = False, logger: Optional[Any] = None, **kwargs
|
client_name: str, stream: bool = False, logger: Optional[Any] = None, **kwargs
|
||||||
) -> LLMAPIManager:
|
) -> LLMAPIManager:
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ class BaseLLMAPI(ABC):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
last_exception = e
|
last_exception = e
|
||||||
if attempt < self.max_retries:
|
if attempt < self.max_retries:
|
||||||
delay = self.retry_delay * (2**attempt) # 指数退避
|
delay = self.retry_delay * (2**attempt)
|
||||||
if self.logger:
|
if self.logger:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"{attempt + 1}th try failed,retry after {delay}s: {e}, traceback: {format_exc()}."
|
f"{attempt + 1}th try failed,retry after {delay}s: {e}, traceback: {format_exc()}."
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ Terminal time out."""
|
|||||||
else:
|
else:
|
||||||
response_parts.append("No output")
|
response_parts.append("No output")
|
||||||
|
|
||||||
response_parts.append("") # 空行分隔
|
response_parts.append("")
|
||||||
|
|
||||||
return "\n".join(response_parts)
|
return "\n".join(response_parts)
|
||||||
|
|
||||||
|
|||||||
@@ -629,7 +629,7 @@ class TextEditorTool(Tool):
|
|||||||
file_descriptor: str,
|
file_descriptor: str,
|
||||||
init_line: int = 1,
|
init_line: int = 1,
|
||||||
expand_tabs: bool = True,
|
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."""
|
"""Generate output for the CLI based on the content of a file."""
|
||||||
file_content = maybe_truncate(file_content)
|
file_content = maybe_truncate(file_content)
|
||||||
|
|||||||
Reference in New Issue
Block a user