Agent
The Agent class is the base class for all agents. It provides the main logic for running the agent and processing the responses from the LLM.
It is an abstract class that should be inherited by all agents. The class provides the main logic for running the agent and processing the responses from the LLM.
GenericAgent
class implements all abstract functions for generic version of an agent in Elemental.
class Agent(ABC):
"""
Generic Agent class.
"""
def __init__(
self,
agent_logic: AgentLogic,
short_memory_capacity: int = -1,
toolbox: ToolBox = None,
termination_sequence: str = None,
) -> None
AgentLogic
object brings all information related to language model interaction including prompt, template and all variables used in the prompt (name, persona).
The Agent
class includes the following methods:
run
- Run the agent's main logic function in the iterative fashion.@abstractmethod def run( self, task: str | List[str], input_session: str ) -> str:
run_instruction
- Run the agent's main logic function on a single instruction. Tuple of a boolean indicating if the response is terminal and the string response.@abstractmethod def run_instruction( self, instruction: str, original_instruction: str = "", input_session: str = "" ) -> Tuple[bool, str]
run_instruction_inference
- Run the agent's main logic function on a single instruction inference, only LLM portion of agent logic.@abstractmethod def run_instruction_inference( self, instruction: str, original_instruction: str = "", input_session: str = "" ) -> str
run_instruction_action
- Run the agent's requested actions. Execute tools and return the result.@abstractmethod def run_instruction_action( self, agent_response: str ) -> str
process_response
- Process the response from the LLM. This method should be used to post-process the raw response and extract only the final result.@abstractmethod def process_response( self, response: str ) -> str
get_termination_sequence
- Get the termination sequence for the agent.def get_termination_sequence(self) -> str
get_agent_name
- Get the agent's name.def get_agent_name(self) -> str
get_agent_persona
- Get the agent's persona.def get_agent_persona(self) -> str
reset_short_memory
- Reset the agent's short memory. This method should be used to clear the short memory of the agent.def reset_short_memory(self) -> None
get_all_messages
- Get all messages from the agent's short memory.def get_all_messages(self) -> List[Message]