forked from SkyworkAI/DeepResearchAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (48 loc) · 1.89 KB
/
main.py
File metadata and controls
60 lines (48 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import argparse
import os
import sys
import asyncio
from pathlib import Path
from mmengine import DictAction
root = str(Path(__file__).resolve().parents[0])
sys.path.append(root)
from src.logger import logger
from src.config import config
from src.models import model_manager
from src.agent import create_agent
def parse_args():
parser = argparse.ArgumentParser(description='main')
parser.add_argument("--config", default=os.path.join(root, "configs", "config_main.py"), help="config file path")
parser.add_argument(
'--cfg-options',
nargs='+',
action=DictAction,
help='override some settings in the used config, the key-value pair '
'in xxx=yyy format will be merged into config file. If the value to '
'be overwritten is a list, it should be like key="[a,b]" or key=a,b '
'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" '
'Note that the quotation marks are necessary and that no white space '
'is allowed.')
args = parser.parse_args()
return args
async def main():
# Parse command line arguments
args = parse_args()
# Initialize the configuration
config.init_config(args.config, args)
# Initialize the logger
logger.init_logger(log_path=config.log_path)
logger.info(f"| Logger initialized at: {config.log_path}")
logger.info(f"| Config:\n{config.pretty_text}")
# Registed models
model_manager.init_models(use_local_proxy=True)
logger.info("| Registed models: %s", ", ".join(model_manager.registed_models.keys()))
# Create agent
agent = await create_agent(config)
logger.visualize_agent_tree(agent)
# Run example
task = "Use deep_researcher_agent to search the latest papers on the topic of 'AI Agent' and then summarize it."
res = await agent.run(task)
logger.info(f"| Result: {res}")
if __name__ == '__main__':
asyncio.run(main())