Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (37 loc) · 1.41 KB
/
Copy pathmain.py
File metadata and controls
47 lines (37 loc) · 1.41 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
import warnings
warnings.simplefilter("ignore", DeprecationWarning)
import sys
from pathlib import Path
import asyncio
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
from src.utils import assemble_project_path
async def main():
# Init config and logger
config.init_config(config_path=assemble_project_path("./configs/config_qwen.toml"))
logger.init_logger(config.log_path)
logger.info(f"Initializing logger: {config.log_path}")
logger.info(f"Load config: {config}")
# Registed models
model_manager.init_models(use_local_proxy=config.use_local_proxy)
logger.info("Registed models: %s", ", ".join(model_manager.registed_models.keys()))
# Create agent
agent = create_agent()
# Default task
default_task = "Use deep_researcher_agent to search the latest papers on the topic of 'AI Agent' and then summarize it."
# Interactive loop
print("Enter your task (press Enter to use default, type 'exit' to quit):")
while True:
task = input(f">>> ") or default_task
if task.lower() in ["exit", "quit"]:
print("Exiting.")
break
res = await agent.run(task)
logger.info(f"Result: {res}")
print(f"Result:\n{res}\n")
if __name__ == '__main__':
asyncio.run(main())