Extend

Some digital employee core components can be extended, for example, identity, connectors (tools & MCPs), and the digital employee object itself.

Extend Use Cases

Identity

Digital employee core can be extended using this code example:

from digital_employee_core import DigitalEmployeeIdentity

class ExtendedDigitalEmployeeIdentity(DigitalEmployeeIdentity):
    """Extended Digital Employee Identity with additional attributes."""
    
    employee_id: str

Connectors

Tools

We can add our own tools in addition to those already provided by GL Connectors by extending the BaseTool.

Here is the example:

import calendar
from datetime import datetime, timedelta
from typing import Any

from gllm_plugin.tools import tool_plugin
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field


class InterviewDateInput(BaseModel):
    """Input schema for interview date tool."""

    reference_date: str = Field(
        default=None,
        description="Reference date in ISO format (YYYY-MM-DD, e.g., 2024-12-16). If not provided, uses current date.",
    )


class GenerateInterviewDateConfig(BaseModel):
    """Configuration schema for interview date generation."""

    days_to_add: int = Field(
        default=7,
        description="Number of days to add to the reference date before finding the next available weekday",
    )
    excluded_weekdays: list[int] = Field(
        default=[calendar.SATURDAY, calendar.SUNDAY],
        description=(
            "List of weekday numbers to exclude (0=Monday, 1=Tuesday, "
            "..., 6=Sunday). Default excludes Saturday and Sunday."
        ),
    )


@tool_plugin(version="1.0.0")
class ConfigurableGenerateInterviewDateTool(BaseTool):
    """Generate an interview date with configurable days offset and excluded weekdays."""

    name: str = "configurable_generate_interview_date"
    description: str = (
        "Generate interview date: adds configurable days to reference date, "
        "returns next available weekday excluding configured weekdays."
    )
    args_schema: type[BaseModel] = InterviewDateInput
    tool_config_schema: type[BaseModel] = GenerateInterviewDateConfig

    def _run(
        self,
        reference_date: str | None = None,
        config: RunnableConfig = None,
        **_kwargs: Any,
    ) -> str:
        """Generate interview date with configuration.

        Adds a configurable number of days to the reference date and returns
        the next available weekday, excluding configured weekdays.

        Args:
            reference_date (str | None, optional): Reference date in ISO format
                (YYYY-MM-DD, e.g., 2024-12-16). If not provided, uses current
                date. Defaults to None.
            config (RunnableConfig, optional): Runnable configuration containing
                tool settings. Defaults to None.
            **_kwargs (Any): Additional keyword arguments (ignored).

        Returns:
            str: Interview date in ISO format (YYYY-MM-DD) or error message if
                date format is invalid.
        """
        try:
            # Get tool config
            tool_config = self.get_tool_config(config)
        except Exception as e:
            return f"Error: Failed to retrieve tool configuration. " f"Details: {e}"

        try:
            # Parse reference date
            base_date = (
                datetime.strptime(reference_date, "%Y-%m-%d").date() if reference_date else datetime.now().date()
            )
        except ValueError as e:
            return f"Error: Invalid date format. Please use YYYY-MM-DD " f"(e.g., 2024-12-16). Details: {e}"

        # Add configured days to base date
        target_date = base_date + timedelta(days=tool_config.days_to_add)

        # Find next available weekday (not in excluded list)
        max_iterations = 7  # Prevent infinite loop
        iterations = 0
        while target_date.weekday() in tool_config.excluded_weekdays and iterations < max_iterations:
            target_date += timedelta(days=1)
            iterations += 1

        if iterations >= max_iterations:
            return (
                f"Error: Could not find available weekday after "
                f"{max_iterations} days. All weekdays may be excluded."
            )

        return f"Interview date: {target_date.isoformat()}"

To configure the tools, we need to create a config_templates/tools_configs.yaml file. Here is an example of tools_configs.yaml :

To define default value for configs, create a config_templates/defaults.yaml file. Here is an example of defaults.yaml :

MCPs

Here is how we can create our own MCP:

We need to provide the config_templates/mcp_configs.yaml file to be able to use the MCP. Here is an example of mcp_configs.yaml:

Digital Employee

circle-info

To see more examples, please check the Digital Employee Examplearrow-up-right.

Last updated