You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/swarms/agents/simple_agent.py

39 lines
874 B

from termcolor import colored
class SimpleAgent:
"""
Simple Agent is a simple agent that runs a flow.
Args:
name (str): Name of the agent
flow (Flow): Flow to run
Example:
>>> from swarms.agents.simple_agent import SimpleAgent
>>> from swarms.structs import Flow
>>> from swarms.models import OpenAIChat
>>> api_key = ""
>>> llm = OpenAIChat()
"""
def __init__(
self,
name: str,
flow,
):
self.name = name
self.flow = flow
self.message_history = []
def run(self, task: str) -> str:
"""Run method"""
metrics = print(
colored(f"Agent {self.name} is running task: {task}", "red"))
print(metrics)
response = self.flow.run(task)
self.message_history.append((self.name, response))
return response