Skip to content

Commit 4f9a545

Browse files
committed
Remove dead code and obsolete modules
1 parent f585de4 commit 4f9a545

34 files changed

Lines changed: 17 additions & 2501 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pytest -q
269269
Current local baseline:
270270

271271
- 490 tests passing
272-
- 46 dynamically registered tools
272+
- 45 dynamically registered tools
273273
- 5 dynamically registered agents
274274

275275
Some dependency deprecation warnings remain and are tracked separately from

‎benchmark/process/dataset_candidate/reasoning/math_reasoning/constant.py‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎benchmark/process/dataset_candidate/reasoning/math_reasoning/get_score.py‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
from pathlib import Path
22
from tqdm import tqdm
3-
import multiprocessing
4-
from copy import deepcopy
53
import re
64
from lm_eval.tasks.minerva_math.utils import (
7-
last_boxed_only_string,
85
normalize_final_answer,
96
get_unnormalized_answer,
10-
remove_boxed,
117
is_equiv,
128
)
139

@@ -92,22 +88,6 @@ def is_correct(sample: str, gt_answer: str, dset: str):
9288

9389

9490

95-
def get_tasks(config):
96-
sample_paths = Path(config.samples_dir).glob("*.yaml")
97-
98-
tasks = []
99-
for sample_path in tqdm(sample_paths, desc="Loading generations"):
100-
save_path = config.save_dir / sample_path.name
101-
102-
task_config = deepcopy(config)
103-
task_config.sample_path = sample_path
104-
task_config.save_path = save_path
105-
106-
tasks.append(task_config)
107-
108-
return tasks
109-
110-
11191
def main(args):
11292
save_dir = Path(args.save_dir).absolute()
11393

‎benchmark/process/dataset_candidate/reasoning/math_reasoning/run_infer.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
import torch
21
from datasets import load_dataset
32
from tqdm import tqdm
4-
import multiprocessing
53
import random
6-
import requests
7-
from functools import partial
84
import argparse
95
from pathlib import Path
106
import yaml
11-
import importlib
127
import os
138
import asyncio
9+
from dotenv import load_dotenv
1410
from prompts import MATH_COT_PROMPT
15-
from constant import *
1611

1712
import openai
1813

14+
load_dotenv()
15+
1916
def save_yaml(path: Path, data, sort_keys=True):
2017
with open(path, "w") as f:
2118
yaml.dump(data, f, sort_keys=sort_keys)
@@ -92,9 +89,8 @@ async def main(args):
9289
save_dir = Path(save_dir)
9390
save_dir.mkdir(parents=True, exist_ok=True)
9491

95-
predictions = []
9692
for item in tqdm(test_dataset):
97-
predictions.append(await run_inference(item, save_dir, args.model, args.base_url))
93+
await run_inference(item, save_dir, args.model, args.base_url)
9894

9995
if __name__ == "__main__":
10096
parser = argparse.ArgumentParser()

‎main_ai_researcher.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ def get_args_research():
7272
return args
7373

7474

75-
def get_args_paper():
76-
parser = argparse.ArgumentParser()
77-
parser.add_argument("--research_field", type=str, default="vq")
78-
parser.add_argument("--instance_id", type=str, default="rotation_vq")
79-
args = parser.parse_args()
80-
return args
81-
82-
8375
def _prepare_research_args(config):
8476
"""Build a research args namespace from the validated config dict.
8577

‎paper_agent/introduction_composing.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def find_task1_content(self, benchmark_path: str, target_paper: str) -> str:
3232
# if paper['target'].lower() == target_paper_lower:
3333
# return paper.get('task1', '')
3434
return benchmark_data['task1']
35-
36-
logging.warning(f"No matching paper found for: {target_paper}")
37-
return ""
3835
except Exception as e:
3936
logging.error(f"Error reading benchmark file: {str(e)}")
4037
return ""
@@ -259,4 +256,4 @@ async def introduction_composing(research_field: str, instance_id: str):
259256
raise
260257

261258
if __name__ == "__main__":
262-
asyncio.run(introduction_composing())
259+
asyncio.run(introduction_composing())

‎paper_agent/tex_writer.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
logger = logging.getLogger(__name__)
66

77

8-
def run_and_print(args):
9-
result = subprocess.run(args, capture_output=True, text=True)
10-
logger.info("[CMD] %s", " ".join(args))
11-
if result.stdout:
12-
logger.debug(result.stdout)
13-
if result.stderr:
14-
logger.debug(result.stderr)
15-
return result
16-
17-
188
def compile_latex_project(project_dir, main_tex_file):
199
"""Compile a LaTeX project with bibtex support.
2010

