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- Thepluginssection lists the plugins available for your application. It allows you to specify several attributes for each plugin, including itsname,path,tags,prefix, andparameters.name- Thenamefield defines the unique identifier for a plugin. It serves as both the name of the plugin and the default value for theprefixandtagsattributes.path- Thepathfield specifies the relative path from theplugin_config.yamlfile to the entry point of the plugin. Thispathguides the application to the plugin’s location.prefix- Theprefixfield lets you define an endpoint path to be appended before the path specified in thepathfield. If not explicitly specified, thenameis used as the default value forprefix.tags- Thetagsfield 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, thenameis used as the default value.parameters- Theparametersfield 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- Theconfigsection encompasses Gunicorn server configuration details. These details ensure that the Plugin server operates effectively and efficiently.worker- Theworkerfield 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 to1.timeout- Thetimeoutfield defines the duration until the Gunicorn master process waits before terminating subprocesses and initiating new processes. Configuring thistimeoutis crucial for managing server stability and responsiveness. Its default value is30 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