How to create a custom plugin with ChatGPT Plugin template
Preview
ChatGPT Plugin is a template designed by Azion to enable a quick and simple creation of ChatGPT plugins that run directly on the edge. With this template, you can implement the default setup, which completes a search within the GitHub repositories of a given account, or customize new plugins according to your needs.
Requirements
Section titled RequirementsBefore using this template, you need to:
- Create a Chat OpenAI account.
- It must be eligible to develop plugins.
- Generate your GitHub personal token.
Getting the template
Section titled Getting the templateTo start using the ChatGPT Plugin template, follow the steps:
- Access Real-Time Manager (RTM).
- If you don’t have an account yet, create a new one by visiting the sign-up page.
- On the homepage, select the Start with a template option.
- Find the ChatGPT Plugin card and select it.
- Click the Settings tab to open the configuration form.
Setting up the template
Section titled Setting up the templateIn the configuration form, you must provide the information to configure your Azion application and others. Fill in the presented fields.
Fields identified with an asterisk are mandatory.
- Application Name *: the name of your edge application. It’s used to identify and manage your application within Azion’s platform.
- Use a unique and easy-to-remember name. If the name has already been used, the platform returns an error message.
- Name for Human: the human-readable name for your plugin, up to
20 characters
.- For example: Repositories Search.
- GitHub Personal Token *: your Github personal token.
After completing all the information, click the Next button, located in the bottom-right corner. This will start the deployment process.
Deploying your project to the edge
Section titled Deploying your project to the edgeDuring the deployment, you’ll be able to follow the process through a window showing off the logs. When it’s complete, the deployment page appears, confirming the edge application for your project has been successfully created.
This page shows you the following sections:
- Access your Edge Application section includes the link to visit and explore your edge application.
- Build Summary contains the application’s name and function.
- The Deployment details tab can be opened to access the logs related to the deployment.
- What do you want to do next? provides recommendations regarding advanced options to enhance your edge application: Customize Domain, Manage Edge Application, View Edge Application Metrics, View Edge Application Logs, and the Back to Home button.
Key configurations
Section titled Key configurationsThis template creates a new Azion edge application and its domain. It also creates an edge function to provide the arguments for the template, including routes to the plugin and OpenAPI settings, and a new repository in your GitHub account based on a public template.
To know more on how to edit and customize your project’s settings, go to the Managing your project on Azion section.
Additionally, to guarantee the optimal performance of this template, it’s necessary to activate the following Azion product:
You must activate this product separately via RTM. To do so:
- Access RTM.
- On the upper-left corner, select the three horizontal lines to open the Products menu.
- In the BUILD section, select Edge Application.
- You’ll be redirected to the Edge Application page.
- It lists all the edge applications you’ve created.
- Find the edge application related to your template and select it.
- In the Main Settings tab, find the Edge Application Modules section and active the switch for the product you want to enable.
Customizing the plugin
Section titled Customizing the pluginThe default setup of this template completes a search within the GitHub repositories of a given account. If you want to maintain this configuration, skip to the Registering your plugin section.
To customize your plugin with another use case, you’ll need to do it through the new GitHub repository created during the deployment.
To customize your ChatGPT plugin, proceed as follows:
- Access your ChatGPT Plugin repository on GitHub.
- In the function folder, open the index.ts file and add your API routes for the plugin. It must looks similar to this:
{your-domain}/well-known/api-plugin.json // your plugin configuration.{your-domain}/openapi.json // your OpenApi specification.{your-domain}/search // to search repositories on GitHub.
- In the schemas folder, change the openapi.json file with the new schema of your API. Follow this example:
"components": { "schemas": { "getAllReposResponse": { "type": "object", "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "url": { "type": "string" }, "stars": { "type": "string" } } } } }
- Still in the schemas folder, change your plugin data in the api-plugin.json file. It must looks similar to this:
{ "schema_version": "v1", "name_for_human": "GitHub Repositories Search", "name_for_model": "github_repositories_search", "description_for_human": "GitHub Repositories Search plugin for ChatGPT.", "description_for_model": "GitHub Repositories Search plugin for ChatGPT.", "auth": { "type": "none" }, "api": { "type": "openapi", "url": "/openapi.json" }, "logo_url": "http://www.example.com/static/images/logo/my-logo-600x600.png", "contact_email": "support@example.com", "legal_info_url": "http://www.example.com/legal"}
- Add your Azion personal token to the repository’s Secrets. Read more about getting an Azion personal token.
- Do it following this format:
AZION_PERSONAL_TOKEN=<value>
- Create a pull request for the main branch to implement the changes.
Registering your plugin
Section titled Registering your pluginThe last step is registering your plugin on the ChatGPT Plugin Store.
To do so:
- Log in to ChatGPT User Interface.
- In the Plugin Store, select the Develop your own plugin option to register your new plugin.
- Complete the information in the registration step.
Done. Your plugin is now ready for use.
Managing your project on Azion
Section titled Managing your project on AzionConsidering that this initial setup may not be optimal for your specific edge application, all settings can be customized any time you need by using Azion Real-Time Manager (RTM).
To manage and edit your edge application’s settings, follow these steps:
- Access RTM.
- On the upper-left corner, select the three horizontal lines to open the Products menu.
- In the BUILD section, select Edge Application.
- You’ll be redirected to the Edge Application page.
- It lists all the edge applications you’ve created.
- Find the edge application related to your WordPress website and select it.
- The list is organized alphabetically. You can also use the search bar located in the upper-left corner of the list; currently, it filters only by Application Name.
After selecting the edge application you’ll work on, you’re directed to a page containing all the settings you can configure.
Additionally, once the template is deployed, you also have full control over customizing your website’s design, content, and functionality using the WordPress admin panel.
Continuous deployment
Section titled Continuous deploymentOnce the template is deployed, you can edit and update your args and code, as well as implement a continuous deployment workflow. However, you’ll need first to declare secrets on your project’s GitHub repository to complete the second build with the changes. When the second build is completed, you’ll be able to manage your project with a continuous deployment workflow and edit the args as desired.
To do so, open your ChatGPT Plugin repository in GitHub. Then, go to Settings > Secrets and variables > Action to add your variables, following these instructions:
- Add the Azion Personal Token to the secrets:
- Read how to generate an Azion Personal Token in the documentation.
AZION_PERSONAL_TOKEN=<value>
- Add the environments for use in the action workflow in the main.yml file, included in the .github/workflows folder of your repository:
- name: edge-... id: azion_edge ... with: .... azionPersonalToken: ${{ secrets.AZION_PERSONAL_TOKEN }} ....
- Access the file azion/azion.json to add the ChatGPT Plugin details. This file will be automatically created on your first deploy.
{ "application": { ... }, "domain": { ... "url": "123.map.azionedge.net" // your URL to insert plugin manifest Important (https://) }, "function": { ... "file": "worker/function.js" }}
- Open a pull request to merge the changes to the main branch and start the automatic deployment.
Now, your project is ready to work with a continuous deployment workflow, updating instantly any changes in the application or the repository.
Adding a custom domain
Section titled Adding a custom domainThe edge application created during the deployment has an assigned Azion domain to make it accessible through the browser. The domain has the following format: xxxxxxxxxx.map.azionedge.net
. However, you can add a custom domain for users to access your edge application through it.
Contributors