Agents

Agent

The YeagerAIAgent class is the core component of YeagerAI's yAgents. It is responsible for orchestrating the execution of tasks by utilizing various modules and interfacing with the Memory and Toolkit. The agent is highly customizable, enabling users to tailor their AI solutions to their specific needs.

class YeagerAIAgent:
    def __init__(self, username: str, session_id: str, session_path: str, model_name: str, callbacks: List[Callable], context: YeagerAIContext):
        # Initialization code
        # ...
    
    def run(self, input):
        return self.agent_executor.run(input)

To create an instance of YeagerAIAgent, you need to provide the following parameters:

  • username: The user's name.

  • session_id: A unique identifier for the current session.

  • session_path: The file path for the current session.

  • model_name: The name of the GPT-4 model used by the agent.

  • callbacks: A list of callback functions that will be executed at specific points during the agent's execution.

  • context: An instance of YeagerAIContext that provides access to memory and other shared resources.

Prompt Template

The YeagerAIPromptTemplate class is responsible for formatting the agent's input prompts, which include conversation history and available tools. This class inherits from BaseChatPromptTemplate and provides a custom format_messages method to generate the appropriate prompt.

class YeagerAIPromptTemplate(BaseChatPromptTemplate):
    def format_messages(self, **kwargs) -> List[BaseMessage]:
        # Formatting code
        # ...

Output Parser

The YeagerAIOutputParser class is responsible for parsing the agent's output and determining whether the agent has provided a final answer or needs to take further actions. This class inherits from AgentOutputParser and provides a custom parse method to process the agent's output.

class YeagerAIOutputParser(AgentOutputParser):
    def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
        # Parsing code
        # ...

Master Template

The MASTER_TEMPLATE is a string that provides a general format for the agent's input prompts. It includes placeholders for conversation history, available tools, and other relevant information. The YeagerAIPromptTemplate class uses this template to generate the final input prompt for the agent.

Last updated