基本搭建完成多智能体框架

This commit is contained in:
2025-01-23 13:34:39 +08:00
parent 981209d677
commit cc3b28a59a
11 changed files with 509 additions and 408 deletions

View File

@@ -11,6 +11,7 @@ from constant import MODEL, OPENAI_API_KEY, OPENAI_BASE_URL, code_executor
from scientist_team import create_scientist_team
from engineer_team import create_engineer_team
from robot_platform import create_robot_team
from analyst_team import create_analyst_team
model_client = OpenAIChatCompletionClient(
model=MODEL,
@@ -25,14 +26,15 @@ model_client = OpenAIChatCompletionClient(
)
async def main(task: str = "") -> dict:
user = UserProxyAgent("user_agent", input_func=input)
scientist_team = create_scientist_team()
engineer_team = create_engineer_team()
await code_executor.start()
robot_platform = create_robot_team(code_executor)
# await code_executor.start()
robot_platform = create_robot_team()
analyst_team = create_analyst_team()
result = {}
user = UserProxyAgent("user", input_func=input)
planning_agent = AssistantAgent(
"PlanningAgent",
description="An agent for planning tasks, this agent should be the first to engage when given a new task.",
@@ -43,20 +45,28 @@ async def main(task: str = "") -> dict:
Assign these subtasks to the appropriate sub-teams; not all sub-teams are required to participate in every task.
Your sub-teams are:
1. User: A human agent to whom you transfer information whenever you need to confirm your execution steps to a human.
2. Engineer team: A team of professional engineers who are responsible for writing code, visualizing experimental schemes, converting experimental schemes to JSON, and more.
2. Engineer: A team of professional engineers who are responsible for writing code, visualizing experimental schemes, converting experimental schemes to JSON, and more.
- The engineer team has the following members:
2.1 Structural engineer: A professional structural engineer who focus on converting natural language synthesis schemes to JSON or XML formated scheme, and then upload this JSON to S3 Storage.
2.2 Software_Engineer: A professional Python software engineer will use Python to implement tasks.
2.3 SandBox_Env: A computer terminal that performs no other action than running Python scripts (provided to it quoted in ```python code blocks), or sh shell scripts (provided to it quoted in ```sh code blocks).
3. Scientist team: A professional team of material scientists who are mainly responsible for consulting on material synthesis, structure, application and properties.
2.2 ML engineer: A professional machine learning engineers will use Python to implement various machine learning algorithms to model data.
2.3 SandBox environment: A computer terminal that performs no other action than running Python scripts (provided to it quoted in ```python code blocks), or sh shell scripts (provided to it quoted in ```sh code blocks).
2.4 Scheme Plotter: An agent responsible for converting a expriment scheme into a Mermaid flowchart.
3. Scientist: A professional team of material scientists who are mainly responsible for consulting on material synthesis, structure, application and properties.
- The scientist team has the following members:
3.1 Synthesis Scientist: who is good at giving perfect and correct synthesis solutions.
3.2 Structure Scientist: focusing on agents of structural topics in materials science.
3.3 Property Scientist: focuses on physical and chemistry property topics in materials science.
3.4 Application Scientist: Focus on practical applications of materials, such as devices, chips, etc.
4. Robot Platform: A robotic platform is responsible for performing automated synthesis experiments, automated characterization experiments, and collecting experimental logs.
- The Robot Platform has the following members:
4.1 RobotIO_Agent: The agent responsible for the input and output of the robot platform. Pass a structured JSON schema to the robot; Get the experiment log of the robot.
4. Executor: A robotic platform is responsible for performing automated synthesis experiments, automated characterization experiments, and collecting experimental datas.
- The Executor team has the following members:
4.1 MobileRobot_Agent: This agent controls the mobile robot by calling the funciton sendScheme2MobileRobot to place the experimental container into the robot workstation. This agent called before RobotWorkstation_Agent.
4.2 RobotWorkstation_Agent: This agent is called by the mobile robot agent, do not plan it alone.
4.3 DataCollector_Agent: This agent collects experimental data and experimental logs from the characterization device in the robot platform and stores them.
5. Analyst: A team of data analysts who are responsible for analyzing and visualizing experimental data and logs.
- The Data Analysis team has the following members:
5.1 Expriment_Analyst: The agent of data analysts who are responsible for analyzing experimental data and logs.
5.2 Expriment_Optimizer: The agent optimizes the experimental scheme by means of component regulation and so on to make the experimental result close to the desired goal of the user.
5.3 Data_Visulizer: The agent of data visulizers who are responsible for visualizing experimental data and logs.
You only plan and delegate tasks - you do not execute them yourself.
@@ -92,7 +102,7 @@ async def main(task: str = "") -> dict:
# The termination condition is a combination of text mention termination and max message termination.
text_mention_termination = TextMentionTermination("TERMINATE")
max_messages_termination = MaxMessageTermination(max_messages=100)
max_messages_termination = MaxMessageTermination(max_messages=200)
termination = text_mention_termination | max_messages_termination
# The selector function is a function that takes the current message thread of the group chat
@@ -105,13 +115,13 @@ async def main(task: str = "") -> dict:
return None
team = SelectorGroupChat(
[planning_agent, user, scientist_team, engineer_team, robot_platform],
[planning_agent, user, scientist_team, engineer_team, robot_platform, analyst_team],
model_client=model_client, # Use a smaller model for the selector.
termination_condition=termination,
selector_func=selector_func,
)
await Console(team.run_stream(task=task))
await code_executor.stop()
await code_executor.stop()
# async for message in team.run_stream(task=task):
# if isinstance(message, TextMessage):
# print(f"----------------{message.source}----------------\n {message.content}")