Extend

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

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:

Tool Input

from pydantic import BaseModel, Field


class GreetingInput(BaseModel):
    user_name: str = Field(default="World", description="Name of the person to greet.")

Tool Config

Tool Implementation

To configure the tools, we need to create a config_templates/tool_configs.yaml file. Here is an example of tool_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 Agent

To create a custom Digital Employee Agent with specialized behavior, you can extend both DigitalEmployeeAgent and its builder. Here's a complete example with multiple pipeline steps using the pipe operator (|):

1. Create Custom Components (Optional)

First, let's create custom components for preprocessing and postprocessing:

2. Extend the Agent Class

3. Create a Custom Builder

4. Instantiate the Extended Digital Employee

Now that we have created the custom agent and builder, let's instantiate the Digital Employee.

Import the Package

Initialize the Extended Digital Employee with Multiple Steps (Improved Approach)

This example demonstrates the improved approach where ALL steps can be combined using the pipe operator (|) by using build_step() from the agent builder:

circle-check
circle-info

Why This Works:

  1. build_step(identity, configs) converts a StepBuilder to a ComponentStep

  2. ComponentStep has the __or__ method implemented

  3. The pipe operator combines ComponentStep instances into a Pipeline

  4. The Pipeline can be added to DigitalEmployeePipelineBuilder as a single step

circle-exclamation
circle-info

Working Example:

See examples/extend_example_with_pipe_operator_v2.pyarrow-up-right for a complete working example that demonstrates this approach.

circle-info

In this example, we use new MCPs (via .add_mcps([new_google_mail_mcp])) and tools (via .add_tools([Tool.from_langchain(GreetingTool)])) that are specifically created for the extended digital employee.

circle-info

We also use HELLO_GREETING_PREFIX, HELLO_GREETING_SUFFIX, NEW_GOOGLE_MAIL_MCP_URL and NEW_GOOGLE_MCP_X_API_KEY configs, which are defined in the config template of the new tool and MCP.

Run the Extended Digital Employee

circle-info

Note: The new pattern uses async/await. Use employee.invoke(...) instead of the old employee.run(...) method.

circle-exclamation
chevron-right🔑 Get GL Connectors x-api-keyhashtag
  1. In the Credentials section, expand the x-api-key panel and click Copy combined value button. Paste this value to replace [gl-connectors-x-api-key].

  1. If your Gmail account has not been integrated yet, continue with the steps below.

  2. Under Available Modules section, find the Google_mail integration and click Add New Integration button.

  1. An authorization URL will appear. Click or copy the URL, then authenticate using your Gmail account.

  1. Below is an example of a successfully integrated Gmail account.

circle-info

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

Last updated