Skip to content

Class swarmauri_core.prompt_templates.IPromptTemplate.IPromptTemplate

swarmauri_core.prompt_templates.IPromptTemplate.IPromptTemplate

Bases: ABC

Interface for template-based prompt generation within the SwarmAURI framework. Defines standard operations and attributes for managing and utilizing templates.

set_template abstractmethod

set_template(template)

Sets or updates the current template string.

PARAMETER DESCRIPTION
template

The new template string to be used for generating prompts.

TYPE: str

Source code in swarmauri_core/prompt_templates/IPromptTemplate.py
19
20
21
22
23
24
25
26
27
@abstractmethod
def set_template(self, template: str) -> None:
    """
    Sets or updates the current template string.

    Args:
        template (str): The new template string to be used for generating prompts.
    """
    pass

set_variables abstractmethod

set_variables(variables={})

Sets or updates the variables to be substituted into the template.

PARAMETER DESCRIPTION
variables

A dictionary of variables where each key-value pair corresponds to a placeholder name and its replacement value in the template.

TYPE: List[Dict[str, str]] DEFAULT: {}

Source code in swarmauri_core/prompt_templates/IPromptTemplate.py
29
30
31
32
33
34
35
36
37
38
39
40
41
@abstractmethod
def set_variables(
    self, variables: Union[List[Dict[str, Any]], Dict[str, Any]] = {}
) -> None:
    """
    Sets or updates the variables to be substituted into the template.

    Args:
        variables (List[Dict[str, str]]): A dictionary of variables where each key-value
                                    pair corresponds to a placeholder name and its
                                    replacement value in the template.
    """
    pass

generate_prompt abstractmethod

generate_prompt(**kwargs)

Generates a prompt string based on the current template and provided keyword arguments.

PARAMETER DESCRIPTION
**kwargs Dict[str, Any]

Keyword arguments containing variables for template substitution.

RETURNS DESCRIPTION
str

The generated prompt string with template variables replaced by their corresponding values provided in kwargs.

TYPE: str

Source code in swarmauri_core/prompt_templates/IPromptTemplate.py
43
44
45
46
47
48
49
50
51
52
53
54
55
@abstractmethod
def generate_prompt(self, **kwargs: Dict[str, Any]) -> str:
    """
    Generates a prompt string based on the current template and provided keyword arguments.

    Args:
        **kwargs Dict[str, Any]: Keyword arguments containing variables for template substitution.

    Returns:
        str: The generated prompt string with template variables replaced by their
             corresponding values provided in `kwargs`.
    """
    pass