Skip to content

Prompt configer

PromptConfiger

Bases: ComponentConfiger

The PromptConfiger class, which is used to load and manage the Prompt configuration.

Source code in agentuniverse/base/config/component_configer/configers/prompt_configer.py
Python
class PromptConfiger(ComponentConfiger):
    """The PromptConfiger class, which is used to load and manage the Prompt configuration."""

    def __init__(self, configer: Optional[Configer] = None):
        """Initialize the PromptConfiger."""
        super().__init__(configer)
        self.__metadata_version: Optional[str] = None

    @property
    def metadata_version(self) -> Optional[str]:
        """Return prompt version of the Prompt."""
        return self.__metadata_version

    def load(self) -> 'PromptConfiger':
        """Load the configuration by the Configer object.
        Returns:
            PromptConfiger: the PromptConfiger object
        """
        return self.load_by_configer(self.__configer)

    def load_by_configer(self, configer: Configer) -> 'PromptConfiger':
        """Load the configuration by the Configer object.
        Args:
            configer(Configer): the Configer object
        Returns:
            PromptConfiger: the PromptConfiger object
        """
        super().load_by_configer(configer)
        try:
            self.__metadata_version = configer.value.get('metadata').get('version')
            # set the prompt default module and class
            if self.metadata_module is None:
                self.metadata_module = 'agentuniverse.prompt.prompt'
            if self.metadata_class is None:
                self.metadata_class = 'Prompt'
        except Exception as e:
            raise Exception(f"Failed to parse the Prompt configuration: {e}")
        return self

metadata_version: Optional[str] property

Return prompt version of the Prompt.

__init__(configer=None)

Initialize the PromptConfiger.

Source code in agentuniverse/base/config/component_configer/configers/prompt_configer.py
Python
def __init__(self, configer: Optional[Configer] = None):
    """Initialize the PromptConfiger."""
    super().__init__(configer)
    self.__metadata_version: Optional[str] = None

load()

Load the configuration by the Configer object. Returns: PromptConfiger: the PromptConfiger object

Source code in agentuniverse/base/config/component_configer/configers/prompt_configer.py
Python
def load(self) -> 'PromptConfiger':
    """Load the configuration by the Configer object.
    Returns:
        PromptConfiger: the PromptConfiger object
    """
    return self.load_by_configer(self.__configer)

load_by_configer(configer)

Load the configuration by the Configer object. Args: configer(Configer): the Configer object Returns: PromptConfiger: the PromptConfiger object

Source code in agentuniverse/base/config/component_configer/configers/prompt_configer.py
Python
def load_by_configer(self, configer: Configer) -> 'PromptConfiger':
    """Load the configuration by the Configer object.
    Args:
        configer(Configer): the Configer object
    Returns:
        PromptConfiger: the PromptConfiger object
    """
    super().load_by_configer(configer)
    try:
        self.__metadata_version = configer.value.get('metadata').get('version')
        # set the prompt default module and class
        if self.metadata_module is None:
            self.metadata_module = 'agentuniverse.prompt.prompt'
        if self.metadata_class is None:
            self.metadata_class = 'Prompt'
    except Exception as e:
        raise Exception(f"Failed to parse the Prompt configuration: {e}")
    return self