Skip to content

Rag agent

Planning agent module.

RagAgent

Bases: Agent

Rag Agent class.

Source code in agentuniverse/agent/default/rag_agent/rag_agent.py
Python
class RagAgent(Agent):
    """Rag Agent class."""

    def input_keys(self) -> list[str]:
        """Return the input keys of the Agent."""
        return ['input']

    def output_keys(self) -> list[str]:
        """Return the output keys of the Agent."""
        return ['output']

    def parse_input(self, input_object: InputObject, agent_input: dict) -> dict:
        """Agent parameter parsing.

        Args:
            input_object (InputObject): input parameters passed by the user.
            agent_input (dict): agent input preparsed by the agent.
        Returns:
            dict: agent input parsed from `input_object` by the user.
        """
        agent_input['input'] = input_object.get_data('input')
        self.agent_model.profile.setdefault('prompt_version', 'default_rag_agent.cn')
        return agent_input

    def parse_result(self, planner_result: dict) -> dict:
        """Planner result parser.

        Args:
            planner_result(dict): Planner result
        Returns:
            dict: Agent result object.
        """
        return planner_result

input_keys()

Return the input keys of the Agent.

Source code in agentuniverse/agent/default/rag_agent/rag_agent.py
Python
def input_keys(self) -> list[str]:
    """Return the input keys of the Agent."""
    return ['input']

output_keys()

Return the output keys of the Agent.

Source code in agentuniverse/agent/default/rag_agent/rag_agent.py
Python
def output_keys(self) -> list[str]:
    """Return the output keys of the Agent."""
    return ['output']

parse_input(input_object, agent_input)

Agent parameter parsing.

Parameters:

Name Type Description Default
input_object InputObject

input parameters passed by the user.

required
agent_input dict

agent input preparsed by the agent.

required
Source code in agentuniverse/agent/default/rag_agent/rag_agent.py
Python
def parse_input(self, input_object: InputObject, agent_input: dict) -> dict:
    """Agent parameter parsing.

    Args:
        input_object (InputObject): input parameters passed by the user.
        agent_input (dict): agent input preparsed by the agent.
    Returns:
        dict: agent input parsed from `input_object` by the user.
    """
    agent_input['input'] = input_object.get_data('input')
    self.agent_model.profile.setdefault('prompt_version', 'default_rag_agent.cn')
    return agent_input

parse_result(planner_result)

Planner result parser.

Parameters:

Name Type Description Default
planner_result(dict)

Planner result

required
Source code in agentuniverse/agent/default/rag_agent/rag_agent.py
Python
def parse_result(self, planner_result: dict) -> dict:
    """Planner result parser.

    Args:
        planner_result(dict): Planner result
    Returns:
        dict: Agent result object.
    """
    return planner_result