Plugin Configurations

The plugin is a FastAPI-based server that enables ACE Agent to interact with third-party applications or APIs over a REST interface.

Defining Plugin

The plugin_config.yaml file is a central component in configuring plugins for your application. The fields within the configuration file and their purposes are as follows.

plugins:
- name: calculator
    path: ./plugins/calculator/calculate.py

- name: plugin_name
    path: config/relative/path/to/entrypoint.py # path will be relative to plugins directory
    tags: ["plugin_tag1", "plugin_tag2"]
    prefix: "prefix/path"
    parameters:
        param_1: value_of_param

config:
workers: 1
timeout: 30
  • plugins - The plugins section lists the plugins available for your application. It allows you to specify several attributes for each plugin, including its name, path, tags, prefix, and parameters.

  • name - The name field defines the unique identifier for a plugin. It serves as both the name of the plugin and the default value for the prefix and tags attributes.

  • path - The path field specifies the relative path from the plugin_config.yaml file to the entry point of the plugin. This path guides the application to the plugin’s location.

  • prefix - The prefix field lets you define an endpoint path to be appended before the path specified in the path field. If not explicitly specified, the name is used as the default value for prefix.

  • tags - The tags field allows you to associate tags with a Plugin server. Tags help organize the Swagger documentation for your application, making it easier to categorize and access plugins. If not explicitly specified, the name is used as the default value.

  • parameters - The parameters field permits the inclusion of additional parameters or configuration information to be passed to the Plugin server. This allows for customization and configuration of plugins as needed.

  • config - The config section encompasses Gunicorn server configuration details. These details ensure that the Plugin server operates effectively and efficiently.

  • worker - The worker field specifies the number of worker processes to be launched by the Gunicorn server. Adjusting this value can optimize server performance and resource utilization. Its default value is set to 1.

  • timeout - The timeout field defines the duration until the Gunicorn master process waits before terminating subprocesses and initiating new processes. Configuring this timeout is crucial for managing server stability and responsiveness. Its default value is 30 sec.

Adding Custom Plugin

You can build a custom plugin for your use case and host it as part of the Plugin server. This allows you to extend the capabilities of the Plugin server to meet your specific needs. For example, you could build a custom plugin that uses the iTunes REST API to extract song artist information.

The Plugin server supports plugin dependency management. This allows you to specify external packages that your custom plugins depend on. For example, you could create a custom plugin that uses the Wikipedia API to retrieve information. You would then add Wikipedia as an external plugin dependency in the Plugin server. This can help to prevent errors and ensure that orders are fulfilled correctly.

Importing Parameters into Plugins

The Plugin server offers a flexible mechanism for incorporating configuration parameters that can be easily accessed within plugins.This example provides an overview of how to import and utilize plugin configuration parameters from the plugin_config.yaml file.

You can specify parameters for plugin configurations within the plugin_config.yaml file. These parameters are associated with individual plugins. In the following example, a weather plugin is configured with a mock parameter set to true.

plugins:
- name: weather
    path: weather.py
    parameters:
        mock: true

In plugins code (for example, weather.py), parameters can be imported and accessed using the following methodology:

from fastapi import APIRouter
from parameters import param

router = APIRouter()

# Accessing the 'mock' parameter for the 'weather' plugin
mock = param.get("weather").get("mock", False)

# Additional weather plugin details can be implemented here