2025-03-29 19:13:56 +08:00
|
|
|
from src.agents.chatbot import ChatbotAgent
|
|
|
|
|
from src.agents.react import ReActAgent
|
2025-03-24 19:07:51 +08:00
|
|
|
|
|
|
|
|
class AgentManager:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.agents = {}
|
|
|
|
|
|
2025-03-29 17:33:09 +08:00
|
|
|
def add_agent(self, agent_id, agent_class):
|
|
|
|
|
self.agents[agent_id] = agent_class
|
2025-03-24 23:00:14 +08:00
|
|
|
|
2025-03-25 05:40:07 +08:00
|
|
|
def get_runnable_agent(self, agent_id, **kwargs):
|
|
|
|
|
agent_class = self.get_agent(agent_id)
|
2025-03-29 17:33:09 +08:00
|
|
|
return agent_class()
|
2025-03-25 05:40:07 +08:00
|
|
|
|
|
|
|
|
def get_agent(self, agent_id):
|
2025-03-29 17:33:09 +08:00
|
|
|
return self.agents[agent_id]
|
2025-03-25 05:40:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
agent_manager = AgentManager()
|
2025-03-29 17:33:09 +08:00
|
|
|
agent_manager.add_agent("chatbot", ChatbotAgent)
|
2025-03-29 19:13:56 +08:00
|
|
|
agent_manager.add_agent("react", ReActAgent)
|
2025-03-25 05:40:07 +08:00
|
|
|
|
|
|
|
|
__all__ = ["agent_manager"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
agent = agent_manager.get_agent("chatbot")
|
|
|
|
|
conf = agent_manager.get_configuration("chatbot")
|
|
|
|
|
agent_info = {
|
|
|
|
|
"name": agent.name,
|
|
|
|
|
"description": agent.description,
|
|
|
|
|
}
|
|
|
|
|
print(agent_info)
|