Skip to content

role_changer

AIRole

AIRole(name: Optional[str] = None, **kwargs: Any)

Bases: RoleChanger

Change the role of the prompts to assistant.

Parameters:

  • name (Optional[str], default: None ) –

    The name of the assistant role. Defaults to None.

  • **kwargs (Any, default: {} ) –

    The keyword arguments to pass to the Role

Source code in src/appl/role_changer.py
def __init__(self, name: Optional[str] = None, **kwargs: Any):
    """Initialize the AIRole object.

    Args:
        name: The name of the assistant role. Defaults to None.
        **kwargs: The keyword arguments to pass to the Role
    """
    role = MessageRole(MessageRoleType.ASSISTANT, name=name)
    super().__init__(role=role, **kwargs)

RoleChanger

RoleChanger(
    role: Optional[MessageRole] = None,
    _ctx: Optional[PromptContext] = None,
)

Bases: PrinterModifier

The contextual role changer of the prompts.

Parameters:

  • role (Optional[MessageRole], default: None ) –

    The new role of the prompts. Defaults to None.

  • _ctx (Optional[PromptContext], default: None ) –

    The prompt context filled automatically by the APPL function.

Source code in src/appl/role_changer.py
def __init__(
    self, role: Optional[MessageRole] = None, _ctx: Optional[PromptContext] = None
):
    """Initialize the RoleChanger object.

    Args:
        role: The new role of the prompts. Defaults to None.
        _ctx: The prompt context filled automatically by the APPL function.
    """
    super().__init__(_ctx)
    if role is not None:
        self._new_role = role

SystemRole

SystemRole(name: Optional[str] = None, **kwargs: Any)

Bases: RoleChanger

Change the role of the prompts to system.

Parameters:

  • name (Optional[str], default: None ) –

    The name of the system role. Defaults to None.

  • **kwargs (Any, default: {} ) –

    The keyword arguments to pass to the RoleChanger constructor.

Source code in src/appl/role_changer.py
def __init__(self, name: Optional[str] = None, **kwargs: Any):
    """Initialize the SystemRole object.

    Args:
        name: The name of the system role. Defaults to None.
        **kwargs: The keyword arguments to pass to the RoleChanger constructor.
    """
    role = MessageRole(MessageRoleType.SYSTEM, name=name)
    super().__init__(role=role, **kwargs)

ToolRole

ToolRole(name: Optional[str] = None, **kwargs: Any)

Bases: RoleChanger

Change the role of the prompts to tool.

Parameters:

  • name (Optional[str], default: None ) –

    The name of the tool role. Defaults to None.

  • **kwargs (Any, default: {} ) –

    The keyword arguments to pass to the RoleChanger constructor.

Source code in src/appl/role_changer.py
def __init__(self, name: Optional[str] = None, **kwargs: Any):
    """Initialize the ToolRole object.

    Args:
        name: The name of the tool role. Defaults to None.
        **kwargs: The keyword arguments to pass to the RoleChanger constructor.
    """
    role = MessageRole(MessageRoleType.TOOL, name=name)
    super().__init__(role=role, **kwargs)

UserRole

UserRole(name: Optional[str] = None, **kwargs: Any)

Bases: RoleChanger

Change the role of the prompts to user.

Parameters:

  • name (Optional[str], default: None ) –

    The name of the user role. Defaults to None.

  • **kwargs (Any, default: {} ) –

    The keyword arguments to pass to the RoleChanger constructor.

Source code in src/appl/role_changer.py
def __init__(self, name: Optional[str] = None, **kwargs: Any):
    """Initialize the UserRole object.

    Args:
        name: The name of the user role. Defaults to None.
        **kwargs: The keyword arguments to pass to the RoleChanger constructor.
    """
    role = MessageRole(MessageRoleType.USER, name=name)
    super().__init__(role=role, **kwargs)