Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 2.82 KB

agent.md

File metadata and controls

76 lines (60 loc) · 2.82 KB

Agent

Overview

The Agent class is a fundamental component of the MiniAutoGen framework, representing an individual agent within the system. Each agent is characterized by unique attributes and functionalities that enable it to participate actively in multi-agent conversations.

Class Definition

class Agent

Description:

The Agent class models an agent with specific attributes and capabilities, essential for dynamic interactions in the multi-agent system.

Attributes:

  • agent_id (int): Uniquely identifies the agent within the system.
  • name (str): The human-readable name of the agent.
  • role (str): The designated role or function of the agent within a conversation or task.
  • pipeline (Pipeline, optional): An object representing the processing pipeline of the agent. If not specified, defaults to None.
  • status (str): Indicates the current status of the agent, with a default value of "available".

Methods:

__init__(self, agent_id, name, role, pipeline=None)
  • Purpose: Initializes a new instance of the Agent class.
  • Arguments:
    • agent_id (int): The ID of the agent.
    • name (str): The name of the agent.
    • role (str): The role of the agent.
    • pipeline (Pipeline, optional): The processing pipeline for the agent. Defaults to None.
generate_reply(self, state)
  • Purpose: Generates a reply based on the given state.
  • Arguments:
    • state (State): The state object to process.
  • Returns: A string (str) representing the generated reply.
get_status(self)
  • Purpose: Retrieves the current status of the agent.
  • Returns: The status of the agent as a string (str).
from_json(json_data)
  • Purpose: Static method to create an Agent instance from JSON data.
  • Arguments:
    • json_data (dict): The JSON data representing the agent.
  • Returns: An instance of Agent.
  • Raises:
    • ValueError: If the JSON data is missing any of the required keys (agent_id, name, role).

Example Usage

Creating an Agent

my_agent = Agent(agent_id=1, name="ChatBot", role="Responder")

Generating a Reply

Assuming current_state is an instance of State:

reply = my_agent.generate_reply(current_state)
print(reply)

Retrieving Agent Status

status = my_agent.get_status()
print(f"Agent Status: {status}")

Creating an Agent from JSON

json_data = {"agent_id": 2, "name": "DataBot", "role": "Analyzer"}
data_bot = Agent.from_json(json_data)

Notes

  • The Agent class is designed to be flexible and adaptable, fitting into various roles and workflows within the MiniAutoGen framework.
  • The pipeline attribute allows for customization of the agent's processing capabilities, enabling it to handle specific types of states or tasks.