minor update

This commit is contained in:
Sun Tao
2026-02-26 16:03:50 +08:00
parent 338087f95c
commit 5f4e80ae6d
12 changed files with 258 additions and 236 deletions

View File

@@ -51,19 +51,19 @@ set_log_level(level="DEBUG")
def construct_agent_list() -> List[Dict[str, Any]]:
"""Construct a list of agents with their configurations."""
web_model = ModelFactory.create(
model_platform=ModelPlatformType.DEEPSEEK,
model_type=ModelType.DEEPSEEK_CHAT,
model_config_dict={"temperature": 0},
)
document_processing_model = ModelFactory.create(
model_platform=ModelPlatformType.DEEPSEEK,
model_type=ModelType.DEEPSEEK_CHAT,
model_config_dict={"temperature": 0},
)
reasoning_model = ModelFactory.create(
model_platform=ModelPlatformType.DEEPSEEK,
model_type=ModelType.DEEPSEEK_CHAT,
@@ -71,7 +71,9 @@ def construct_agent_list() -> List[Dict[str, Any]]:
)
search_toolkit = SearchToolkit()
document_processing_toolkit = DocumentProcessingToolkit(model=document_processing_model)
document_processing_toolkit = DocumentProcessingToolkit(
model=document_processing_model
)
code_runner_toolkit = CodeExecutionToolkit(sandbox="subprocess", verbose=True)
file_toolkit = FileToolkit()
excel_toolkit = ExcelToolkit()
@@ -96,9 +98,9 @@ Here are some tips that help you perform web search:
FunctionTool(search_toolkit.search_wiki),
FunctionTool(search_toolkit.search_baidu),
FunctionTool(document_processing_toolkit.extract_document_content),
]
],
)
document_processing_agent = ChatAgent(
"You are a helpful assistant that can process documents and multimodal data, and can interact with file system.",
document_processing_model,
@@ -106,9 +108,9 @@ Here are some tips that help you perform web search:
FunctionTool(document_processing_toolkit.extract_document_content),
FunctionTool(code_runner_toolkit.execute_code),
*file_toolkit.get_tools(),
]
],
)
reasoning_coding_agent = ChatAgent(
"You are a helpful assistant that specializes in reasoning and coding, and can think step by step to solve the task. When necessary, you can write python code to solve the task. If you have written code, do not forget to execute the code. Never generate codes like 'example code', your code should be able to fully solve the task. You can also leverage multiple libraries, such as requests, BeautifulSoup, re, pandas, etc, to solve the task. For processing excel files, you should write codes to process them.",
reasoning_model,
@@ -116,27 +118,27 @@ Here are some tips that help you perform web search:
FunctionTool(code_runner_toolkit.execute_code),
FunctionTool(excel_toolkit.extract_excel_content),
FunctionTool(document_processing_toolkit.extract_document_content),
]
],
)
agent_list = []
web_agent_dict = {
"name": "Web Agent",
"description": "A helpful assistant that can search the web, extract webpage content, and retrieve relevant information.",
"agent": web_agent
"agent": web_agent,
}
document_processing_agent_dict = {
"name": "Document Processing Agent",
"description": "A helpful assistant that can process a variety of local and remote documents, including pdf, docx, images, audio, and video, etc.",
"agent": document_processing_agent
"agent": document_processing_agent,
}
reasoning_coding_agent_dict = {
"name": "Reasoning Coding Agent",
"description": "A helpful assistant that specializes in reasoning, coding, and processing excel files. However, it cannot access the internet to search for information. If the task requires python execution, it should be informed to execute the code after writing it.",
"agent": reasoning_coding_agent
"agent": reasoning_coding_agent,
}
agent_list.append(web_agent_dict)
@@ -147,7 +149,7 @@ Here are some tips that help you perform web search:
def construct_workforce() -> Workforce:
"""Construct a workforce with coordinator and task agents."""
coordinator_agent_kwargs = {
"model": ModelFactory.create(
model_platform=ModelPlatformType.DEEPSEEK,
@@ -155,7 +157,7 @@ def construct_workforce() -> Workforce:
model_config_dict={"temperature": 0},
)
}
task_agent_kwargs = {
"model": ModelFactory.create(
model_platform=ModelPlatformType.DEEPSEEK,
@@ -163,17 +165,17 @@ def construct_workforce() -> Workforce:
model_config_dict={"temperature": 0},
)
}
task_agent = ChatAgent(
"You are a helpful assistant that can decompose tasks and assign tasks to workers.",
**task_agent_kwargs
**task_agent_kwargs,
)
coordinator_agent = ChatAgent(
"You are a helpful assistant that can assign tasks to workers.",
**coordinator_agent_kwargs
**coordinator_agent_kwargs,
)
workforce = Workforce(
"Workforce",
task_agent=task_agent,
@@ -181,7 +183,7 @@ def construct_workforce() -> Workforce:
)
agent_list = construct_agent_list()
for agent_dict in agent_list:
workforce.add_single_agent_worker(
agent_dict["description"],
@@ -195,14 +197,14 @@ def main():
r"""Main function to run the OWL system with an example question."""
# Default research question
default_task_prompt = "Search for recent news about the OWL project and generate a report, then save it locally."
# Override default task if command line argument is provided
task_prompt = sys.argv[1] if len(sys.argv) > 1 else default_task_prompt
task = Task(
content=task_prompt,
)
workforce = construct_workforce()
processed_task = workforce.process_task(task)
@@ -213,4 +215,3 @@ def main():
if __name__ == "__main__":
main()