Skip to content

Component base

ComponentBase

Bases: BaseModel

The ComponentBase class, which is used to define the base class of the component.

Source code in agentuniverse/base/component/component_base.py
Python
class ComponentBase(BaseModel):
    """The ComponentBase class, which is used to define the base class of the component."""

    component_type: ComponentEnum
    # pydantic protected_namespaces config
    model_config = ConfigDict(protected_namespaces=())

    def get_instance_code(self) -> str:
        """Return the full name of the component."""
        appname = ApplicationConfigManager().app_configer.base_info_appname
        return f'{appname}.{self.component_type.value.lower()}.{self.name}'

    def initialize_by_component_configer(self, component_configer: ComponentConfiger) -> 'ComponentBase':
        """Initialize the component by the ComponentConfiger object.

        Args:
            component_configer(ComponentConfiger): the ComponentConfiger object
        Returns:
            ComponentBase: the component object
        """
        pass

get_instance_code()

Return the full name of the component.

Source code in agentuniverse/base/component/component_base.py
Python
def get_instance_code(self) -> str:
    """Return the full name of the component."""
    appname = ApplicationConfigManager().app_configer.base_info_appname
    return f'{appname}.{self.component_type.value.lower()}.{self.name}'

initialize_by_component_configer(component_configer)

Initialize the component by the ComponentConfiger object.

Parameters:

Name Type Description Default
component_configer(ComponentConfiger)

the ComponentConfiger object

required
Source code in agentuniverse/base/component/component_base.py
Python
def initialize_by_component_configer(self, component_configer: ComponentConfiger) -> 'ComponentBase':
    """Initialize the component by the ComponentConfiger object.

    Args:
        component_configer(ComponentConfiger): the ComponentConfiger object
    Returns:
        ComponentBase: the component object
    """
    pass