Files
LangBot/docs/en/plugin/plugin-intro.md
T
2025-01-02 23:30:44 +08:00

7.1 KiB

Plugin Introduction

:::info Table of Contents toc :::

Plugin Categories

Plugins are extension modules of LangBot, which include two types of executable content: event listeners and content functions. Event listeners are driven by events during the main program's execution, while content functions are driven by content generated by GPT. Both driving methods are uniformly packaged within the plugin class.

Event Listeners

Plugins listen to various events during the operation of LangBot. When an event occurs, LangBot calls the registered listener of the plugin with relevant event information. Plugins can register listeners to be triggered under specified conditions.

Content Functions

Content functions differ from plugins triggered by events. During a conversation, when the dialogue content matches the description of a content function, GPT specifies the function to be called, and LangBot invokes it. This is implemented based on GPT's Function Calling capability, which is a function automatically called by GPT embedded in the conversation.

It's similar to the official ChatGPT plugins.

For example, if we provide GPT with a function access_the_web, along with its detailed description and parameter descriptions, then when we engage in a conversation involving content like the following:

Q: Please search for QQ bot projects on GitHub.
Q: Please search for some good cloud service provider websites for me.
Q: Read and summarize this article: https://zhuanlan.zhihu.com/p/607570830
Q: Check the weather in Qingyuan today.

GPT will respond with a function call request for access_the_web, and LangBot will call the content function provided by the plugin, returning the call result to GPT to generate a new response.
Of course, the function calling feature is not limited to web access; it can also implement functions such as image processing, scientific calculations, and itinerary planning. Theoretically, we can achieve the same functionality as ChatGPT Plugins through content functions.

Plugin Usage

Installation

This section only provides the basic installation method for plugins. For detailed instructions, please refer to the documentation of each plugin or consult its developer.

During runtime, use an administrator account to send a private message to the bot with !plugin get <GitHub repository address> to automatically fetch the source code and install the plugin. The program will automatically install the required libraries based on the requirements.txt file in the repository.

For example, to install the hello_plugin plugin:

!plugin get https://github.com/RockChinQ/hello_plugin

After installation, restart the program.

Manual Installation

Place the obtained plugin program in the plugins directory. For specific usage, please refer to the documentation of each plugin or consult its developer.

Management

!plugin Commands

!plugin                     List all installed plugins
!plugin get <repository address>    Install a plugin from a GitHub repository address (requires administrator privileges)
!plugin update all          Update all plugins (requires administrator privileges, only supports plugins installed from repositories)
!plugin update <plugin name>    Update a specific plugin
!plugin del <plugin name>    Delete a plugin (requires administrator privileges)
!plugin on <plugin name>     Enable a plugin (requires administrator privileges)
!plugin off <plugin name>    Disable a plugin (requires administrator privileges)

!func                       List all content functions

plugins/plugins.json Configuration File

When the program starts, it synchronizes the settings here with the actual loaded plugin settings.

This file is automatically generated by the program. Do not manually add or delete items; only modify the priority and enabled status. After modification, a restart is required.

Example:

"plugins": [
    {
        "name": "Nahida",
        "description": "Hello Nahida",
        "version": "0.1",
        "author": "RockChinQ",
        "source": "",   
        "main_file": "plugins/Nahida/main.py",
        "pkg_path": "plugins/Nahida/",
        "priority": 0,  
        "enabled": true   
    }
]

source: Source code address. If empty, it means this plugin does not support automatic updates by the program.

priority: Plugin execution priority. During initialization and event calls, higher-priority plugins will be processed first.

enabled: When set to false, the plugin will not be initialized or called.

Plugin List

Below is a partial list of plugins. For all plugins, please check RockChinQ's Star Collection