‎paper_agent/tex_writer_ori.py‎

Lines changed: 0 additions & 59 deletions
This file was deleted.

‎research_agent/inno/core.py‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from .logger import MetaChainLogger, LoggerManager
2222
from httpx import RemoteProtocolError, ConnectError, TimeoutException
2323
from litellm.exceptions import APIError
24-
from tenacity import RetryCallState
2524
from research_agent.constant import API_BASE_URL, CHEEP_MODEL, COMPLETION_MODEL, NOT_SUPPORT_SENDER, MUST_ADD_USER, NOT_SUPPORT_FN_CALL, NOT_USE_FN_CALL
2625
from research_agent.inno.fn_call_converter import convert_tools_to_description, convert_non_fncall_messages_to_fncall_messages, SYSTEM_PROMPT_SUFFIX_TEMPLATE, convert_fn_messages_to_non_fn_messages, interleave_user_into_messages
2726
from research_agent.inno.memory.utils import encode_string_by_tiktoken, decode_tokens_by_tiktoken
@@ -33,44 +32,6 @@
3332
LLM_RETRY_ATTEMPTS = int(os.getenv("LLM_RETRY_ATTEMPTS", "3"))
3433
LLM_RETRY_BACKOFF_SECONDS = int(os.getenv("LLM_RETRY_BACKOFF_SECONDS", "5"))
3534

36-
def should_retry_error(retry_state: RetryCallState):
37-
"""检查是否应该重试错误
38-
39-
Args:
40-
retry_state: RetryCallState对象,包含重试状态信息
41-
42-
Returns:
43-
bool: 是否应该重试
44-
"""
45-
if retry_state.outcome is None:
46-
return False
47-
48-
exception = retry_state.outcome.exception()
49-
if exception is None:
50-
return False
51-
52-
print(f"Caught exception: {type(exception).__name__} - {str(exception)}")
53-
54-
# 匹配更多错误类型
55-
if isinstance(exception, (APIError, RemoteProtocolError, ConnectError, TimeoutException, TimeoutError)):
56-
return True
57-
58-
# 通过错误消息匹配
59-
error_msg = str(exception).lower()
60-
return any([
61-
"connection error" in error_msg,
62-
"server disconnected" in error_msg,
63-
"eof occurred" in error_msg,
64-
"timeout" in error_msg,
65-
"rate limit" in error_msg, # 添加 rate limit 错误检查
66-
"rate_limit_error" in error_msg, # Anthropic 的错误类型
67-
"too many requests" in error_msg, # HTTP 429 错误
68-
"overloaded" in error_msg, # 添加 Anthropic overloaded 错误
69-
"overloaded_error" in error_msg, # 添加 Anthropic overloaded 错误的另一种形式
70-
"负载已饱和" in error_msg, # 添加中文错误消息匹配
71-
"error code: 429" in error_msg, # 添加 HTTP 429 状态码匹配
72-
"context_length_exceeded" in error_msg # 添加上下文长度超限错误匹配
73-
])
7435
__CTX_VARS_NAME__ = "context_variables"
7536
logger = LoggerManager.get_logger()
7637

‎research_agent/inno/environment/browser_cookies.py‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,5 @@ def convert_cookies_to_python():
4545
f.write(output_str)
4646
return output_str
4747

48-
def get_all_cookies():
49-
all_cookies = []
50-
json_dir = wd / "cookie_json"
51-
cookie_files = glob.glob(str(json_dir / "*.json"))
52-
53-
for cookie_file in cookie_files:
54-
json_path = wd / "cookie_json" / cookie_file
55-
cookies = load_cookies_from_json(json_path)
56-
all_cookies.extend(cookies)
57-
return all_cookies
58-
5948
if __name__ == "__main__":
60-
print(convert_cookies_to_python())
49+
print(convert_cookies_to_python())

0 commit comments

Comments
 (0)