OnePrompt as Personal Assistant ChatBot.

OnePrompt

Extensible ChatBot App with Custom Plugins

Improving AI Chat Experience using User-Generated Custom Plugins

OnePrompt also facilitates the utilization of custom plugins generated by users through OpenAI's "Function Calling" feature. For more information about "Function Calling", please visit this OpenAI blog. Custom plugins enable integration with a variety of service APIs, thereby enhancing the AI chat experience for users.

Custom Plugin Templates

OnePrompt provides custom plugin templates to give users an opportunity to experience custom plugins. Of course, users are free to create custom plugins beyond templates. Later in this article, we will provide a detailed description of how to create custom plugins.

Screenshot of Settings Screen on OnePrompt.

Custom Plugins in Settings

Tap "Custom Plugins" in Settings screen.

Screenshot of Custom Plugins Templates on OnePrompt.

Custom Plugins Templates

Popular API services are accessible through custom plugins.

Screenshot of Inital Setup for Custom Plugin on OnePrompt.

Custom Plugin Initial Setup

Supporting API key and other setup.

Custom Plugin Data Structures

Custom plugins for OnePrompt are described using JSON data structures. JSON data consists of four key elements: "name", "description", "functions" and "plugins". Only JSON response data is supported by custom plugins. See the "Custom Plugin Data" table below in detail.

Custom Plugin Data
KeyDescription
nameString. Title shown in the plugin menu
descriptionString. Text applied as "system prompt"
functionsArray. Contains "function data" (see below)
pluginsArray. Contains "plugin data" (see below)

The functions in custom plugin data is the same as "functions" defined in API reference. Each function consists of three key elements: "name", "description" and "parameters". See the "Function Data" table below in detail.

Function Data
KeyDescription
nameString. Function name
descriptionString. Detailed function descriptions
parametersDictionary. See function parameters

The plugins in custom plugin data is JSON object contains "plugin". Each plugin consists of five key elements: "plugin_name", "http_method", "url_string","parameters" and "filter". See the "Plugin Data" table below in detail.

Plugin Data
KeyDescription
plugin_nameString. Same name as the corresponding function name
http_methodString. HTTP method name, ether "GET" or "POST"
url_stringString. Endpoint URL of Rest API
parametersDictionary. Contains the constant key-value pairs defined in the Rest API (optional)
filterDictionary. Used to extract only the desired keys from the response data. (optional)

The filter in plugin data consists of three key elements: "paths", "type" and "keys". The filter can be used to reduce the number of tokens by extracting only the necessary keys from the response data. See the "Filter Data" table below in detail.

Filter Data
KeyDescription
pathsArray. Keys containing the data you want to extract as path
typeString. The value type indicated by last key in paths ether "array" or "dictionary"
keysArray. Desired keys to use chat response

How to Make A Custom Plugin

Let's create a custom plugin using the "Programmable Search Engine". Here is the entire plugin code provided for your reference, which you can study to create a custom plugin. And this is the Node.js code to confirm the response of the Google Custom Search API.


{
  "name": "Google Search Plugin",
  "description": "You can search information with [keywords] that are extracted in order to satisfy user's request. The [keywords] must be separated by white space.",
  "functions": [
    {
      "name": "custom_search",
      "description" : "Search information with keywords.",
      "parameters": {
        "type": "object",
        "properties": {
          "q": {
            "type": "string",
            "description" : "Set search keywords separated by white space."
          }
        },
        "required": [ "q" ]
      }
    }
  ],
  "plugins": [
    {
      "plugin_name": "custom_search",
      "http_method": "GET",
      "url_string": "https://customsearch.googleapis.com/customsearch/v1",
      "parameters": {
        "key": "Your-API-Key",
        "cx": "Your-Search-Engine-ID",
        "c2coff": 1,
        "lr": "lang_en",
        "hl": "en",
        "num": 5,
        "filter": 1
      },
      "filter": {
        "paths": [
          "items"
        ],
        "type": "array",
        "keys": [
          "title",
          "snippet",
          "link"
        ]
      }
    }
  ]
}

The data structures in the "functions" section are exactly the same as those defined in the OpenAI API reference for "functions". The parameter name "q" in the "properties" section corresponds to the parameter name in the query parameters of the Custom Search JSON API reference. It's essential to ensure that the keys within the properties section match the query parameters specified in the API reference - this rule is of utmost significance when crafting the custom plugin.

