Skip to content

Commit 86cc7fb

Browse files
zhiweizhiwei
authored andcommitted
add local api
1 parent 9e6e386 commit 86cc7fb

2 files changed

Lines changed: 138 additions & 0 deletions

File tree

configs/config_qwen.toml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# General Config
2+
tag = "gaia"
3+
concurrency = 4
4+
workdir = "workdir"
5+
log_path = "log.txt"
6+
download_path = "downloads_folder"
7+
use_local_proxy = false # true for local proxy, false for public proxy
8+
split = "validation"
9+
save_path = "dra.jsonl"
10+
11+
# Tool Config
12+
[searcher_tool]
13+
engine = "Google"
14+
fallback_engines = ["DuckDuckGo", "Baidu", "Bing"]
15+
retry_delay = 10
16+
max_retries = 3
17+
lang = "en"
18+
country = "us"
19+
filter_year = 0
20+
num_results = 5
21+
fetch_content = false
22+
max_length = 50000
23+
24+
[deep_researcher_tool]
25+
model_id = "Qwen"
26+
max_depth = 2
27+
max_insights = 20
28+
time_limit_seconds = 60
29+
max_follow_ups = 3
30+
summarizer_model_id = "Qwen"
31+
32+
[browser_tool]
33+
model_id = "Qwen"
34+
headless = false
35+
disable_security = true
36+
extra_chromium_args = []
37+
chrome_instance_path = ""
38+
wss_url = ""
39+
cdp_url = ""
40+
use_proxy = false
41+
max_length = 50000
42+
[browser.proxy]
43+
server = "xxxx"
44+
username = "xxxx"
45+
password = "xxxx"
46+
47+
[deep_analyzer_tool]
48+
analyzer_model_ids = ["Qwen"]
49+
summarizer_model_id = "Qwen"
50+
51+
# Agent configs
52+
[agent]
53+
name = "dra"
54+
use_hierarchical_agent = true
55+
56+
[agent.planning_agent_config]
57+
model_id = "Qwen"
58+
name = "planning_agent"
59+
description = "A planning agent that can plan the steps to complete the task."
60+
max_steps = 15
61+
template_path = "src/agent/planning_agent/prompts/planning_agent.yaml"
62+
tools = ["planning"]
63+
managed_agents = ["deep_analyzer_agent", "browser_use_agent", "deep_researcher_agent"]
64+
65+
[agent.deep_analyzer_agent_config]
66+
model_id = "Qwen"
67+
name = "deep_analyzer_agent"
68+
description = "Performs systematic, step-by-step analysis..."
69+
max_steps = 3
70+
template_path = "src/agent/deep_analyzer_agent/prompts/deep_analyzer_agent.yaml"
71+
tools = ["deep_analyzer", "python_interpreter"]
72+
73+
[agent.browser_use_agent_config]
74+
model_id = "Qwen"
75+
name = "browser_use_agent"
76+
description = "Searches relevant web pages and interacts with them."
77+
max_steps = 5
78+
template_path = "src/agent/browser_use_agent/prompts/browser_use_agent.yaml"
79+
tools = ["auto_browser_use", "python_interpreter"]
80+
81+
[agent.deep_researcher_agent_config]
82+
model_id = "Qwen"
83+
name = "deep_researcher_agent"
84+
description = "Conducts extensive web searches."
85+
max_steps = 3
86+
template_path = "src/agent/deep_researcher_agent/prompts/deep_researcher_agent.yaml"
87+
tools = ["deep_researcher", "python_interpreter"]
88+
89+
[dataset]
90+
name = "2023_all"
91+
path = "data/GAIA"

main.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import warnings
2+
warnings.simplefilter("ignore", DeprecationWarning)
3+
4+
import sys
5+
from pathlib import Path
6+
import asyncio
7+
8+
root = str(Path(__file__).resolve().parents[0])
9+
sys.path.append(root)
10+
11+
from src.logger import logger
12+
from src.config import config
13+
from src.models import model_manager
14+
from src.agent import create_agent
15+
from src.utils import assemble_project_path
16+
17+
18+
async def main():
19+
# Init config and logger
20+
config.init_config(config_path=assemble_project_path("./configs/config_qwen.toml"))
21+
logger.init_logger(config.log_path)
22+
logger.info(f"Initializing logger: {config.log_path}")
23+
logger.info(f"Load config: {config}")
24+
25+
# Registed models
26+
model_manager.init_models(use_local_proxy=config.use_local_proxy)
27+
logger.info("Registed models: %s", ", ".join(model_manager.registed_models.keys()))
28+
29+
# Create agent
30+
agent = create_agent()
31+
32+
# Default task
33+
default_task = "Use deep_researcher_agent to search the latest papers on the topic of 'AI Agent' and then summarize it."
34+
35+
# Interactive loop
36+
print("Enter your task (press Enter to use default, type 'exit' to quit):")
37+
while True:
38+
task = input(f">>> ") or default_task
39+
if task.lower() in ["exit", "quit"]:
40+
print("Exiting.")
41+
break
42+
res = await agent.run(task)
43+
logger.info(f"Result: {res}")
44+
print(f"Result:\n{res}\n")
45+
46+
if __name__ == '__main__':
47+
asyncio.run(main())

0 commit comments

Comments
 (0)