In the "plugins" section, "parameters" refers to a dictionary (aka an associative array) of fixed values that will be sent to the API. This field can be omitted, especially when there is no API key or other relevant information. In the context of "plugins", the term "filter" instructs to target the "items" field within the response data of type "array". It further directs the extraction of specific fields such as "title", "snippet" and "link" as indicated by the contents of the "keys".

How to Use The Custom Plugin

To use the custom plugin you've created, launch the Files.app and copy the plugin file to the "Plugins" folder of OnePrompt on your local device. After opening the chat screen, you'll come across the puzzle piece icon in case the custom plugin is accessible. Tap on the puzzle piece icon and choose the custom plugin you wish to utilize. When using the custom search plugin, input a sentence with particular keywords, and you'll obtain the relevant search results.

Screenshot of Plugins Folder.

Plugins Folder

Open the "Files.app" and then copy the plugin file you've created to the "Plugins" folder within OnePrompt in the local iOS device.

Screenshot of Custom Plugins Menu on OnePrompt Chat Screen.

Custom Plugins Menu

Access the chat screen, then tap on the puzzle piece icon. From there, choose the plugin you've created.

Screenshot of Google Search Custom Plugin on OnePrompt.

Google Search Plugin

Enter a sentence containing search keywords and the search results corresponding to the keywords will be displayed.

Another Example for A Custom Plugin

Below is an illustration of using the "YouTube Data API to Search for Content" as a custom plugin. Here is the complete plugin code provided for your convenience. Additionally, the following Node.js code demonstrates how to verify the response from the YouTube Search API.


{
  "name": "YouTube Search Plugin",
  "description": "You can perform searches on YouTube videos using [keywords] to fulfill user requests. The [keywords] must be separated by spaces. The output for search results must be contains the [videoTitle] and [videoDescription], and include the video's URL in the following format: https://www.youtube.com/watch?v=[videoId]. From the search results, please extract the [videoTitle], [videoDescription], and [videoId]. Lastly, please kindly provide a response in the same language as the one entered by the user.",
  "functions": [
    {
      "name": "youtube_search",
      "description" : "Perform searches on YouTube videos to fulfill user requests.",
      "parameters": {
        "type": "object",
        "properties": {
          "q": {
            "type": "string",
            "description" : "Search keywords separated by spaces."
          }
        },
        "required": [ "q" ]
      }
    }
  ],
  "plugins": [
    {
      "plugin_name": "youtube_search",
      "http_method": "GET",
      "url_string": "https://www.googleapis.com/youtube/v3/search",
      "parameters": {
        "key": "Your-API-Key",
        "part": "id,snippet",
        "type": "video",
        "order": "relevance",
        "maxResults": 5,
        "regionCode": "en"
      },
      "filter": {
        "paths": [
          "items"
        ],
        "type": "array",
        "keys": [
          "id.videoId",
          "snippet.title:videoTitle",
          "snippet.description:videoDescription"
        ]
      }
    }
  ]
}

The primary distinction compared to the plugin code above lies in the content of the "keys" within the "filter" section. The value of each key is used to extract the content of the response with the data structure below which contains dictionary data. The newly designated key for the response of the function call is the string on the right side, separated by a dot. For instance, "videoId" would be the key for "id.videoId".

For the key "snippet.title:videoTitle", it indicates the replacement of the value "title" within the key separated by a dot with the specified alias "videoTitle". The same principle applies to "snippet.description:videoDescription" as well. This is very useful when explicitly directing keywords at the system prompt.

{
  "items": [
    {
      "id": {
        "videoId": "VIDEO-ID",
        ...
      },
      "snippet": {
        "title": "VIDEO-TITLE",
        "description": "VIDEO-DESCRIPTION",
        ...
      },
      ...
    }
  ]
}
Screenshot of Selecting YouTube Search Plugin on OnePrompt Chat Screen.

Select YouTube Plugin

Access the chat screen, then tap on the puzzle piece icon. From there, choose the YouTube Search plugin you've created.

Screenshot of Searching YouTube Videos on OnePrompt Chat Screen.

Search YouTube Videos

Input the text containing keywords to search for YouTube videos.

Screenshot of Function Calling Log on OnePrompt ChatLog Screen.

YouTube Search Log

The ChatLog screen enables you to view the contents of the data structure that provided a response to the "function call".

Notice

To display the logs for "function call", enable the "Shows Function Chain in ChatLog" option in the "For Developer" section of the "Settings" screen.

Download OnePrompt from the Apple App Store
QR Code to Download OnePrompt from AppStore

OnePrompt can be used on all your iOS devices.

OnePrompt - Chatbot App Focused on AI Chat Prompts for iOS / iPadOS | Product Hunt