@@ -1,42 +0,0 @@
|
||||
# command.json Configuration
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The `data/config/command.json` file is used to configure command-related settings.
|
||||
|
||||
## Command Privilege
|
||||
|
||||
Set the privilege configuration for each command.
|
||||
|
||||
The privilege level for regular users is 1, while the privilege level for administrators (set in `system.json`) is 2.
|
||||
|
||||
Here, you can set the minimum privilege level for each command. If set to 1, both users and administrators can use the command. If set to 2, only administrators can use the command.
|
||||
|
||||
Subcommands need to be specified with a dot separator, such as `"plugin.on"`. Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugin": 1,
|
||||
"plugin.on": 2
|
||||
}
|
||||
```
|
||||
|
||||
This means the minimum privilege level for the `plugin` command is 1, and the minimum privilege level for the `plugin.on` command is 2. Each command has a default privilege level.
|
||||
|
||||
If not set, the default level will be used. The default privilege level for each command class is defined in `pkg/command/operators`.
|
||||
|
||||
## Command Prefix
|
||||
|
||||
Set the command prefix. It is configured as an array, and the program will treat messages that match the prefix as commands (in group chats, they must also comply with group response rules).
|
||||
|
||||
The following example sets the command prefix to `!`, `!`, and `#`:
|
||||
|
||||
```json
|
||||
"command-prefix": [
|
||||
"!",
|
||||
"!",
|
||||
"#"
|
||||
]
|
||||
```
|
||||
@@ -1,203 +0,0 @@
|
||||
# pipeline.json Configuration
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The `data/config/pipeline.json` file configures the operational flow of processing a request. After the platform adapter receives a message event, it sends it to the pipeline for queued processing. You can configure features such as blacklists and whitelists, group response rules, whether to check incoming messages, incoming message ignore rules, whether to check for sensitive words, Baidu Cloud content review settings, incoming message length limits, and rate limiting.
|
||||
|
||||
## Access Control
|
||||
|
||||
```json
|
||||
"access-control":{
|
||||
"mode": "blacklist",
|
||||
"blacklist": [],
|
||||
"whitelist": []
|
||||
},
|
||||
```
|
||||
|
||||
`mode`: Set the mode to either `whitelist` (only process messages from sessions in the `whitelist`) or `blacklist` (ignore messages from sessions in the `blacklist`).
|
||||
|
||||
`blacklist`: Format `{type}_{id}`, example: `"blacklist": ["group_12345678", "person_12341234"]`.
|
||||
|
||||
`whitelist`: Format `{type}_{id}`, example: `"whitelist": ["group_12345678", "person_12341234"]`.
|
||||
|
||||
## Group Message Response Rules
|
||||
|
||||
Only process messages from sessions that pass the `access-control` check. Multiple keys can be included. To set specific response rules for a group, use the group ID as the key. Groups not specified will use the default response rules.
|
||||
|
||||
```json
|
||||
"respond-rules": {
|
||||
"default": {
|
||||
"at": true,
|
||||
"prefix": [
|
||||
"/ai", "!ai", "!ai", "ai"
|
||||
],
|
||||
"regexp": [],
|
||||
"random": 0.0
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
`at`: `true` or `false`. When `true`, all messages that mention the bot will be responded to.
|
||||
|
||||
`prefix`: Set response prefixes. Messages with the specified prefixes will be responded to even if they do not mention the bot. The prefix will be removed before sending to the AI. For example:
|
||||
|
||||
```json
|
||||
"prefix": ["/ai", "!ai", "!ai", "ai"]
|
||||
|
||||
In this case, the message "ai hello" will be responded to, and the prefix "ai" will be removed before sending to the AI, resulting in "hello".
|
||||
```
|
||||
|
||||
`regexp`: Regular expression matching. [Regular Expression Tutorial](https://www.runoob.com/regexp/regexp-syntax.html).
|
||||
|
||||
`random`: Random match probability, ranging from 0.0 to 1.0, corresponding to 0% to 100%. When set to 1.0, all messages will be responded to.
|
||||
|
||||
You can set specific response rules for individual groups, for example:
|
||||
|
||||
```json
|
||||
"respond-rules": {
|
||||
"default": {
|
||||
"at": true,
|
||||
"prefix": [
|
||||
"/ai", "!ai", "!ai", "ai"
|
||||
],
|
||||
"regexp": [],
|
||||
"random": 0.0
|
||||
},
|
||||
"123456":{
|
||||
"at": true,
|
||||
"prefix": [
|
||||
"/ai", "!ai", "!ai", "ai"
|
||||
],
|
||||
"regexp": [],
|
||||
"random": 0.0
|
||||
},
|
||||
"789012":{
|
||||
"at": true,
|
||||
"prefix": [
|
||||
"/ai", "!ai", "!ai", "ai"
|
||||
],
|
||||
"regexp": [],
|
||||
"random": 0.0
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
## Incoming Message Check Switch
|
||||
|
||||
```json
|
||||
"income-msg-check": true,
|
||||
```
|
||||
|
||||
`income-msg-check`: Whether to check incoming messages.
|
||||
|
||||
## Incoming Message Ignore Rules
|
||||
|
||||
```json
|
||||
"ignore-rules": {
|
||||
"prefix": ["/"],
|
||||
"regexp": []
|
||||
},
|
||||
```
|
||||
|
||||
Incoming messages that match the rules will be ignored. Only effective when `income-msg-check` is `true`.
|
||||
|
||||
`prefix`: Ignore messages with the prefix `/`.
|
||||
|
||||
`regexp`: Ignore messages that match the regular expression.
|
||||
|
||||
## Local Sensitive Word Check
|
||||
|
||||
```json
|
||||
"check-sensitive-words": true,
|
||||
```
|
||||
|
||||
`check-sensitive-words`: Whether to check for sensitive words. The sensitive word list is located in `data/config/sensitive-words.json`.
|
||||
|
||||
## Baidu Cloud Content Review Configuration
|
||||
|
||||
```json
|
||||
"baidu-cloud-examine": {
|
||||
"enable": false,
|
||||
"api-key": "",
|
||||
"api-secret": ""
|
||||
},
|
||||
```
|
||||
|
||||
`baidu-cloud-examine`: Controls whether to use Baidu Cloud content review.
|
||||
|
||||
`enable`: When `enable=true`, it will always check the AI response results. Only checks incoming messages when `income-msg-check` is `true`.
|
||||
|
||||
`api-key`: The `API_KEY` from the Baidu AI Open Platform.
|
||||
|
||||
`api-secret`: The `SECRET_KEY` from the Baidu AI Open Platform.
|
||||
|
||||
*`API_KEY` and `SECRET_KEY` are assigned to users after creating an application. They are strings used to identify users and perform signature verification for access. They can be viewed in the **Application List** in the AI Service Console.*
|
||||
|
||||
## Rate Limit Rules
|
||||
|
||||
```json
|
||||
"rate-limit": {
|
||||
"strategy": "drop",
|
||||
"algo": "fixwin",
|
||||
"fixwin": {
|
||||
"default": {
|
||||
"window-size": 60,
|
||||
"limit": 60
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`strategy`: The handling strategy when the request rate exceeds the limit in a session. `drop` discards new requests, while `wait` waits for the request rate to drop below the limit.
|
||||
|
||||
`algo`: The algorithm used. Currently, only `fixwin` (fixed window) is supported, which limits the number of requests processed within a window period. You can implement other rate-limiting algorithms by referring to the plugin development tutorial.
|
||||
|
||||
`fixwin`: Specific rate settings, limiting the number of requests processed within a window period. Supports specifying rate limits for specific sessions in the format `{type}_{id}`, example: `group_12345678`, `person_12341234`.
|
||||
|
||||
`window-size`: The size of the window period in seconds.
|
||||
|
||||
`limit`: The maximum number of requests processed within the window period.
|
||||
|
||||
For example:
|
||||
|
||||
```json
|
||||
"fixwin": {
|
||||
"default": {
|
||||
"window-size": 60,
|
||||
"limit": 60
|
||||
},
|
||||
"group_12345678": {
|
||||
"window-size": 30,
|
||||
"limit": 60
|
||||
},
|
||||
"person_12341234": {
|
||||
"window-size": 60,
|
||||
"limit": 60
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This will set:
|
||||
|
||||
- A default group window period of 60 seconds, with a maximum of 60 requests processed.
|
||||
- A group with ID 12345678 has a window period of 30 seconds, with a maximum of 60 requests processed.
|
||||
- A user with ID 12341234 has a window period of 60 seconds, with a maximum of 60 requests processed.
|
||||
|
||||
## Message History Truncation
|
||||
|
||||
Truncates the current session's message history before sending it to the model to limit the length of the message passed to the model.
|
||||
|
||||
```json
|
||||
"msg-truncate": {
|
||||
"method": "round",
|
||||
"round": {
|
||||
"max-round": 10
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`method`: The truncation method. `round` truncates by rounds. Currently, only `round` is supported. You can implement other truncation methods by referring to the plugin development tutorial.
|
||||
|
||||
`round`: Truncates by rounds. `max-round` specifies the maximum number of historical message rounds to retain.
|
||||
@@ -1,124 +0,0 @@
|
||||
# platform.json Configuration
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The `data/config/platform.json` file configures the message platforms that the program connects to and related message processing settings. This includes the list of enabled message adapters, whether to track the process of content function calls, whether to quote the original message when replying in a group, whether to @ the original user when replying in a group, the forced message delay range, long message handling strategies, and whether to hide AI exception information from users.
|
||||
|
||||
## Message Platform Adapters (platform-adapters)
|
||||
|
||||
```json
|
||||
"platform-adapters": [
|
||||
{
|
||||
"adapter": "nakuru",
|
||||
"enable": false,
|
||||
"host": "127.0.0.1",
|
||||
"ws_port": 8080,
|
||||
"http_port": 5700,
|
||||
"token": ""
|
||||
},
|
||||
{
|
||||
"adapter": "aiocqhttp",
|
||||
"enable": false,
|
||||
"host": "0.0.0.0",
|
||||
"port": 2280,
|
||||
"access-token": "",
|
||||
},
|
||||
{
|
||||
"adapter": "qq-botpy",
|
||||
"enable": false,
|
||||
"appid": "",
|
||||
"secret": "",
|
||||
"intents": [
|
||||
"public_guild_messages",
|
||||
"direct_message"
|
||||
]
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
Currently, four message platform adapters are supported: `go-cqhttp`, `aiocqhttp`, and `qq-botpy`. Multiple adapters of the same or different types can be enabled simultaneously.
|
||||
For configuration details of each message platform, please refer to the deployment documentation.
|
||||
|
||||
### Multiple Adapters Example
|
||||
|
||||
```json
|
||||
"platform-adapters": [
|
||||
{
|
||||
"adapter": "aiocqhttp",
|
||||
"enable": false,
|
||||
"host": "0.0.0.0",
|
||||
"port": 2280,
|
||||
"access-token": "",
|
||||
},
|
||||
{
|
||||
"adapter": "nakuru",
|
||||
"enable": true,
|
||||
"host": "127.0.0.1",
|
||||
"ws_port": 8081,
|
||||
"http_port": 5701,
|
||||
"token": "token"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Track Content Function Calls (track-function-calls)
|
||||
|
||||
```json
|
||||
"track-function-calls": true,
|
||||
```
|
||||
|
||||
Whether to track the process of content function calls. If enabled, the records of content function calls during the conversation will also be sent to the user.
|
||||
|
||||
If disabled (false), only the final result will be sent to the user.
|
||||
|
||||
> For details on the content function feature, please refer to the plugin documentation.
|
||||
|
||||
## Quote Original Message (quote-origin)
|
||||
|
||||
```json
|
||||
"quote-origin": false,
|
||||
```
|
||||
|
||||
Whether to quote the original message when replying in a group.
|
||||
|
||||
## @ Original User (at-sender)
|
||||
|
||||
```json
|
||||
"at-sender": false,
|
||||
```
|
||||
|
||||
Whether to @ the original user when replying in a group.
|
||||
|
||||
## Forced Message Delay Range (force-delay)
|
||||
|
||||
```json
|
||||
"force-delay": [0, 0],
|
||||
```
|
||||
|
||||
The forced message delay range before sending the response back to the user, to prevent risk control. The unit is seconds.
|
||||
|
||||
## Long Message Handling Strategy (long-text-process)
|
||||
|
||||
```json
|
||||
"long-text-process": {
|
||||
"threshold": 256,
|
||||
"strategy": "forward",
|
||||
"font-path": ""
|
||||
},
|
||||
```
|
||||
|
||||
`threshold`: The threshold. Messages longer than this value will use the long message handling strategy.
|
||||
|
||||
`strategy`: The long message handling strategy. Currently supported strategies are `forward` (forward message component) and `image` (convert text to image).
|
||||
|
||||
`font-path`: The font used for rendering images. If not set, on Windows, the system's Microsoft YaHei font will be attempted. If not found, the strategy will switch to `forward`. If not set on non-Windows systems, it will directly switch to `forward`.
|
||||
|
||||
## Hide AI Interface Exception Information from Users (hide-exception-info)
|
||||
|
||||
```
|
||||
"hide-exception-info": true
|
||||
```
|
||||
|
||||
Whether to hide AI exception information from users. If true, when an exception occurs while requesting the AI interface, an error prompt will be returned to the user, and the error details will be output to the console.
|
||||
@@ -1,234 +0,0 @@
|
||||
# provider.json Configuration
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The `data/config/provider.json` file contains configuration items related to AI interface providers.
|
||||
|
||||
## Enable Chat Function (enable-chat)
|
||||
|
||||
```json
|
||||
"enable-chat": true,
|
||||
```
|
||||
|
||||
`enable-chat`: Whether to enable the AI chat function.
|
||||
|
||||
## Enable AI Vision Function (enable-vision)
|
||||
|
||||
```json
|
||||
"enable-vision": true,
|
||||
```
|
||||
|
||||
`enable-vision`: Whether to enable the AI vision function. The model used must also support the vision function. For details, refer to the metadata section.
|
||||
|
||||
## Model API Keys (keys)
|
||||
|
||||
::: info
|
||||
Different model providers may use different API formats. LangBot determines the usage of each model through a triplet (requester, key group, model name). To view supported models or add custom models, refer to the metadata configuration section in the `llm-models.json` file.
|
||||
:::
|
||||
|
||||
```json
|
||||
"keys": {
|
||||
"openai": [
|
||||
"sk-1234567890"
|
||||
],
|
||||
"anthropic": [
|
||||
"sk-1234567890"
|
||||
],
|
||||
"moonshot": [
|
||||
"sk-1234567890"
|
||||
],
|
||||
"deepseek": [
|
||||
"sk-1234567890"
|
||||
],
|
||||
"gitee-ai": [
|
||||
"XXXXX"
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
`keys`: Configure key groups in dictionary format, where each key group's name is the key and the value is a list of keys. For the correspondence between models and key groups, refer to the metadata section in the `llm-models.json` file.
|
||||
|
||||
Currently supported key groups:
|
||||
|
||||
- `openai`: Key group for [OpenAI](https://openai.com/). If you don't have an OpenAI API Key, you can [get one here](https://api.qhaigc.net/).
|
||||
- `anthropic`: Key group for [Anthropic](https://anthropic.com/).
|
||||
- `moonshot`: Key group for [Moonshot](https://moonshot.cn/) (Moonshot AI).
|
||||
- `deepseek`: Key group for [Deepseek](https://deepseek.com/) (Deepseek AI).
|
||||
- `gitee-ai`: Key group for [Gitee AI](https://ai.gitee.com/) Serverless API.
|
||||
|
||||
## Large Model Requester (requester)
|
||||
|
||||
```json
|
||||
"requester": {
|
||||
"openai-chat-completions": {
|
||||
"base-url": "https://api.openai.com/v1",
|
||||
"args": {},
|
||||
"timeout": 120
|
||||
},
|
||||
"anthropic-messages": {
|
||||
"base-url": "https://api.anthropic.com",
|
||||
"args": {
|
||||
"max_tokens": 1024
|
||||
},
|
||||
"timeout": 120
|
||||
},
|
||||
"moonshot-chat-completions": {
|
||||
"base-url": "https://api.moonshot.cn/v1",
|
||||
"args": {},
|
||||
"timeout": 120
|
||||
},
|
||||
"deepseek-chat-completions": {
|
||||
"base-url": "https://api.deepseek.com",
|
||||
"args": {},
|
||||
"timeout": 120
|
||||
},
|
||||
"ollama-chat": {
|
||||
"base-url": "http://127.0.0.1:11434",
|
||||
"args": {},
|
||||
"timeout": 600
|
||||
},
|
||||
"gitee-ai-chat-completions": {
|
||||
"base-url": "https://ai.gitee.com/v1",
|
||||
"args": {},
|
||||
"timeout": 120
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
`requester`: Configure requesters, where each requester's name is the key and the value is the requester configuration. For the correspondence between models and requesters, refer to the metadata section in the `llm-models.json` file. For implementing requesters, refer to the plugin development tutorial.
|
||||
|
||||
Currently supported requesters (unless a new requester is implemented via a plugin, new requester configurations cannot be added to `requester`):
|
||||
|
||||
- `openai-chat-completions`: ChatCompletion requester for [OpenAI](https://openai.com/).
|
||||
- `anthropic-messages`: Requester for [Anthropic](https://anthropic.com/) (Claude).
|
||||
- `moonshot-chat-completions`: Requester for [Moonshot](https://moonshot.cn/) (Moonshot AI).
|
||||
- `deepseek-chat-completions`: Requester for [Deepseek](https://deepseek.com/) (Deepseek AI).
|
||||
- `ollama-chat`: Requester for [Ollama](https://ollama.com/), which does not require a key and directly requests the Ollama service at the target address.
|
||||
- `gitee-ai-chat-completions`: Requester for [Gitee AI](https://ai.gitee.com/) Serverless API (OpenAI-compatible interface).
|
||||
|
||||
`base-url`: Set the API endpoint.
|
||||
|
||||
`args`: Additional parameters for the request, excluding the model, set in dictionary format. Refer to the documentation of each provider for details.
|
||||
|
||||
`timeout`: Set the request timeout in seconds. For models that take longer, it is recommended to set a larger value.
|
||||
|
||||
## Model to Use (model)
|
||||
|
||||
```json
|
||||
"model": "gpt-3.5-turbo",
|
||||
```
|
||||
|
||||
`model`: Set the name of the model to use. This model must exist in the `llm-models.json` metadata.
|
||||
|
||||
For the list of supported models and the corresponding requesters and key groups for each model, refer to the metadata section in the `llm-models.json` file.
|
||||
|
||||
## Scenario Preset (Personality) (prompt)
|
||||
|
||||
```json
|
||||
"prompt-mode": "normal",
|
||||
"prompt": {
|
||||
"default": "If the user wants help later, please say 'Input !help to get help.'."
|
||||
}
|
||||
```
|
||||
|
||||
`prompt-mode`: Set the scenario preset mode, with values `normal` (single preset mode) and `full-scenario` (full historical conversation mode).
|
||||
|
||||
In `normal` mode, use the `prompt` below, which can have multiple entries.
|
||||
|
||||
```json
|
||||
"prompt": {
|
||||
"default": "If the user wants help later, please say 'Input !help to get help.'.",
|
||||
"help": "If the user wants help later, please say 'Input !help to get help.'."
|
||||
}
|
||||
```
|
||||
|
||||
The `normal` mode also supports reading the contents of files in the `data/prompts` directory as individual System Prompts, where the file name is the `prompt` name.
|
||||
|
||||
In use, set it as the default via the `!default set <preset name>` command (replace `<preset name>` entirely).
|
||||
|
||||
### Full-Scenario Mode Configuration
|
||||
|
||||
Add complete historical conversations as files to the `data/scenario/` directory, referencing `data/scenario/default.json`.
|
||||
|
||||
```json
|
||||
{
|
||||
"prompt": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant. If I need help, you should say 'Input !help to get help.'"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Okay, I am a capable AI assistant. If you need help, I will say 'Input !help to get help.'"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`role` is the role of the message, which can be `user` (user), `assistant` (AI), or `system` (system).
|
||||
`content` is a string representing the message content.
|
||||
In use, set it as the default via the `!default set <file name>` command (replace `<preset name>` entirely).
|
||||
|
||||
## Request Runner (runner)
|
||||
|
||||
```json
|
||||
"runner": "local-agent",
|
||||
```
|
||||
|
||||
Set which runner will handle the chat messages. The default is `local-agent`.
|
||||
Currently supported:
|
||||
|
||||
- `local-agent`: A local Agent mechanism implemented by LangBot, managing conversations and invoking plugins. Must be set to `local-agent` to use `content functions`.
|
||||
- `dify-service-api`: Use the Service API mechanism of [Dify](https://dify.ai/), supporting chat assistants, Agents, and workflow applications.
|
||||
|
||||
## Dify Service API Configuration (dify-service-api)
|
||||
|
||||
```json
|
||||
"dify-service-api": {
|
||||
"base-url": "https://api.dify.ai/v1",
|
||||
"app-type": "chat",
|
||||
"chat": {
|
||||
"api-key": "app-1234567890",
|
||||
"timeout": 120
|
||||
},
|
||||
"agent": {
|
||||
"api-key": "app-1234567890",
|
||||
"timeout": 120
|
||||
},
|
||||
"workflow": {
|
||||
"api-key": "app-1234567890",
|
||||
"output-key": "summary",
|
||||
"timeout": 120
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Only when `runner` is set to `dify-service-api`, configure the following:
|
||||
|
||||
- `base-url`: The address of the Dify Service API, default is `https://api.dify.ai/v1`, which is the address of the official Dify cloud service. If you are using a self-deployed community edition, set it to your self-deployed address.
|
||||
- `app-type`: The type of Dify application to use. Supports `chat` - chat assistant (including advanced orchestration), `agent` - Agent, `workflow` - workflow; fill in the corresponding API parameters for the application type below.
|
||||
- `chat`: Configuration for Dify chat assistant applications.
|
||||
- `api-key`: API key for the Dify chat assistant application.
|
||||
- `timeout`: Request timeout for the Dify chat assistant application, in seconds, default is 120 seconds.
|
||||
- `agent`: Configuration for Dify Agent applications.
|
||||
- `api-key`: API key for the Dify Agent application.
|
||||
- `timeout`: Request timeout for the Dify Agent application, in seconds, default is 120 seconds.
|
||||
- `workflow`: Configuration for Dify workflow applications.
|
||||
- `api-key`: API key for the Dify workflow application.
|
||||
- `output-key`: Output key for the Dify workflow application, used to retrieve the output results of the workflow application. Default is `summary`, corresponding to the output variable of the end node in the workflow orchestration.
|
||||
- `timeout`: Request timeout for the Dify workflow application, in seconds, default is 120 seconds.
|
||||
|
||||

|
||||
|
||||
When using workflows, LangBot will explicitly pass the following parameters, which you can add to the start node of the Dify workflow:
|
||||
|
||||
- `langbot_user_message_text`: Plain text of the user's message.
|
||||
- `langbot_session_id`: User session ID, `person_<id>` for private chats, `group_<id>` for group chats.
|
||||
- `langbot_conversation_id`: User conversation ID, generated by LangBot. It will be regenerated after the user resets the conversation.
|
||||
|
||||

|
||||
|
||||
When using workflow applications or Agent applications, if `track-function-calls` in `platform.json` is enabled, a message `Calling function xxx` will be output to the user when Dify executes each tool call.
|
||||
However, if using `ChatFlow` under the `chat` application (chat assistant -> workflow orchestration), only the text returned by the Answer (direct reply) node will be output.
|
||||
@@ -1,131 +0,0 @@
|
||||
# system.json Configuration Items
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The `data/config/system.json` file is used to configure system settings, such as administrators, network proxies, whether to report telemetry data for developer analysis, logging level, session message processing concurrency, pipeline message processing concurrency, help messages, and more.
|
||||
|
||||
## Admin Sessions (admin-sessions)
|
||||
|
||||
```json
|
||||
"admin-sessions": [],
|
||||
```
|
||||
|
||||
`admin-sessions`: Set administrator sessions in the format {type}_{id}, where type is either "group" or "person". For example:
|
||||
|
||||
```json
|
||||
"admin-sessions": ["group_123456789", "person_123456789"],
|
||||
```
|
||||
|
||||
::: info
|
||||
1. If you are using the official QQ API, the session ID is the mapped value. You can refer to [qq-botpy metadata](https://docs.langbot.app/config/metadata/adapter-qq-botpy.html) or check the console output when the program processes messages.
|
||||
2. If a session specifies a group, all messages from everyone in that group will be considered as administrator messages.
|
||||
:::
|
||||
|
||||
## Network Proxies (network-proxies)
|
||||
|
||||
::: info
|
||||
It is recommended to set proxies via environment variables, as the configuration file settings **will override environment variables**.
|
||||
Environment variables to set: `http_proxy` and `https_proxy`
|
||||
:::
|
||||
|
||||
```json
|
||||
"network-proxies": {
|
||||
"http": null,
|
||||
"https": null
|
||||
},
|
||||
```
|
||||
|
||||
`network-proxies`: Set up network proxies, which are forward proxies. Both http and https must be filled in. For example:
|
||||
|
||||
```json
|
||||
"network-proxies": {
|
||||
"http": "http://127.0.0.1:7890",
|
||||
"https": "http://127.0.0.1:7890"
|
||||
},
|
||||
```
|
||||
|
||||
## Report Telemetry Data (report-usage)
|
||||
|
||||
```json
|
||||
"report-usage": true,
|
||||
```
|
||||
|
||||
`report-usage`: Whether to report telemetry data for developer analysis. This does not include sensitive information.
|
||||
|
||||
## Logging Level (logging-level)
|
||||
|
||||
```json
|
||||
"logging-level": "info",
|
||||
```
|
||||
|
||||
`logging-level`: Currently unused. Debug logging can only be enabled via the environment variable DEBUG=true.
|
||||
|
||||
## Session Message Processing Concurrency (session-concurrency)
|
||||
|
||||
```json
|
||||
"session-concurrency": {
|
||||
"default": 1
|
||||
},
|
||||
```
|
||||
|
||||
`session-concurrency`: The concurrency level for session message processing, granular to each session. The session format is {type}_{id}. Sessions not specified will use the default configuration.
|
||||
|
||||
## Pipeline Message Processing Concurrency (pipeline-concurrency)
|
||||
|
||||
```json
|
||||
"pipeline-concurrency": 20,
|
||||
```
|
||||
|
||||
`pipeline-concurrency`: The concurrency level for pipeline message processing, granular to the entire program. Currently, the FCFS algorithm is used to schedule requests.
|
||||
|
||||
## Telemetry Server URL (qcg-center-url)
|
||||
|
||||
The target URL for pushing telemetry data during LangBot operation. The default is the official URL. If you have deployed [qcg-center](https://github.com/RockChinQ/qcg-center) yourself, you can change it to your own URL.
|
||||
|
||||
```json
|
||||
"qcg-center-url": "https://api.qchatgpt.rockchin.top/api/v2"
|
||||
```
|
||||
|
||||
## Help Message (help-message)
|
||||
|
||||
```json
|
||||
"help-message": "LangBot - 😎High stability, 🧩plugin support, 🦄multimodal ChatGPT QQ bot🤖\nLink: https://langbot.app"
|
||||
```
|
||||
|
||||
`help-message`: The help message displayed when a user sends the !help command.
|
||||
|
||||
## HTTP Interface (http-api)
|
||||
|
||||
Configure the HTTP service, which needs to be enabled to access the WebUI.
|
||||
|
||||
```json
|
||||
"http-api": {
|
||||
"enable": true,
|
||||
"host": "0.0.0.0",
|
||||
"port": 5300,
|
||||
"jwt-expire": 604800
|
||||
},
|
||||
```
|
||||
|
||||
`enable`: Whether to enable the HTTP interface
|
||||
`host`: The address the HTTP interface listens on
|
||||
`port`: The port the HTTP interface listens on
|
||||
`jwt-expire`: JWT expiration time in seconds
|
||||
|
||||
## Persistence Configuration (persistence)
|
||||
|
||||
Configure database information.
|
||||
|
||||
```json
|
||||
"persistence": {
|
||||
"sqlite": {
|
||||
"path": "data/persistence.db"
|
||||
},
|
||||
"use": "sqlite"
|
||||
}
|
||||
```
|
||||
|
||||
`sqlite`: Use SQLite database, `path` is the database file path
|
||||
`use`: Which database to use, currently only `sqlite` is supported
|
||||
@@ -1,21 +0,0 @@
|
||||
# adapter-qq-botpy.json Metadata
|
||||
|
||||
`data/metadata/adapter-qq-botpy.json` is the metadata for the QQ official API adapter. When using the group chat interface of the official API, the group ID and member ID are in string format, while LangBot internally only supports integer IDs. To ensure that the same correspondence is maintained after a restart, this data needs to be saved to a file.
|
||||
|
||||
## Format
|
||||
|
||||
```json
|
||||
{
|
||||
"mapping": {
|
||||
"groups": {
|
||||
"15944D6D2B525C6E3536134D4669F067": 443241151434655
|
||||
},
|
||||
"members": {
|
||||
"547A6244A731B4BEEBE5EE2AE4CD00A8": 232437565267568
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `groups`: Group ID mapping, where the key is the string group ID and the value is the integer group ID.
|
||||
- `members`: Member ID mapping, where the key is the string member ID and the value is the integer member ID.
|
||||
@@ -1,53 +0,0 @@
|
||||
# llm-models.json Metadata
|
||||
|
||||
`data/metadata/llm-models.json` is a list of supported large language models. This file specifies the models that can be used in the `model` list within `data/config/provider.json`, and it defines the corresponding `Key Manager` and `API Requester` for each model.
|
||||
|
||||
## Format
|
||||
|
||||
```json
|
||||
{
|
||||
"list": [
|
||||
{
|
||||
"name": "default",
|
||||
"requester": "openai-chat-completions",
|
||||
"token_mgr": "openai",
|
||||
"tool_call_supported": false,
|
||||
"vision_supported": false
|
||||
},
|
||||
{
|
||||
"name": "gpt-3.5-turbo",
|
||||
"tool_call_supported": true
|
||||
},
|
||||
{
|
||||
"name": "gpt-4o",
|
||||
"tool_call_supported": true,
|
||||
"vision_supported": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The models are listed in the `list` array, and each model has the following fields:
|
||||
|
||||
- `name`: The name of the model, used to specify the model in the `model` list within `data/config/provider.json`.
|
||||
- `model_name`: The model name used when making requests, used to distinguish between the same model using different requesters. If not set, the `name` field will be used.
|
||||
- `requester`: The name of the requester, specifying which requester to use to get responses from this model. Different requesters correspond to different API formats.
|
||||
- For supported requesters, please refer to the `requester` field in the `provider.json` configuration file.
|
||||
- To implement a new requester, you need to write a plugin. Please refer to the `Component Extension` section in the plugin development documentation.
|
||||
- `token_mgr`: The Key Manager, specifying the key group used by this model, corresponding to the `keys` list in `data/config/provider.json`.
|
||||
- `tool_call_supported`: Whether the model supports tool calls, indicating if the model can use `content functions`.
|
||||
- `vision_supported`: Whether the model supports image input, indicating if the model can use `image input`.
|
||||
|
||||
The `default` model is mandatory and serves as the default configuration for models. Other models do not need to set all fields; only the `name` field is required, and other fields will inherit the configuration from the `default` model.
|
||||
|
||||
## Automatic Update Mechanism
|
||||
|
||||
Every time LangBot starts, the program automatically fetches the latest model list from the central server. The `name` field in the local `llm-models.json` is compared with the model list returned by the central server. If a model does not exist locally, it will be added. If it already exists locally, it will be overwritten by the remote version.
|
||||
|
||||
## Custom Models
|
||||
|
||||
You can add custom models by following the format described above.
|
||||
|
||||
- If you need to use an interface (requester) that is currently not supported, you will need to extend the requester yourself. Please refer to the plugin development documentation -> Component Extension.
|
||||
- You can add your own key groups in the `keys` list within `data/config/provider.json`.
|
||||
- It is not recommended to modify the default model configuration, as it will be overwritten by the automatically updated information upon startup.
|
||||
@@ -1,3 +0,0 @@
|
||||
# sensitive-words.json Metadata
|
||||
|
||||
This is a local sensitive word dictionary. You can modify it by referring to the content of `data/metadata/sensitive-words.json`.
|
||||
@@ -1,35 +0,0 @@
|
||||
# Docker Deployment (Recommended for Linux Only)
|
||||
|
||||
:::warning
|
||||
Please **ensure** you have the following capabilities:
|
||||
- Familiarity with `Docker` and `Docker Compose`
|
||||
- Understanding of network communication configuration between containers
|
||||
- Knowledge of container file mounting mechanisms
|
||||
- Strong hands-on skills and ability to search for resources
|
||||
:::
|
||||
|
||||
:::info
|
||||
Please make sure Git, Docker, and Docker Compose are installed first.
|
||||
:::
|
||||
|
||||
Clone the project using Git:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/RockChinQ/LangBot
|
||||
cd LangBot
|
||||
```
|
||||
|
||||
Start the container:
|
||||
|
||||
```bash
|
||||
docker compose up
|
||||
```
|
||||
|
||||
On the first startup, you will be prompted to create a configuration file. Please proceed with the configuration as instructed.
|
||||
|
||||
The container will map port `5300` for the WebUI, which you can access at `http://127.0.0.1:5300`.
|
||||
It will also map ports `2280-2290` for reverse connections from message platform adapters using the OneBot protocol. Please continue reading the [Message Platform Integration Documentation](/deploy/platforms/aiocqhttp/napcat).
|
||||
|
||||
## Notes
|
||||
|
||||
- Installed plugins will be saved in the `plugins` directory (mapped to the local `plugins` directory). When installing plugins, the necessary dependencies may be automatically installed. If you **recreate** the container, the installed plugins will be loaded, but the incremental dependencies will not be installed, which may cause issues. You can delete the plugin directory and restart, then reinstall the plugins to allow the program to automatically install the required dependencies.
|
||||
@@ -1,84 +0,0 @@
|
||||
# Manual Deployment (Recommended, Works on All Platforms)
|
||||
|
||||
:::warning
|
||||
1. Please use Python 3.10.1 (excluding 3.10.0) or higher. Version 3.10.14 is recommended. If you don't have Python installed, you need to install it yourself.
|
||||
:::
|
||||
|
||||
## Installing the Main Program
|
||||
|
||||
1. Go to the [Release](https://github.com/RockChinQ/LangBot/releases) page and download the latest version of the compressed package (recommended) `langbot-xxx-all.zip` (do not download the Source Code as it does not include the WebUI). Extract the package and open the command line (terminal) in the extracted directory.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
|
||||
You can also use the following command to clone the latest code (which may contain unstable code) and use it:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/RockChinQ/LangBot
|
||||
cd LangBot
|
||||
|
||||
# Build the frontend, requires NodeJS >= 22
|
||||
cd web
|
||||
npm install && npm run build
|
||||
cd ..
|
||||
```
|
||||
:::
|
||||
|
||||
2. (Recommended) Create a virtual environment
|
||||
|
||||
On some Linux systems that use the system package manager to manage Python dependencies, dependency conflicts may occur. Therefore, please use venv to create a virtual environment. Windows users can skip this step.
|
||||
|
||||
```bash
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Or use the Tsinghua mirror
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
```
|
||||
|
||||
3. Run the main program once to generate the configuration file
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
The following message will be displayed
|
||||
|
||||
```
|
||||
_ ___ _
|
||||
| | __ _ _ _ __ _| _ ) ___| |_
|
||||
| |__/ _` | ' \/ _` | _ \/ _ \ _|
|
||||
|____\__,_|_||_\__, |___/\___/\__|
|
||||
|___/
|
||||
|
||||
⭐️Open Source Address: https://github.com/RockChinQ/LangBot
|
||||
📖Documentation Address: https://docs.langbot.app
|
||||
|
||||
The following files do not exist and have been automatically generated. Please modify the configuration files as needed and restart:
|
||||
- plugins/__init__.py
|
||||
- plugins/plugins.json
|
||||
- data/config/command.json
|
||||
- data/config/pipeline.json
|
||||
- data/config/platform.json
|
||||
- data/config/provider.json
|
||||
- data/config/system.json
|
||||
- data/config/sensitive-words.json
|
||||
- data/scenario/default.json
|
||||
```
|
||||
|
||||
You can now exit the program using Ctrl+C and continue to the [Deploying Message Platform](/deploy/platforms/aiocqhttp/napcat.html) page.
|
||||
|
||||
After deploying the message platform and filling in the configuration files, run the program again:
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
@@ -1,51 +0,0 @@
|
||||
# Deploying with BT Panel
|
||||
|
||||
Deploy LangBot with one click using the [BT Panel](https://www.bt.cn/new/download.html?r=dk_LangBot).
|
||||
|
||||
## Installing BT Panel
|
||||
|
||||
:::warning
|
||||
If you have already installed BT Panel, please update to version **9.2.0** or above.
|
||||
:::
|
||||
|
||||
> Recommended server systems (from BT Panel): Debian 12, Ubuntu 22, etc.
|
||||
>
|
||||
> This guide assumes the server has a public IPv4 address. If you are using a home machine without a public IP, you can access the relevant pages via the intranet as described below.
|
||||
|
||||
Open the [BT Panel](https://www.bt.cn/new/download.html?r=dk_LangBot) and use the Linux panel installation script provided by BT Panel. Choose the script corresponding to your system.
|
||||
|
||||

|
||||
|
||||
Copy the corresponding script and paste it into your server to execute.
|
||||
|
||||
## Installing LangBot
|
||||
|
||||
After waiting for a while, the BT Panel installation will be completed.
|
||||
|
||||
You will see a prompt similar to the following. Copy the external panel address and open it in your browser.
|
||||
|
||||

|
||||
|
||||
The first time you open it, a `Recommended Installation Suite` popup may appear. You can skip this by closing it.
|
||||
|
||||
Then, click on the `docker` option in the sidebar. If it’s your first time, you will be prompted to install Docker and Docker Compose services. Click `Install Now`. If they are already installed, you can ignore this step.
|
||||
|
||||
Next, go to `Docker -> App Store`, search for `LangBot` (note the case sensitivity), and click `Install` using the default configuration.
|
||||
|
||||
After a short wait, you will see a container named `langbot_XXXX` showing as `Running`.
|
||||
|
||||

|
||||
|
||||
Click on the red circle in the image above to view the running logs.
|
||||
|
||||

|
||||
|
||||
You will see the external and internal access paths for the WebUI configuration page (visual configuration page). Copy the public address, for example, `http://xxx.xxx.xxx.xxx:5300` (where `xxx.xxx.xxx.xxx` is the BT Panel IP and `5300` is the port number, which may vary as shown in the image).
|
||||
|
||||
Open the address, enter the admin email and password, and then click `Initialize`.
|
||||
|
||||
You can now configure settings in the visual interface.
|
||||
|
||||
If you prefer to directly modify the JSON configuration file, you can refer to the local mapped directory shown in the image above. Navigate to the installation directory, where the `data` folder stores configuration files and the `plugins` folder stores plugin-related files.
|
||||
|
||||
Next, please continue reading the [Deploying Message Platform](/deploy/platforms/aiocqhttp/napcat.html) page.
|
||||
@@ -1,54 +0,0 @@
|
||||
# Detailed Network Configuration
|
||||
|
||||
LangBot and some messaging platforms can be deployed using Docker. Below is a detailed explanation of network configurations for four scenarios.
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## Both LangBot and Messaging Platform Run in Docker Containers
|
||||
|
||||
If both the messaging platform (NapCat/Lagrange) and LangBot are started using Docker, you need to configure the Docker network connection.
|
||||
|
||||
Create a new network:
|
||||
|
||||
```bash
|
||||
docker network create langbot-network
|
||||
```
|
||||
|
||||
Add the network configuration to the `docker-compose.yaml` file in the LangBot directory (add it under the `services.langbot` field and include the `langbot-network` configuration under the `networks` field):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
langbot:
|
||||
...
|
||||
networks:
|
||||
- langbot-network
|
||||
...
|
||||
|
||||
networks:
|
||||
langbot-network:
|
||||
external: true
|
||||
```
|
||||
|
||||
Then, add the same network configuration to the `docker-compose.yaml` file of the messaging platform (if the messaging platform is started using the `docker run` command, add `--network langbot-network` to the startup command). Next, modify the IP address in the WS reverse connection address in the messaging platform configuration file to `langbot` (e.g., `ws://langbot:2280/ws`).
|
||||
|
||||
Restart both containers.
|
||||
|
||||
## Only LangBot Runs in a Docker Container
|
||||
|
||||
When only LangBot is deployed using Docker, ports 2280 to 2290 are mapped to the host by default. In this case, LangBot can only act as a WebSocket server, accepting connections from the messaging platform as a client.
|
||||
|
||||
Set the messaging platform to ReverseWebSocket (referred to as `reverse ws` or `WebSocket client`), with the port corresponding to the port enabled by LangBot's aiocqhttp adapter, and connect to localhost 127.0.0.1.
|
||||
|
||||
## Neither LangBot nor Messaging Platform Uses Docker Deployment
|
||||
|
||||
Configure the messaging platform and LangBot settings according to the documentation, ensuring both use the same unused port, and connect to localhost 127.0.0.1.
|
||||
|
||||
## Only Messaging Platform Runs in a Docker Container (Not Recommended)
|
||||
|
||||
:::warning
|
||||
Only supported on Linux or other systems that support host mode Docker networking.
|
||||
:::
|
||||
|
||||
Currently, LangBot's aiocqhttp adapter only supports reverse WebSocket connections. When the messaging platform runs in a Docker container and LangBot runs directly on the host, the messaging platform must act as a client to connect to LangBot. In this case, you must set the messaging platform's network to `host` mode and configure its WS connection address to 127.0.0.1, with the port corresponding to the port enabled by LangBot's aiocqhttp adapter.
|
||||
@@ -1,56 +0,0 @@
|
||||
# Deploying the Message Platform Lagrange
|
||||
|
||||
## Introduction to Lagrange
|
||||
|
||||
Lagrange is a reverse engineering framework for the QQNT protocol, designed to be lightweight and relatively stable. It connects via the OneBot 11 protocol and requires the use of `aiocqhttp` as the adapter.
|
||||
|
||||
::: warning
|
||||
You need to use NT QQ to interact with the bot; the older version of QQ will not work properly.
|
||||
:::
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
The following provides a general guide for deployment on Windows. For detailed steps or instructions for other platforms, please refer to the [Lagrange Official Documentation](https://lagrangedev.github.io/Lagrange.Doc/Lagrange.OneBot/).
|
||||
|
||||
### Environment Setup
|
||||
|
||||
Install the .NET 8 runtime. [Click here to download directly from the Microsoft official website](https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-desktop-8.0.4-windows-x64-installer).
|
||||
|
||||
### Download the Latest Build from Github Actions
|
||||
|
||||
You need to log in to Github to download. If you don't need certain features, you can download from the Release section. Refer to image 3.
|
||||
|
||||
[Github Actions](https://github.com/KonataDev/Lagrange.Core/actions)
|
||||
|
||||
Follow the images to download:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Final Steps
|
||||
|
||||
Unzip the downloaded zip file, navigate to the directory containing `Lagrange.OneBot.exe`, and open a command prompt in this directory. Enter the following command:
|
||||
|
||||
```bash
|
||||
.\Lagrange.OneBot
|
||||
```
|
||||
|
||||
Run it once. If a QR code is output, you can directly scan it with your bot account to log in (if the QR code is unclear, you can find the image file in the `lagrange/data` directory).
|
||||
|
||||
If you cannot log in, please check if the `SignServerUrl` in the `appsettings.json` configuration file of Lagrange is correctly filled. You can find the signing address in the Lagrange documentation.
|
||||
|
||||
## Modifying Configuration
|
||||
|
||||
To configure Lagrange to connect to LangBot, edit the `appsettings.json` configuration file of Lagrange. Ensure that the connection settings under `Implementations` match the content shown in the image below:
|
||||
|
||||

|
||||
|
||||
The `Type` must be `ReverseWebSocket`;
|
||||
The `Host` should be the IP address of the host running LangBot. If it's on the same host, you can use `127.0.0.1`;
|
||||
The `Suffix` must be `/ws`;
|
||||
The `Port` must match the port that the `aiocqhttp` adapter in the LangBot message platform configuration is listening on.
|
||||
|
||||
Next, please read [Filling in Configuration Information](/deploy/quick-config/config).
|
||||
@@ -1,13 +0,0 @@
|
||||
# Deploying the Message Platform LiteLoaderQQNT
|
||||
|
||||
# LiteLoaderQQNT
|
||||
|
||||
- [LiteLoaderQQNT's OneBot API Plugin](https://github.com/LLOneBot/LLOneBot) injects into the QQ client and converts it to the OneBot 11 protocol.
|
||||
|
||||
Tutorial for installing LiteLoaderQQNT: https://llonebot.github.io/zh-CN/guide/getting-started
|
||||
|
||||

|
||||
|
||||
Ensure that the IP address in the URL is the address of the host running LangBot (use 127.0.0.1 if running on the same network), the port must match the port that the aiocqhttp adapter in the LangBot message platform configuration is listening on, and the suffix must be `/ws`:
|
||||
|
||||
Next, please read [Filling in Configuration Information](/deploy/quick-config/config).
|
||||
@@ -1,27 +0,0 @@
|
||||
# Deploying the Messaging Platform NapCat
|
||||
|
||||
## NapCat Installation Tutorial
|
||||
|
||||
Follow the [NapCat Official Documentation for Installation](https://napcat.napneko.icu/guide/start-install).
|
||||
|
||||
## NapCat Configuration Tutorial
|
||||
|
||||
This example uses the webui operation. For other configuration methods, please refer to the NapCat documentation.
|
||||
|
||||
After logging in, you can view the logs in the console or Bash. Look for the following line:
|
||||
`[NapCat] [WebUi] WebUi Publish Panel Url: http://x.x.x.x:6099/webui?token=xxxxx`
|
||||

|
||||
|
||||
Copy the URL to your browser, or on Windows 11, press Ctrl and click the URL. After scanning the QR code to log in, you will be directed to the network configuration page.
|
||||
|
||||
Click to add a network configuration for the WebSocket client, then enable it. In the URL field, enter `ws://127.0.0.1:2280/ws` and save it.
|
||||

|
||||

|
||||
|
||||
::: info
|
||||
- The port number depends on the `port` field of `aiocqhttp` in `data/config/platform.json`. The default is 2280. Please refer to [Filling in Configuration Information](/deploy/quick-config/config) to continue the configuration.
|
||||
- You must use the WebSocket Client (Reverse WS) to connect to LangBot. Make sure to modify the IP address and port according to your actual situation, and the suffix must be `/ws`.
|
||||
- If both LangBot and NapCat are running in containers, please refer to [Container Network Configuration](/deploy/network-details).
|
||||
:::
|
||||
|
||||
Next, please read [Filling in Configuration Information](/deploy/quick-config/config).
|
||||
@@ -1,75 +0,0 @@
|
||||
# Deploying the Shamrock Messaging Platform
|
||||
|
||||
> This document only covers the basic steps. For detailed operations, troubleshooting, and the latest information, please refer to the [OpenShamrock Official Documentation](https://whitechi73.github.io/OpenShamrock/).
|
||||
|
||||
::: tip
|
||||
|
||||
Project archived, not recommended for continued use.
|
||||
|
||||
:::
|
||||
|
||||
## Introduction to OpenShamrock
|
||||
|
||||
While tools like go-cqhttp simulate the QQ protocol for communication, Shamrock uses Android hooks to simulate clicks on QQ, offering higher stability.
|
||||
|
||||
Optional platforms (or devices):
|
||||
|
||||
- Emulator
|
||||
- Linux server
|
||||
- PVE
|
||||
- Cloud phone
|
||||
- Physical phone
|
||||
|
||||
## Steps (Emulator)
|
||||
|
||||
### Environment Setup
|
||||
|
||||
**Note: It is recommended to use the [mumu emulator](https://mumu.163.com/).**
|
||||
|
||||
Refer to [this document](https://forum.libfekit.so/d/60-mumu12mo-ni-qi-an-zhuang-magiskhe-lsposed) to install Magisk and LSPosed.
|
||||
|
||||
Remember to enable the writable system disk and root permissions in the mumu emulator.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Installing OpenShamrock
|
||||
|
||||
Download the latest OpenShamrock installation package from [OpenShamrock's Actions](https://github.com/whitechi73/OpenShamrock/actions). Make sure to download the version with the `all` suffix, such as `Shamrock-v1.0.7.r253.81be383-all.zip`. Extract the package and install it in the mumu emulator.
|
||||
|
||||
#### Configuring Shamrock
|
||||
|
||||
1. Modify the settings on the Shamrock settings page as shown:
|
||||
|
||||
Enable passive WebSocket and fill in the address and port that the LangBot's aiocqhttp adapter is listening on (see the configuration information page for details).
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
The passive WebSocket address should be the address and port that the LangBot's aiocqhttp adapter is listening on, and the path must be `/ws`, for example, `ws://127.0.0.1:2280/ws`. Refer to the configuration information page for details.
|
||||
|
||||
2. Go to the LSPosed module management page and enable the Shamrock module.
|
||||
|
||||

|
||||
|
||||
### Installing QQ
|
||||
|
||||
Refer to [this page](https://whitechi73.github.io/OpenShamrock/guide/faq.html#%E6%94%AF%E6%8C%81%E7%9A%84qq%E7%89%88%E6%9C%AC) for the supported QQ versions and choose the latest one.
|
||||
|
||||
Download the corresponding version from [here](https://qq.cn.uptodown.com/android/versions) and install it in the mumu emulator.
|
||||
|
||||
### Logging into the Bot QQ Account
|
||||
|
||||
1. Open QQ, log in to the bot QQ account, close QQ, and restart the emulator.
|
||||
2. Start LSPosed, and Shamrock will automatically run. Start QQ.
|
||||
3. Open the Shamrock page, and it should display `Activated` and show the account information and related message logs.
|
||||
|
||||
### Next Steps
|
||||
|
||||
Refer to the configuration information page to connect via the aiocqhttp adapter.
|
||||
|
||||

|
||||
|
||||
Next, please read [Filling in Configuration Information](/deploy/quick-config/config).
|
||||
@@ -1,150 +0,0 @@
|
||||
# Deploying the Messaging Platform go-cqhttp
|
||||
|
||||
> This document only covers the basic steps. For detailed operations, troubleshooting, and the latest information, please refer to the [official go-cqhttp documentation](https://docs.go-cqhttp.org/).
|
||||
|
||||
::: warning
|
||||
|
||||
gocq is not archived, but the original developer has stated: [https://github.com/Mrs4s/go-cqhttp/issues/2471](https://github.com/Mrs4s/go-cqhttp/issues/2471)
|
||||
|
||||
:::
|
||||
|
||||
## Download go-cqhttp
|
||||
|
||||
Download the latest go-cqhttp executable from the [go-cqhttp Release](https://github.com/Mrs4s/go-cqhttp/releases/latest) (it is recommended to directly download the executable zip file instead of the installer).
|
||||
|
||||

|
||||
|
||||
## Run and Configure go-cqhttp
|
||||
|
||||
Unzip and run the file. The first time you run it, it will ask for the network protocol to be opened. **Please enter `02` and press Enter. You must enter `02`❗❗❗❗❗❗❗**
|
||||
|
||||
```
|
||||
C:\Softwares\go-cqhttp.old> .\go-cqhttp.exe
|
||||
Configuration file not found, generating configuration file for you!
|
||||
Please select the communication method you need:
|
||||
> 0: HTTP communication
|
||||
> 1: Cloud function service
|
||||
> 2: Forward Websocket communication
|
||||
> 3: Reverse Websocket communication
|
||||
Please enter the number(s) you need (0-9), you can enter multiple, and the same number can be entered multiple times (e.g., 233)
|
||||
Your choice is:02
|
||||
```
|
||||
|
||||
A prompt will indicate that the `config.yml` file has been generated. Close go-cqhttp.
|
||||
|
||||
Open the `config.yml` file in the same directory as go-cqhttp.
|
||||
|
||||
1. Edit the account login information
|
||||
|
||||
Only modify the `uin` and `password` below to the QQ number and password of the bot account you want to log in to.
|
||||
|
||||
```yaml
|
||||
account: # Account related
|
||||
uin: 1233456 # QQ account
|
||||
password: '' # Use QR code login when the password is empty
|
||||
encrypt: false # Whether to enable password encryption
|
||||
status: 0 # Online status, please refer to https://docs.go-cqhttp.org/guide/config.html#在线状态
|
||||
relogin: # Reconnection settings
|
||||
delay: 3 # First reconnection delay, in seconds
|
||||
interval: 3 # Reconnection interval
|
||||
max-times: 0 # Maximum reconnection times, 0 means unlimited
|
||||
```
|
||||
|
||||
2. Modify the websocket port
|
||||
|
||||
Find the following content in `config.yml`
|
||||
|
||||
```yaml
|
||||
- ws:
|
||||
# Forward WS server listening address
|
||||
address: 0.0.0.0:8080
|
||||
middlewares:
|
||||
<<: *default # Reference default middleware
|
||||
```
|
||||
|
||||
**Change `0.0.0.0:8080` to `0.0.0.0:6700`**, save and close `config.yml`.
|
||||
|
||||
3. Configure the signature server
|
||||
|
||||
Fill in as follows,
|
||||
|
||||
```yaml
|
||||
sign-servers:
|
||||
- url: 'https://qsign.trpgbot.com/' # Main signature server address, required
|
||||
key: 'selfshare'
|
||||
authorization: '-'
|
||||
- url: 'https://qsign-v3.trpgbot.com/' # Secondary server address, optional
|
||||
key: 'selfshare'
|
||||
authorization: '-'
|
||||
|
||||
auto-register: true
|
||||
```
|
||||
|
||||
Write to the file /data/versions/6.json,
|
||||
|
||||
```json
|
||||
{
|
||||
"apk_id": "com.tencent.mobileqq",
|
||||
"app_id": 537220362,
|
||||
"sub_app_id": 537220362,
|
||||
"app_key": "0S200MNJT807V3GE",
|
||||
"sort_version_name": "9.0.56.16830",
|
||||
"build_time": 1713424357,
|
||||
"apk_sign": "a6b745bf24a2c277527716f6f36eb68d",
|
||||
"sdk_version": "6.0.0.2560",
|
||||
"sso_version": 21,
|
||||
"misc_bitmap": 150470524,
|
||||
"main_sig_map": 34869472,
|
||||
"sub_sig_map": 66560,
|
||||
"dump_time": 1713424357,
|
||||
"qua": "V1_AND_SQ_9.0.56_6372_YYB_D",
|
||||
"protocol_type": 6
|
||||
}
|
||||
```
|
||||
|
||||
Thanks to zhaodice for bringing the QQ 9.0.56 signature server.
|
||||
|
||||
4. If your server is on the public network, it is strongly recommended to fill in the `access-token` (optional)
|
||||
|
||||
```yaml
|
||||
# Default middleware anchor
|
||||
default-middlewares: &default
|
||||
# Access token, strongly recommended for servers on the public network
|
||||
access-token: ''
|
||||
```
|
||||
|
||||
5. Configuration is complete, restart go-cqhttp.
|
||||
|
||||
## Login
|
||||
|
||||
Double-click the login script. After a while, you will see a prompt.
|
||||
|
||||

|
||||
|
||||
Copy the link after `Captcha link: ` and open it in Chrome or Edge. Press F12 to open the developer tools.
|
||||
|
||||
Open `Network`.
|
||||
|
||||

|
||||
|
||||
Complete the verification in the browser. In `Network`, find the request named `cap_union_new_verify`, at the very bottom.
|
||||
|
||||

|
||||
|
||||
The content after `ticket` is what you need to input back into go-cqhttp, but do not include the double quotes at the beginning and end.
|
||||
|
||||
**Note**
|
||||
|
||||
- Remember to delete the quotes (`"`, there is one at the beginning and end) when copying, as they are not part of the ticket content.
|
||||
- Be quick.
|
||||
- Make sure not to miss any characters (the content is long, make sure you copy it all).
|
||||
|
||||
Paste the copied content into the terminal running go-cqhttp.
|
||||
|
||||

|
||||
|
||||
> If the login is unsuccessful after starting, please try modifying the protocol number in `device.json` according to [this document](https://docs.go-cqhttp.org/guide/config.html#%E8%AE%BE%E5%A4%87%E4%BF%A1%E6%81%AF).
|
||||
|
||||
## Next Steps
|
||||
|
||||
Check the configuration information page and connect via the Nakuru adapter.
|
||||
@@ -1,153 +0,0 @@
|
||||
# Deploying the Mirai Messaging Platform
|
||||
|
||||
> This document provides only the basic steps. For detailed operations, troubleshooting, and the latest information, please visit the [Mirai Official Repository](https://github.com/mamoe/mirai) and the [Mirai Official Forum](https://mirai.mamoe.net/).
|
||||
|
||||
::: warning
|
||||
|
||||
This messaging platform is unstable. Do not use it.
|
||||
|
||||
:::
|
||||
|
||||
## Preparation
|
||||
|
||||
> Note: Due to the diverse and complex network environments, many steps may require the use of network magic. Those who understand will know.
|
||||
|
||||
1. Create a Folder
|
||||
|
||||
Create a new folder on any drive (D, E, F, etc.), for example, name it `qqbot`.
|
||||
|
||||
2. Create Subfolders
|
||||
|
||||
Double-click to enter the newly created folder, and create two subfolders (it is recommended to keep the names consistent): `mirai` and `LangBot`.
|
||||
|
||||
## Installing mirai-console
|
||||
|
||||
Download the corresponding version of the installer from the [mcl-installer releases page](https://github.com/iTXTech/mcl-installer/releases). Find the latest installer, which is marked with "Latest," click `show all 14 assets`, and download `mcl-installer-X.X.X-windows-amd64.exe`. For example, download `mcl-installer-1.0.7-windows-amd64.exe` and save it in the previously created `mirai` folder.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Double-click to open it and press Enter all the way. Then, you will see some additional files.
|
||||
|
||||

|
||||
|
||||
Continue by clicking `mcl.cmd`. If you cannot see the file extension, refer to this article to display file extensions: [How to View File Extensions](https://jingyan.baidu.com/article/9158e0004c6cbea2541228da.html).
|
||||
|
||||
After double-clicking, an interface similar to the one below will appear. When `Enter to continue` appears, press Enter.
|
||||
|
||||

|
||||

|
||||
When the green text appears, the installation is complete. At this point, type `exit` and press Enter to quit.
|
||||
|
||||
## Installing mirai-api-http
|
||||
|
||||
Open `mcl.cmd`, enter `mcl --update-package net.mamoe:mirai-api-http --channel stable-v2 --type plugin`, and press Enter.
|
||||
|
||||

|
||||
|
||||
Open `mcl.cmd` again, press Enter all the way until it exits.
|
||||
|
||||
Open `mcl.cmd` once more, and if you see the following interface, it means the installation was successful.
|
||||

|
||||
Press `Ctrl+C` to exit.
|
||||
Locate the `mira/config/net.mamoe.mirai-api-http/setting.yml` file, right-click, and open it with Notepad.
|
||||
|
||||

|
||||
|
||||
Delete all the content and replace it with:
|
||||
|
||||
```yml
|
||||
adapters:
|
||||
- ws
|
||||
debug: true
|
||||
enableVerify: true
|
||||
verifyKey: yirimirai
|
||||
singleMode: false
|
||||
cacheSize: 4096
|
||||
adapterSettings:
|
||||
ws:
|
||||
host: localhost
|
||||
port: 8080
|
||||
reservedSyncId: -1
|
||||
```
|
||||
|
||||
Open `mcl.cmd` again, and you should see the following output:
|
||||

|
||||
This indicates that mirai-api-http has been successfully installed.
|
||||
|
||||
## Configuring the Signature Service
|
||||
|
||||
Download the qsign one-click signature package from this link. Click to download the latest zip file, such as `qsign-1.2.1-beta-dev-d62ddce-all.zip` [as of December 19, 2023]. [Click here to go to the download page](https://github.com/MrXiaoM/qsign/releases).
|
||||
|
||||

|
||||
|
||||
After downloading, extract the files to get the following:
|
||||
|
||||

|
||||
|
||||
Copy the two files into the `mirai` folder.
|
||||
|
||||

|
||||
|
||||
Open the `txlib` folder and note the folder with the largest number.
|
||||
|
||||

|
||||
|
||||
Then, double-click to run `mcl.cmd`. After a while, when you see the prompt `mirai-console started successfully`, qsign is installed.
|
||||
|
||||
Next, open the `config.yml` file located in `mirai/config/top.mrxiaom.qsign` with Notepad.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Then, press `Ctrl+S` to save.
|
||||
|
||||
Double-click to run `mcl.cmd` again, and you should see a similar prompt, as shown below:
|
||||
|
||||

|
||||
|
||||
## Running Mirai
|
||||
|
||||
At this point, you have successfully installed and configured everything. Next, you can log in with your bot's QQ account.
|
||||
|
||||
Enter the following, replacing `123456` with your bot's QQ number and `67890` with your bot's QQ password:
|
||||
|
||||
```bash
|
||||
login 12345 67890
|
||||
```
|
||||
|
||||
Then, you will see the following prompt:
|
||||
|
||||

|
||||
|
||||
Copy the link after `Captcha link:` and open it in Chrome or Edge. Press F12 to open the developer tools.
|
||||
|
||||
Open the `Network` tab.
|
||||
|
||||

|
||||
|
||||
Complete the verification in the browser. In the `Network` tab, find the request named `cap_union_new_verify` at the bottom.
|
||||
|
||||

|
||||
|
||||
The content after `ticket` is what you need to input back into Mirai, but do not include the quotes at the beginning and end.
|
||||
|
||||
**Note**
|
||||
|
||||
- Remember to delete the quotes (`"`, one at the beginning and one at the end) when copying; they are not part of the ticket content.
|
||||
- Be quick.
|
||||
- Make sure not to miss any characters (the content is long, so ensure you copy everything).
|
||||
|
||||
Paste the copied content into the terminal running Mirai.
|
||||
|
||||

|
||||
|
||||
Then press Enter. If you're lucky, you will be prompted to enter a verification code. Type `yes` and press Enter, then enter the verification code and press Enter to log in successfully.
|
||||
|
||||
If you're unlucky and encounter error code 237, it is recommended to try with a different account.
|
||||
|
||||
## Next Steps
|
||||
|
||||
Check the configuration information page and connect via the YiriMirai adapter.
|
||||
@@ -1,11 +0,0 @@
|
||||
# Using the Official QQ Bot API
|
||||
|
||||
The official QQ bot is available for anyone to apply and can be used in channels, group chats, and private messages.
|
||||
|
||||
## Registering a QQ Bot
|
||||
|
||||
Go to the [QQ Open Platform](https://q.qq.com/#/), locate the QQ bot documentation at the bottom, and follow the instructions to register a QQ channel bot.
|
||||
|
||||
## Obtaining Credentials
|
||||
|
||||
After registration, go to the bot console, find the Development Settings, and obtain the `AppId (Bot ID)` and `AppSecret (Bot Key)`. Then proceed to the step of filling in the configuration information.
|
||||
@@ -1,150 +0,0 @@
|
||||
# Filling in Configuration Information
|
||||
|
||||
To enable the basic functionality of LangBot, modify the following configuration files. After reading this page, it is recommended to check the [Configuration Details](/config/function/platform.md) for more in-depth explanations of the configuration items.
|
||||
|
||||
- `data/config/platform.json`
|
||||
- `data/config/provider.json`
|
||||
- `data/config/system.json`
|
||||
|
||||
## platform.json
|
||||
|
||||
Modify this configuration file to specify the messaging platforms you want to connect to. You only need to focus on the `platform-adapters` field. Currently supported platform adapters include `go-cqhttp`, `aiocqhttp`, and `qq-botpy`. You can enable multiple adapters of the same or different types simultaneously. Please fill in the details based on the messaging platforms you have deployed.
|
||||
|
||||
::: info
|
||||
If both the messaging platform and LangBot are running in Docker, please configure the adapter settings below first. For specific network configurations, refer to [Docker Network Configuration Details](/deploy/network-details).
|
||||
:::
|
||||
|
||||
### aiocqhttp Adapter
|
||||
|
||||
Used to connect to NapCat/Lagrange/LLOneBot and other OneBot protocol-compatible bot ends (only supports reverse WebSocket).
|
||||
|
||||
```json
|
||||
{
|
||||
"adapter": "aiocqhttp",
|
||||
"enable": true,
|
||||
"host": "0.0.0.0",
|
||||
"port": 2280,
|
||||
"access-token": ""
|
||||
},
|
||||
```
|
||||
|
||||
`"adapter": "aiocqhttp"`, no need to change.
|
||||
|
||||
`enable`: Whether to enable it. Set it to `true` after configuration.
|
||||
|
||||
`host`: The IP address to listen on. Generally, keep it as `0.0.0.0`. When using aiocqhttp, LangBot acts as a server passively waiting for the framework to connect. Please set the `Passive WebSocket Address` or `Reverse WebSocket Address` (depending on the framework) in NapCat/Lagrange/LLOneBot to the address LangBot is listening on, with the path as `/ws`, e.g., `ws://127.0.0.1:2280/ws`.
|
||||
|
||||
`port`: The port to listen on. Default is 2280. Set the same port in NapCat/Lagrange/LLOneBot. LangBot started in a container exposes ports 2280-2290 by default. Please choose any one of these ports.
|
||||
|
||||
`access-token`: Set the access token, which should match the one set in NapCat/Lagrange/LLOneBot.
|
||||
|
||||
### qq-botpy Adapter
|
||||
|
||||
Used to connect to the official QQ bot API.
|
||||
|
||||
```json
|
||||
{
|
||||
"adapter": "qq-botpy",
|
||||
"enable": false,
|
||||
"appid": "",
|
||||
"secret": "",
|
||||
"intents": [
|
||||
"public_guild_messages",
|
||||
"direct_message",
|
||||
"public_messages"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`"adapter": "qq-botpy"`, no need to change.
|
||||
|
||||
`enable`: Whether to enable it. Set it to `true` after configuration.
|
||||
|
||||
`appid`: The appid of the official QQ bot you applied for.
|
||||
|
||||
`secret`: The secret of the official QQ bot you applied for.
|
||||
|
||||
`intents`: Controls the types of events to listen to. You need to fill this in to receive corresponding messages. Currently supported event types include:
|
||||
|
||||
- `public_guild_messages` QQ channel messages
|
||||
- `direct_message` QQ channel private messages
|
||||
- `public_messages` QQ group and list private messages
|
||||
|
||||
### Nakuru Adapter
|
||||
|
||||
Used to connect to go-cqhttp.
|
||||
|
||||
```json
|
||||
{
|
||||
"adapter": "nakuru",
|
||||
"enable": false,
|
||||
"host": "127.0.0.1",
|
||||
"ws_port": 8080,
|
||||
"http_port": 5700,
|
||||
"token": ""
|
||||
},
|
||||
```
|
||||
|
||||
`"adapter": "nakuru"`, no need to change.
|
||||
|
||||
`enable`: Whether to enable it. Set it to `true` after configuration.
|
||||
|
||||
`host`: The host address running go-cqhttp. Generally, no need to change.
|
||||
|
||||
`ws_port`: The WebSocket server listening address. Keep it consistent with the `config.yml` in `go-cqhttp`.
|
||||
|
||||
`http_port`: The HTTP server listening address. Keep it consistent with the `config.yml` in `go-cqhttp`.
|
||||
|
||||
`token`: The verification token. Keep it consistent with the `config.yml` in `go-cqhttp`.
|
||||
|
||||
## provider.json
|
||||
|
||||
Modify this configuration file to set the relevant information for the connected AI providers. Currently supported interfaces and corresponding models include `openai(GPT)`, `anthropic(claude)`, and `moonshot`.
|
||||
|
||||
> If you don't have an OpenAI API Key, you can [get it here](https://api.qhaigc.net/)
|
||||
|
||||
The following only explains how to enable the OpenAI interface. For specific setup methods, please refer to the [Function Configuration `provider.json` Page](/config/function/provider).
|
||||
|
||||
Edit `data/provider.json`, and add your OpenAI API Key under `keys`->`openai`, for example:
|
||||
|
||||
```json
|
||||
"keys": {
|
||||
"openai": [
|
||||
"sk-AAAAAAAAAAAABBBBBBBBBBBBCCCCCCCCCCCCCDDDDDDDDD"
|
||||
],
|
||||
},
|
||||
```
|
||||
|
||||
If you are using a relay station or another platform compatible with OpenAI format, set `requester`->`openai-chat-completions`->`base-url` to your relay station address. For example:
|
||||
|
||||
Remember to add `/v1` after the address.
|
||||
|
||||
```json
|
||||
"openai-chat-completions": {
|
||||
"base-url": "https://api.example.com/v1",
|
||||
"args": {},
|
||||
"timeout": 120
|
||||
},
|
||||
```
|
||||
|
||||
Finally, change the `model` to the one you want to use, for example:
|
||||
|
||||
```json
|
||||
"model": "gpt-4o",
|
||||
```
|
||||
|
||||
## system.json
|
||||
|
||||
In `data/system.json`, modify `admin-sessions` to add `person_your_QQ_number` to set your session with the bot as an administrator (only effective for person session private chats), for example:
|
||||
|
||||
```json
|
||||
"admin-sessions": [
|
||||
"person_1010553892"
|
||||
],
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
After reading and completing the above tutorial, restart LangBot according to your deployment method. You should be able to use it successfully. If not, please read again (you might have missed or made a mistake in some steps). If you still cannot use it after fully reading and thoroughly understanding this document, you can find a community group [here](/insight/community.html).
|
||||
|
||||
:::
|
||||
@@ -1,9 +0,0 @@
|
||||
# Updating LangBot
|
||||
|
||||
## Using Docker (or One-Click Deployment Based on Docker)
|
||||
|
||||
Simply pull the latest image.
|
||||
|
||||
## Manual Deployment
|
||||
|
||||
Download the latest release from the [Releases](https://github.com/RockChinQ/LangBot/releases) page, specifically the `langbot-<version>-all.zip` file under Assets. Extract it to the previously deployed directory and restart.
|
||||
@@ -1,3 +0,0 @@
|
||||
# Component Architecture
|
||||
|
||||

|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "LangBot"
|
||||
image:
|
||||
src: /en/public/langbot-logo-block.png
|
||||
alt: LangBot-logo
|
||||
text: ""
|
||||
tagline: "Originally named QChatGPT; 😎 Highly stable, 🧩 Plugin-supported, 🦄 Multimodal LLM QQ / QQ Channel / OneBot bot / Agent platform"
|
||||
actions:
|
||||
- theme: brand
|
||||
text: View Documentation
|
||||
link: /en/insight/guide
|
||||
- theme: alt
|
||||
text: Code Repository
|
||||
link: https://github.com/RockChinQ/LangBot
|
||||
|
||||
features:
|
||||
- title: Rich Ecosystem
|
||||
details: Supports plugin extensions such as event listeners and Agents, with dozens of plugins available
|
||||
|
||||
- title: Intuitive Features
|
||||
details: Integrates various commonly used features such as blacklist, rate limiting, response selection, context control, and Prompt management
|
||||
|
||||
- title: Multiple Models
|
||||
details: Compatible with multiple providers including OpenAI, Moonshot, Anthropic, and Gitee AI, with deep support for OneAPI
|
||||
|
||||
- title: High Stability
|
||||
details: Adopts mainstream design principles with a clear architecture and high test coverage
|
||||
|
||||
- title: Quick Deployment
|
||||
details: Supports multiple deployment methods, including one-click deployment via Baota, Docker deployment, and source code deployment
|
||||
|
||||
- title: Continuous Maintenance
|
||||
details: Long-term maintenance and iteration, continuously following the latest application practices in the field of large models
|
||||
|
||||
---
|
||||
@@ -1,19 +0,0 @@
|
||||
# Community Resources
|
||||
|
||||
## Video Tutorials
|
||||
|
||||
[【Latest in August】Deploy the Most Powerful AI Voice Chat + Tavern Role-Playing + QQ Bot in 5 Minutes, New Role-Playing Voice Chat QQ Bot](https://www.bilibili.com/video/BV1vypZeBEW1/?share_source=copy_web&vd_source=1335a044d4fd926920999a0e3ba0a731)
|
||||
|
||||
## QQ Groups for Project Communication
|
||||
|
||||
### Community Group
|
||||
|
||||
> Please read the documentation carefully before asking questions in the group. Join the group only if you cannot resolve the issue.
|
||||
|
||||
Lazy's Communication Group: 619154800 ([Link](https://qm.qq.com/q/1K9GjQuza))
|
||||
|
||||
### Official Group
|
||||
|
||||
> The official group does not provide deployment support.
|
||||
|
||||
Group 4: 195992197 ([Link](https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=cSekvWmyezfCE4O8gXS7lSjkmPinjzpP&authKey=G4jHfz2%2BtQawxCRhn1ZRrQiI8bTvlepQubZL6F9fymFuz8jqZZ4FkYh6lhKLMCd9&noverify=0&group_code=195992197))
|
||||
@@ -1,18 +0,0 @@
|
||||
# Reading Guide
|
||||
|
||||
## Deployment Section
|
||||
|
||||
To deploy this project, please strictly follow the three steps below. Each step can be completed using different methods.
|
||||
|
||||
- Read the **Deploy LangBot** page and choose a deployment method.
|
||||
- Read the **Deploy Messaging Platform** page and select the messaging platform you want to use.
|
||||
- Read the **Fill in Configuration Information** page and fill in the configuration as needed.
|
||||
|
||||
## Usage Section
|
||||
- Read the **Command Syntax** to understand the available commands for the bot, which allow you to switch presets, change models, and more during conversations.
|
||||
- Read the **Plugin List** to obtain plugins and enhance functionality.
|
||||
- Read the **FAQ** to help resolve issues during deployment and usage.
|
||||
|
||||
## Configuration Section
|
||||
- **Feature Configuration**: Detailed explanations of all configuration options to meet more customized needs.
|
||||
- **Metadata Configuration**: Control sensitive words, model lists, and more.
|
||||
@@ -1,114 +0,0 @@
|
||||
# Model Overview and Features
|
||||
|
||||
## Model Overview
|
||||
|
||||
### Text Conversation
|
||||
|
||||
- OpenAI API: GPT-3.5 / GPT-4 series
|
||||
- Moonshot / Deepseek and other major model providers supporting OpenAI API
|
||||
- Anthropic: Claude series
|
||||
- [OneAPI](https://github.com/songquanpeng/one-api) interface aggregation platform: Google Gemini Pro / Azure / Anthropic Claude / Zhipu ChatGLM / Baidu ERNIE Bot / iFlytek Spark Cognitive / Alibaba Tongyi Qianwen / 360 ZhiNao and other official LLM interfaces on the market
|
||||
- [free-one-api](https://github.com/RockChinQ/free-one-api) reverse engineering library aggregation platform: ChatGPT / Claude / Google Bard / gpt4free / Tongyi Qianwen
|
||||
|
||||
## Feature List
|
||||
|
||||
<details>
|
||||
<summary>✅ Contextually Relevant Responses</summary>
|
||||
|
||||
- The program sends recent conversation content to the model, and the model generates responses based on the context.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Supports Sensitive Word Filtering to Avoid Account Risks</summary>
|
||||
|
||||
- It is difficult to monitor the content of conversations between the bot and users, hence this feature is introduced to reduce bot risks.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Multiple Response Rules in Group Chats, No Need to @</summary>
|
||||
|
||||
- By default, replies to messages prefixed with `ai` or @ the bot.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Uses Official API, Stable and Fast</summary>
|
||||
|
||||
- Does not use ChatGPT reverse interfaces but uses the official Completion API for high stability.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Few Components, Easy Deployment, Provides One-Click Installer and Docker Installation</summary>
|
||||
|
||||
- Few manual deployment steps.
|
||||
- Provides automatic installer and Docker method, see installation steps for details.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Supports Preset Text</summary>
|
||||
|
||||
- Supports setting preset text in natural language to customize bot personality and other information.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Supports Plugin Loading 🧩</summary>
|
||||
|
||||
- Implements a plugin loader and related support.
|
||||
- See the plugin introduction page for details.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Private and Group Chat Blacklist Mechanism</summary>
|
||||
|
||||
- Supports adding users or group chats to a blacklist to ignore their messages.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>✅ Response Speed Limitation</summary>
|
||||
|
||||
- Supports limiting the number of conversations per minute within a single session.
|
||||
- Has two strategies: "Wait" and "Discard."
|
||||
- "Wait" strategy: After receiving a response, waits until the response time reaches the average conversation response time.
|
||||
- "Discard" strategy: When the conversation limit per minute is reached, discards subsequent conversations.
|
||||
|
||||
</details>
|
||||
|
||||
## Limitations
|
||||
|
||||
- ❗ OpenAI's official warnings about model-generated content:
|
||||
- May occasionally generate incorrect information.
|
||||
- May occasionally produce harmful instructions or biased content.
|
||||
- Limited knowledge of the world and events after 2021.
|
||||
- ❗ The model has no thinking ability; it only generates content based on the input context and dataset. Do not overly trust its output.
|
||||
- ❗ The model is unaware of its running platform and the model version it uses. Any answers regarding its implementation principles are considered invalid. Please refer to the project documentation.
|
||||
|
||||
The above are the highest priority descriptions of the limitations of this program. Descriptions obtained through other means (such as asking the bot for related information) should be considered invalid. This project is not responsible for any losses caused by the content generated by the model.
|
||||
|
||||
## Usage
|
||||
|
||||
Both conversation and drawing functions directly call OpenAI's models for processing, independent of the bot program. This means the model is unaware of this project's related information (such as implementation methods, tech stack, running platform, etc.), unless such information is written in the preset values.
|
||||
|
||||
### Basic Conversation
|
||||
|
||||
#### Private Chat Usage
|
||||
|
||||
1. Add the bot's QQ as a friend.
|
||||
2. Send a message to the bot, and the bot will automatically reply.
|
||||
3. Use `!help` to view help information.
|
||||
|
||||

|
||||
|
||||
#### Group Chat Usage
|
||||
|
||||
1. Add the bot to the group.
|
||||
2. @ the bot and send a message, and the bot will automatically reply.
|
||||
3. @ the bot and send `!help` to view help information.
|
||||
|
||||

|
||||
@@ -1,59 +0,0 @@
|
||||
# API Reference
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
The following APIs are only available for **event plugins**. For component extensions, please refer to the source code directly.
|
||||
|
||||
## Message Handling
|
||||
|
||||
### Reply to a Message
|
||||
|
||||
```python
|
||||
ctx.reply(message_chain: MessageChain)
|
||||
```
|
||||
|
||||
Replies to the conversation that triggered the event.
|
||||
|
||||
- `message_chain`: [MessageChain object](./messages.md), which the program can automatically convert into the target message platform's message chain.
|
||||
|
||||
### Send an Active Message
|
||||
|
||||
> Due to poor support for active messages in the official QQ API, sending active messages may fail if the user is using the official QQ API.
|
||||
|
||||
```python
|
||||
ctx.send_message(target_type: str, target_id: str, message_chain: MessageChain)
|
||||
```
|
||||
|
||||
Sends an active message to the target.
|
||||
|
||||
- `target_type`: The type of target, with possible values: `"person"`, `"group"`.
|
||||
- `target_id`: The target ID (QQ number or group number).
|
||||
- `message_chain`: [MessageChain object](./messages.md), which the program can automatically convert into the target message platform's message chain.
|
||||
|
||||
## Event Handling
|
||||
|
||||
### Prevent Default Event Behavior
|
||||
|
||||
```python
|
||||
ctx.prevent_default()
|
||||
```
|
||||
|
||||
Prevents the default behavior of the event, stopping subsequent processing actions (e.g., fetching a reply from the interface when a private message is received, or fetching a reply from the interface when a group message is received).
|
||||
|
||||
### Prevent Subsequent Plugin Execution
|
||||
|
||||
```python
|
||||
ctx.prevent_postorder()
|
||||
```
|
||||
|
||||
Prevents the execution of subsequent plugins for this event. The execution order of plugins can be modified by adjusting priorities as described in the `Plugin Management` section of the `Plugin Introduction`.
|
||||
|
||||
### Add a Return Value
|
||||
|
||||
```python
|
||||
ctx.add_return(name: str, value: Any)
|
||||
```
|
||||
|
||||
Adds a return value. Return values for events are **optional**. For the return values supported by each event, please refer to the comments in `pkg.plugin.events` for each event.
|
||||
@@ -1,104 +0,0 @@
|
||||
# Component Extension
|
||||
|
||||
> Please read the [Plugin Introduction Page](/plugin/plugin-intro) first.
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
Plugins wrapped in subclasses of `BasePlugin` can only listen to predefined events, whereas component extensions can replace entire components, enabling more powerful functionality.
|
||||
|
||||
- Component extensions do not need to be wrapped in a subclass of `BasePlugin` and can be placed in any module within the plugin directory.
|
||||
- Extended components are not controlled by the plugin's on/off switch.
|
||||
- Extended components are typically selected via options in the configuration file.
|
||||
|
||||
## Extendable Components
|
||||
|
||||

|
||||
|
||||
To extend a component, create a new class that inherits from the component's base class, then use the corresponding decorator on the class, and configure the component to use this implementation based on the usage method.
|
||||
|
||||
Most components contain an `ap: pkg.core.app.Application` object, which can be used to interact with various parts of the entire program.
|
||||
Most components support implementing the `async def initialize(self)` method for asynchronous initialization when the component is loaded.
|
||||
The `ap` object includes manager objects for various configuration files, which can be used to access these configurations.
|
||||
|
||||
### Command
|
||||
|
||||
Add a new command.
|
||||
|
||||
- Base Class: `pkg.command.operator.CommandOperator`
|
||||
- Decorator: `pkg.command.operator.operator_class(name: str, help: str="", usage: str=None, alias: list[str]=[], privilege: int=1, parent_class: typing.Type[CommandOperator] = None)`
|
||||
- Reference Implementation: `pkg.command.operators/`
|
||||
- Usage: After successful loading, execute the command `!cmd` to view all commands and their help information.
|
||||
|
||||
### Content Filter
|
||||
|
||||
Add a new content processor that determines whether to continue processing before and after handling a message.
|
||||
|
||||
- Base Class: `pkg.pipeline.cntfilter.filter.ContentFilter`
|
||||
- Decorator: `pkg.pipeline.cntfilter.filter.filter_class(name: str)`
|
||||
- Reference Implementation: `pkg.pipeline.cntfilter.filters/`
|
||||
- Usage: After successful loading, the `process` method of the content filter will be called at the declared inspection stage for each filter implementation.
|
||||
|
||||
### Long Message Handling Strategy
|
||||
|
||||
Add a new long message handling strategy. Examples include components that convert text to merged forwarded messages or text to images.
|
||||
|
||||
- Base Class: `pkg.pipeline.longtext.strategy.LongTextStrategy`
|
||||
- Decorator: `pkg.pipeline.longtext.strategy.strategy_class(name: str)`
|
||||
- Reference Implementation: `pkg.pipeline.longtext.strategies/`
|
||||
- Usage: Set the `strategy` field in the `long-text-strategy` section of `data/config/platform.json` to the name of the newly added strategy.
|
||||
|
||||
### Conversation Rate Limiting Algorithm
|
||||
|
||||
Add a new conversation rate limiting algorithm. The rate limiting algorithm implementation class methods are called when a conversation request enters and exits, allowing the implementation class to control waiting or dropping requests.
|
||||
|
||||
- Base Class: `pkg.pipeline.ratelimit.algo.RateLimitAlgo`
|
||||
- Decorator: `pkg.pipeline.ratelimit.algo.algo_class(name: str)`
|
||||
- Reference Implementation: `pkg.pipeline.ratelimit.algos/`
|
||||
- Usage: Set the `algo` field in the `rate-limit` section of `data/config/pipeline.json` to the name of the newly added algorithm.
|
||||
|
||||
### LLM Interface Requester
|
||||
|
||||
Add a new LLM interface requester, such as integrating the ChatGLM interface.
|
||||
|
||||
- Base Class: `pkg.provider.modelmgr.api.LLMAPIRequester`
|
||||
- Decorator: `pkg.provider.modelmgr.api.api_requester_class(name: str)`
|
||||
- Reference Implementation: `pkg.provider.modelmgr.apis/`
|
||||
- Usage: Add a model in `data/metadata/llm-models.json` and set the `requester` field of the model to the name of the newly added requester. For details, refer to the metadata configuration section.
|
||||
|
||||
### Prompt Loader
|
||||
|
||||
Add a new Prompt loader.
|
||||
|
||||
- Base Class: `pkg.provider.sysprompt.loader.PromptLoader`
|
||||
- Decorator: `pkg.provider.sysprompt.loader.loader_class(name: str)`
|
||||
- Reference Implementation: `pkg.provider.sysprompt.loaders/`
|
||||
- Usage: Set the `prompt-mode` field in `data/config/provider.json` to the name of the newly added loader.
|
||||
|
||||
### Message Platform Adapter
|
||||
|
||||
Add a new message platform adapter, such as integrating WhatsApp or Discord.
|
||||
|
||||
- Base Class: `pkg.platform.adapter.MessageSourceAdapter`
|
||||
- Decorator: `pkg.platform.adapter.adapter_class(name: str)`
|
||||
- Reference Implementation: `pkg.platform.adapters/`
|
||||
- Usage: The configuration information in the `platform-adapters` section of `data/config/platform.json` will automatically look up the corresponding adapter implementation based on the `adapter` name during initialization and pass the configuration to the adapter for initialization. Message platform adapters are complex to implement, so it is recommended to refer to existing implementations.
|
||||
|
||||
### Conversation History Message Truncator
|
||||
|
||||
Add a new conversation history message truncator that truncates historical messages before sending them to the model.
|
||||
|
||||
- Base Class: `pkg.pipeline.msgtrun.truncator.Truncator`
|
||||
- Decorator: `pkg.pipeline.msgtrun.truncator.truncator_class(name: str)`
|
||||
- Reference Implementation: `pkg.pipeline.msgtrun.truncators/`
|
||||
- Usage: Set the `method` field in the `msg-truncate` section of `data/config/pipeline.json` to the name of the newly added truncator.
|
||||
|
||||
### Chat Request Runner
|
||||
|
||||
Add a new chat message runner. The default is local-agent, which provides basic Prompt composition, Agent orchestration, and multi-turn requests. If you need to integrate a knowledge base or local RAG, implement it here.
|
||||
|
||||
- Base Class: `pkg.provider.runner.RequesterRunner`
|
||||
- Decorator: `pkg.provider.runner.runner_class(name: str)`
|
||||
- Reference Implementation: `pkg.provider.runners/`
|
||||
- Usage: Set the `runner` field in the `runner` section of `data/config/provider.json` to the name of the newly added runner.
|
||||
@@ -1,82 +0,0 @@
|
||||
# Message Platform Entities
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
LangBot supports multiple message platforms, but the format of `message entities` varies across different platforms. To abstract these differences, LangBot has a unified standard. Plugin developers only need to understand and use the message entities described on this page within their plugins. LangBot's internal message processing logic will automatically handle the parsing and conversion of messages.
|
||||
|
||||
:::info
|
||||
LangBot's message platform entities are based on a modified implementation of [YiriMirai](https://github.com/YiriMiraiProject/YiriMirai).
|
||||
:::
|
||||
|
||||
## Message Chain
|
||||
|
||||
The `messages` on message platforms are different from the messages used for AI interactions. Messages on message platforms are described in the form of `message chains`. Each independent message displayed on QQ is a message chain. A message chain can contain various `message chain components` such as `text`, `images`, `@ components`, etc. For example:
|
||||
|
||||

|
||||
|
||||
This is a message chain containing a Plain component ("Hello World") and an Image component ("Usagi").
|
||||
|
||||
The definitions of message chains and message chain components are located in `pkg/platform/types/messages.py`.
|
||||
|
||||
### Constructing a Message Chain
|
||||
|
||||
First, import the `pkg.platform.types` package to use the message components within it.
|
||||
|
||||
```python
|
||||
from pkg.platform.types import *
|
||||
|
||||
# Construct a message containing the text "Hello LangBot" and an image (fetched from a URL)
|
||||
msg_chain = MessageChain([
|
||||
Plain("Hello LangBot"),
|
||||
Image(url='https://qchatgpt.rockchin.top/langbot-logo.png')
|
||||
])
|
||||
|
||||
# Construct a message containing an @All component and the text "Hello LangBot"
|
||||
msg_chain = MessageChain([
|
||||
AtAll(),
|
||||
Plain("Hello LangBot")
|
||||
])
|
||||
|
||||
# Construct a message containing an @ component for a specific member and the text "Hello LangBot"
|
||||
msg_chain = MessageChain([
|
||||
At(123456),
|
||||
Plain("Hello LangBot")
|
||||
])
|
||||
```
|
||||
|
||||
Currently supported message chain components:
|
||||
|
||||
- `Source`: Source message chain information. If the message is received from a message platform, this component will be included at the beginning of the message chain, recording the message information.
|
||||
- `Plain`: Plain text message.
|
||||
- `Quote`: Quoted message.
|
||||
- `Image`: Image message.
|
||||
- `AtAll`: @All members message.
|
||||
- `At`: @Specific member message.
|
||||
- `Voice`: Voice message.
|
||||
- Requires checking platform support.
|
||||
- `Forward`: Forwarded message.
|
||||
- Not supported on many platforms, not recommended for use.
|
||||
- `File`: File message.
|
||||
|
||||
For specific usage, refer to the definitions in `pkg/platform/types/messages.py`.
|
||||
|
||||
## Message Platform Events
|
||||
|
||||
These events are different from LangBot plugin events and are part of an independent event system for message platforms. These events are the source events for LangBot plugin events and can be obtained from each `Query.message_event`.
|
||||
|
||||
The definitions of message platform events are located in `pkg/platform/types/events.py`.
|
||||
|
||||
## Other Entities
|
||||
|
||||
In addition to the entities mentioned above, there are entities such as `Friend` and `Group`. The definitions of these entities are located in `pkg/platform/types/entities.py`.
|
||||
They are generally included in the event objects mentioned above and can be used to retrieve information not included in plugin events.
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
Plugins developed based on version 3.x can seamlessly adapt to version 3.4. However, `import mirai` is no longer supported in the new version, and the editor will report errors when developing plugins. Please make the following changes:
|
||||
|
||||
- Change `import mirai` to `import pkg.platform.types as mirai`
|
||||
- It is not recommended to directly change it to `as mirai`. Instead, use `import pkg.platform.types as platform_types` and replace the corresponding `mirai.xxx` in the plugin code with `platform_types.xxx`.
|
||||
- Change `from mirai import *` to `from pkg.platform.types import *`
|
||||
@@ -1,225 +0,0 @@
|
||||
# Plugin Development Tutorial
|
||||
|
||||
> Please read the [Plugin Introduction Page](/plugin/plugin-intro) first.
|
||||
> It is recommended to read the project source code to understand the project architecture.
|
||||
|
||||
> For issues and feature requests, please create an issue in the repository.
|
||||
> **Please try to solve the problem on your own before asking questions.**
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## 💬 Introduction
|
||||
|
||||
This page explains the steps for developing a regular plugin. There are two methods inside a plugin: event listeners and content functions.
|
||||
Event listeners can respond to certain events and modify behavior. Content functions can be called by large language models. For more details, please refer to the plugin introduction page.
|
||||
|
||||
LangBot also supports component extensions, allowing you to replace entire components without being limited to listening to predefined events. Please read this page and then check the **Component Extension** page for more details.
|
||||
|
||||
## 💻 Quick Start
|
||||
|
||||
Deploy this project according to the documentation and ensure it runs properly.
|
||||
|
||||
Use [hello_plugin](https://github.com/RockChinQ/hello_plugin) as a template to generate a plugin code repository, then clone the repository code into the `plugins` directory.
|
||||
|
||||
Modify the necessary parts in the plugin's README.md file.
|
||||
|
||||
Edit `main.py` and input the following content:
|
||||
|
||||
```Python
|
||||
from pkg.plugin.context import register, handler, llm_func, BasePlugin, APIHost, EventContext
|
||||
from pkg.plugin.events import * # Import event classes
|
||||
|
||||
|
||||
"""
|
||||
When receiving a private or group chat message "hello", reply with "hello, <sender_id>!" or "hello, everyone!"
|
||||
"""
|
||||
|
||||
|
||||
# Register the plugin
|
||||
@register(name="Hello", description="hello world", version="0.1", author="RockChinQ")
|
||||
class HelloPlugin(BasePlugin):
|
||||
|
||||
# Triggered when the plugin is loaded
|
||||
def __init__(self, host: APIHost):
|
||||
pass
|
||||
|
||||
# Asynchronous initialization
|
||||
async def initialize(self):
|
||||
pass
|
||||
|
||||
# Triggered when a private message is received
|
||||
@handler(PersonNormalMessageReceived)
|
||||
async def person_normal_message_received(self, ctx: EventContext):
|
||||
msg = ctx.event.text_message # Here, event is the object of PersonNormalMessageReceived
|
||||
if msg == "hello": # If the message is "hello"
|
||||
|
||||
# Output debug information
|
||||
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
|
||||
|
||||
# Reply with "hello, <sender_id>!"
|
||||
ctx.add_return("reply", ["hello, {}!".format(ctx.event.sender_id)])
|
||||
|
||||
# Prevent the default behavior of this event (fetching a reply from the API)
|
||||
ctx.prevent_default()
|
||||
|
||||
# Triggered when a group message is received
|
||||
@handler(GroupNormalMessageReceived)
|
||||
async def group_normal_message_received(self, ctx: EventContext):
|
||||
msg = ctx.event.text_message # Here, event is the object of GroupNormalMessageReceived
|
||||
if msg == "hello": # If the message is "hello"
|
||||
|
||||
# Output debug information
|
||||
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
|
||||
|
||||
# Reply with "hello, everyone!"
|
||||
ctx.add_return("reply", ["hello, everyone!"])
|
||||
|
||||
# Prevent the default behavior of this event (fetching a reply from the API)
|
||||
ctx.prevent_default()
|
||||
|
||||
# Triggered when the plugin is unloaded
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
```
|
||||
|
||||
This plugin will implement: when a private chat receives a `hello` message, it replies with `hello, <sender QQ number>!`, and when a group chat receives a `hello` message, it replies with `hello, everyone!`.
|
||||
|
||||
### Interpreting This Plugin Program
|
||||
|
||||
- `import pkg.plugin.context` imports `register (for registering plugin classes)`, `handler (for registering event listeners)`, `llm_func (for registering content functions)`, `BasePlugin (plugin base class)`, `APIHost (API host)`, `EventContext (event context class)`, etc.
|
||||
- `import pkg.plugin.events` imports all supported event classes.
|
||||
- `@register` marks the class `HelloPlugin` as a plugin class, declaring the plugin name as `Hello` along with the plugin description, version, and author.
|
||||
- The class `HelloPlugin` inherits from `BasePlugin`. This class can be named arbitrarily; the plugin name is only related to the parameters in the `register` call.
|
||||
- The `__init__` method of this class is optional, and the code inside it will be executed when the plugin is loaded during the main program startup.
|
||||
- The plugin class also supports adding an asynchronous method `async def initialize(self)` for asynchronous initialization.
|
||||
- `@handler` marks the method `person_normal_message_received` as an event listener, handling the `PersonNormalMessageReceived` event (triggered when a private message is received before fetching a reply from OpenAI). This method can be named arbitrarily; the bound event is only related to the parameters in `handler`. For more supported events, please refer to the `pkg.plugin.events` file or the `API` section below.
|
||||
- Debug information is output through the `self.ap.logger` logger. The `ap` object in the plugin class's parent class is the context object of the entire program, through which all objects in the program can be accessed.
|
||||
- The second parameter `ctx` obtained by the event listener method is the context of this event, where `event` is the event object of this event. Relevant parameters can be extracted from it. For specific parameters that can be obtained from events, please refer to the comments of each event class in the `pkg.plugin.events` file.
|
||||
- Inside the event listener method, the `text_message` parameter is extracted from the parameters, and if it is `hello`, the return value `reply` is set to `["hello, {}!".format(ctx.event.sender_id)]`. Then, the `ctx.prevent_default()` method is called to prevent the default behavior of the original program.
|
||||
- For the return values supported by each event, please refer to the comments of each event in `pkg.plugin.events`.
|
||||
- A similar program is used to register the `GroupNormalMessageReceived` event to handle group messages.
|
||||
|
||||
After saving the changes, restart the main program and send the `!plugin` command to the bot. If the `Hello` plugin appears, it means the plugin has been successfully loaded.
|
||||
|
||||
## ❗ Guidelines (Important)
|
||||
|
||||
- Each plugin should be in a separate directory for easier management. It is recommended to create a repository on GitHub to store a single plugin for easy access and updates.
|
||||
- Plugin names should use `PascalCase`, such as `Hello`, `ExamplePlugin`, `ChineseCommands`, etc.
|
||||
- Multiple Python program files can be stored in one directory to separate the various functions of the plugin, making it easier for developers to manage. However, it is not recommended to register multiple plugins in one directory.
|
||||
- The dependencies required by the plugin should be specified in the `requirements.txt` file in the plugin directory. The program will automatically install the dependencies when fetching this plugin from the repository.
|
||||
|
||||
## 🪝 Content Functions
|
||||
|
||||
`Content functions` are implemented through [GPT's Function Calling capability](https://platform.openai.com/docs/guides/gpt/function-calling). These are functions embedded in conversations and automatically called by GPT.
|
||||
|
||||
> Your plugin does not necessarily need to include content functions. Please read the content function page to understand this feature first.
|
||||
|
||||
### Steps to Write Content Functions
|
||||
|
||||
1️⃣ First, follow the steps above to write the basic structure of your plugin. Now, please delete (or you can keep them for simplicity) the class functions decorated with `@handler` in the plugin content above.
|
||||
|
||||
<details>
|
||||
<summary>Class Structure After Deletion</summary>
|
||||
|
||||
```python
|
||||
|
||||
# Register the plugin
|
||||
@register(name="Hello", description="hello world", version="0.1", author="RockChinQ")
|
||||
class HelloPlugin(Plugin):
|
||||
|
||||
# Triggered when the plugin is loaded
|
||||
def __init__(self, plugin_host: APIHost):
|
||||
pass
|
||||
|
||||
# Triggered when the plugin is unloaded
|
||||
def __del__(self):
|
||||
pass
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
2️⃣ Now, add the following function to the position where the functions were deleted (as a class method).
|
||||
|
||||
```Python
|
||||
|
||||
# Function to add
|
||||
@llm_func(name="access_the_web") # Set the function name
|
||||
async def access_web(self, query, url: str):
|
||||
"""Call this function to search about the question before you answer any questions.
|
||||
- Do not search through baidu.com at any time.
|
||||
- If you need to search somthing, visit https://www.google.com/search?q=xxx.
|
||||
- If user ask you to open a url (start with http:// or https://), visit it directly.
|
||||
- Summary the plain content result by yourself, DO NOT directly output anything in the result you got.
|
||||
|
||||
Args:
|
||||
url(str): url to visit
|
||||
|
||||
Returns:
|
||||
str: plain text content of the web page
|
||||
"""
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
# You need to first use
|
||||
# pip install beautifulsoup4
|
||||
# to install the dependencies
|
||||
|
||||
r = requests.get(
|
||||
url,
|
||||
timeout=10,
|
||||
headers={
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183"
|
||||
}
|
||||
)
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
|
||||
s = soup.get_text()
|
||||
|
||||
# Remove extra blank lines or lines with only \t and spaces
|
||||
s = re.sub(r'\n\s*\n', '\n', s)
|
||||
|
||||
if len(s) >= 512: # Truncate the first 512 characters of the obtained webpage plain text content
|
||||
return s[:512]
|
||||
|
||||
return s
|
||||
|
||||
```
|
||||
|
||||
#### Please Note:
|
||||
|
||||
- The function's comments must be written strictly according to the required format. For the specific format, please refer to [this document](https://github.com/RockChinQ/CallingGPT/wiki/1.-Function-Format#function-format).
|
||||
- Content functions and `event listeners decorated with @handler` can coexist in the same plugin and are simultaneously controlled by the plugin switch in `plugins/plugins.json`.
|
||||
- Ensure that the model you are using supports function calling.
|
||||
|
||||
3️⃣ Now your program has web access capabilities. Restart the program and ask the bot about online content or directly send an article link to request a summary.
|
||||
|
||||
- This is just an example. For more efficient web access capabilities, please refer to [WebwlkrPlugin](https://github.com/RockChinQ/WebwlkrPlugin).
|
||||
|
||||
## 📄 Terminology Explanation
|
||||
|
||||
### Explanation
|
||||
|
||||
The `ctx: EventContext` object obtained by event listener methods can be viewed in the `pkg.plugin.context` module. The `event` property of the `ctx` object is the event object of this event, from which relevant parameters can be extracted. For specific parameters that can be obtained from events, please refer to the comments of each event class in the `pkg.plugin.events` file.
|
||||
Event return values are **optional** and can be submitted by calling `ctx.add_return(key: str, ret)`.
|
||||
|
||||
### Events
|
||||
|
||||
If an event is part of a request (user sending a message), its event object will contain a `query` object, which includes the context data of this request (the process of handling a user sending a message, where one request process may trigger multiple events).
|
||||
For all supported events, please refer to the comments of each event class in the `pkg.plugin.events` file.
|
||||
For `message chain components`, please refer to [Message Platform Entities](./messages).
|
||||
|
||||
### BasePlugin Structure
|
||||
|
||||
#### self.ap
|
||||
|
||||
Accessing `self.ap` in plugin methods refers to the object of the `pkg.core.app.Application` class, which contains the context object of the entire program. All objects in the program can be accessed through this object.
|
||||
|
||||
#### self.host
|
||||
|
||||
Accessing `self.host` in plugin methods refers to the object of the `pkg.plugin.context.APIHost` class, which provides some APIs of the main program. For more details, please refer to its source code.
|
||||
|
||||
### API Reference
|
||||
|
||||
For the APIs that plugins can call, please refer to the [API Reference](./api-ref).
|
||||
@@ -1,117 +0,0 @@
|
||||
# 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](https://platform.openai.com/docs/guides/gpt/function-calling), 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.
|
||||
|
||||
#### Repository Cloning (Recommended)
|
||||
|
||||
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:
|
||||
|
||||
```json
|
||||
"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](https://github.com/stars/RockChinQ/lists/qchatgpt-%E6%8F%92%E4%BB%B6)
|
||||
|
||||
- [WebwlkrPlugin](https://github.com/RockChinQ/WebwlkrPlugin) - Allows the bot to access the internet!!
|
||||
- [https://github.com/the-lazy-me/NewChatVoice](https://github.com/the-lazy-me/miHoYoVoice) - LangBot voice plugin, enabling voice chat using multiple TTS platforms
|
||||
- [Yuumi0221/URLMaskerPlugin](https://github.com/Yuumi0221/URLMaskerPlugin) - Used to mask (replace) URLs to comply with QQ official bot API restrictions on URLs in messages
|
||||
- [ElvisChenML/Waifu](https://github.com/ElvisChenML/Waifu) - A LangBot plugin aimed at using program logic combined with LLM to create realistic chatbots, exploring authentic chat experiences.
|
||||
- [Pevernow/LangBot_Plugin_Emoticon_v3](https://github.com/Pevernow/QChatGPT_Plugin_Emoticon_v3) - LangBot v3 compatible, an emoticon plugin based on online APIs.
|
||||
- [https://github.com/kirifujinagisa/RussianRoulette](https://github.com/kirifujinagisa/RussianRoulette) - A LangBot Russian Roulette game plugin
|
||||
- [https://github.com/kirifujinagisa/FileSender](https://github.com/kirifujinagisa/FileSender) - A LangBot plugin for sending specified local files to applicants
|
||||
- [https://github.com/ElvisChenML/GalgameMaker](https://github.com/ElvisChenML/GalgameMaker) - A LangBot plugin for quickly generating Galgames conducted in QQ conversations.
|
||||
- [https://github.com/zzseki/QChatGPT_Plugin_News](https://github.com/zzseki/QChatGPT_Plugin_News) - No description (guess from the repository name)
|
||||
- [https://github.com/zzseki/QChatGPT_Plugin_Weather ](https://github.com/zzseki/QChatGPT_Plugin_Weather)- No description (guess from the repository name)
|
||||
- [https://github.com/zzseki/QChatGPT_Plugin_Music](https://github.com/zzseki/QChatGPT_Plugin_Music) - No description (guess from the repository name)
|
||||
- [https://github.com/inkOrCloud/Markdown2IMG](https://github.com/inkOrCloud/Markdown2IMG) - LangBot plugin, converting markdown text into images for output
|
||||
- [https://github.com/Annalasu/QcPlugin_Md2QQImage](https://github.com/Annalasu/QcPlugin_Md2QQImage) - Displays md image links in messages as normal images
|
||||
- [https://github.com/the-lazy-me/SillyTavernPlugin](https://github.com/the-lazy-me/SillyTavernPlugin) - LangBot plugin, capable of transcribing SillyTavern character cards to adapt to LangBot's personality presets
|
||||
@@ -1,110 +0,0 @@
|
||||
# Technical Information
|
||||
|
||||
Below is the technical information about the implementation principles of LangBot. Please read carefully before contributing.
|
||||
|
||||
> This document is the technical documentation for LangBot 2.x and is outdated. For version 3.x, please refer directly to the source code.
|
||||
> Please read the OpenAI API documentation at https://beta.openai.com/docs/ first. The following information assumes that you are familiar with the relevant features of OpenAI models and their interface invocation methods.
|
||||
|
||||
## Terminology
|
||||
|
||||
Includes the terminology involved in the OpenAI API and the naming of concepts in the project.
|
||||
The terms in parentheses are the corresponding terms in the program, while those without parentheses are abstract concepts.
|
||||
|
||||
### Model
|
||||
|
||||
AI model. The content generated by calling OpenAI's interface in the program is all generated by OpenAI's models.
|
||||
|
||||
### Tokens
|
||||
|
||||
Tokens as defined by OpenAI. ASCII characters are 1 token, while others are 2 tokens.
|
||||
|
||||
### Prompt
|
||||
|
||||
i. The prompt used when calling OpenAI's text completion model. The model interface will return a response based on the prompt. The program will encapsulate the conversation content to generate the prompt. The prompts for calling the text completion model are marked with `user_name` (default is `You`, can be modified in the configuration file) and `bot_name` (default is `Bot`, can be modified in the configuration file) to identify the conversation roles for the model. Here is an example:
|
||||
|
||||
```
|
||||
You: The weather is nice today.
|
||||
Bot: I'm glad you like today's weather :)
|
||||
You: Thank you.
|
||||
Bot: You're welcome :)
|
||||
```
|
||||
For the program implementation of the completion model, please refer to the `Implementation` section below.
|
||||
|
||||
ii. The prompt used when calling OpenAI's drawing model. The model will draw based on the prompt and return the image URL.
|
||||
|
||||
### Object
|
||||
|
||||
The program treats a single person or a single QQ group as an object. The object and the model are the two parties in a conversation during a session.
|
||||
|
||||
### Session
|
||||
|
||||
Sessions are only valid for the text completion function; the drawing function does not have the concept of a session. Each object uses the same session, and there are only two roles in a session: the object and the model. Therefore, all people in the group will be treated as the same role to converse with the model.
|
||||
|
||||
The essence of the program obtaining a reply is `text completion`.
|
||||
Since the conversation needs to maintain context, the program will send the conversation history between the model and the object as a `prompt` to OpenAI's interface to obtain a reply that fits the previous context.
|
||||
However, the prompt for OpenAI's text completion interface has a length limit (the default `text-davinci-003` has a limit of 4096 tokens),
|
||||
so the concept of `session` is added to manage the prompt content sent to the interface.
|
||||
|
||||
The session's lifespan can be set in `config.py`, with a default of 20 minutes. After the session expires, it will be stored in the database and reset. The next time the object initiates a conversation, a new session will be started.
|
||||
|
||||
### Default Prompt, Personality (default_prompt)
|
||||
|
||||
The preset conversation information for each session can be set in `config.py`. The program will write the following content to the prompt when each session is created:
|
||||
|
||||
```
|
||||
You: <preset information>
|
||||
Bot: Okay
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### QQ Bot
|
||||
|
||||
> Program Path:
|
||||
> pkg.qqbot
|
||||
|
||||
- `pkg.qqbot.manager` contains `QQBotManager`, which implements functions such as receiving messages, calling the OpenAI module to process messages, reporting to the audit module to record usage, and provides methods for notifying administrators and sending messages for other modules to call.
|
||||
- `pkg.qqbot.filter` provides operations related to sensitive word filtering.
|
||||
- `pkg.qqbot.process` provides unified processing logic for private messages and group messages.
|
||||
|
||||
Mirai and YiriMirai are used as the framework for Python to interact with QQ. For details, please refer to their documentation.
|
||||
At startup, YiriMirai's function is called to create a bot object, which is used by the program to interact with QQ through Mirai. The upper-level program calls this bot object's methods to process messages.
|
||||
Since YiriMirai currently cannot shut down the bot, the same bot object is maintained before and after hot reloading, meaning that the QQ bot's related configuration (QQ number, adapter, etc.) information does not support hot reloading.
|
||||
|
||||
### Database
|
||||
|
||||
> Program Path:
|
||||
> pkg.database
|
||||
|
||||
- `pkg.database.manager` contains `DatabaseManager`, which encapsulates many methods for calling the database for other modules to use.
|
||||
|
||||
SQLite is used as the database, storing all historical session information of objects, api-key cost information, and api-key usage information.
|
||||
|
||||
### OpenAI Interaction
|
||||
|
||||
> Program Path:
|
||||
> pkg.openai
|
||||
|
||||
- `pkg.openai.manager` contains the `OpenAIInteract` class, which encapsulates OpenAI's text completion `Completion` API and drawing API for the bot module to call. After a successful interface call, it reports the usage information of the current api-key to the audit module.
|
||||
- `pkg.openai.keymgr` implements multi-api-key management, where the `exceeded` variable records api-key overage errors at runtime and provides api-key switching functionality based on overage records.
|
||||
- `pkg.openai.pricing` records the cost information of each model for estimating costs when calling the interface. The cost estimation function is no longer tied to api-key switching; api-keys are only switched when the interface call reports an overage error.
|
||||
- `pkg.openai.session` contains `Session` for session management.
|
||||
|
||||
### Utils Module
|
||||
|
||||
#### Context Module
|
||||
|
||||
Saves the objects from the aforementioned modules and allows each module to retrieve objects from here to call their methods.
|
||||
|
||||
#### Hot Reload Function
|
||||
|
||||
> pkg.utils.reloader
|
||||
|
||||
Before reloading, save all objects in the context, execute the program shutdown process in `main.py`, use the `reload` function of `importlib` to reload all modules (including the configuration file and any new modules), restore the context after reloading, and execute the program startup process.
|
||||
All modules will recreate their objects, but the bot object in the QQ bot module will not be recreated. This is because the shutdown method provided by YiriMirai cannot be used, meaning that the QQ bot configuration in `config.py` does not support hot reloading.
|
||||
|
||||
#### Hot Update Function
|
||||
|
||||
> pkg.utils.updater
|
||||
|
||||
Use the `dulwich` library to perform a pull operation to fetch the latest source code from the remote repository and perform a hot reload to load the latest code.
|
||||
|
Before Width: | Height: | Size: 217 KiB |
@@ -1 +0,0 @@
|
||||
785b5351176ee5e392b36dab82b333308cbf8146
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 157 KiB |
@@ -1,6 +0,0 @@
|
||||
# Consultation Methods
|
||||
|
||||
The author offers long-term customized services. Feel free to reach out for inquiries:
|
||||
|
||||
- WeChat: junyan_qin
|
||||
- QQ: 1010553892
|
||||
@@ -1,5 +0,0 @@
|
||||
# Guide to Large-Scale Usage and Commercial Deployment
|
||||
|
||||
LangBot has already achieved a certain level of production readiness and is currently operating in the production environments of several companies, handling specific business tasks. We understand that you place great importance on compliance and stability issues. This chapter will discuss best practices for commercial deployment based on existing cases.
|
||||
|
||||
Please click on the left-hand menu to view specific content.
|
||||
@@ -1,33 +0,0 @@
|
||||
# Message Platform Stability
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
Most mainstream bots use `reverse engineering` methods to crack QQ's communication protocol, enabling program-controlled functionalities. This approach has a certain gray area and may be subject to Tencent's system risk control.
|
||||
|
||||
Based on current cases, existing reverse engineering methods can achieve relatively stable operation for several months, with service downtime recovery not exceeding 24 hours. There is robust community support, making it suitable for commercial use.
|
||||
|
||||
## Reducing Risk of Being Flagged by Risk Control
|
||||
|
||||
- Enable `forced message delay` and `request rate limiting` in the configuration file to slow down the bot's response time to user messages, thereby reducing the risk of being flagged by risk control.
|
||||
|
||||
- Avoid using the bot in large groups with complex memberships. Generally, this does not cause issues, and there have been cases where bots have run stably in groups of 3000 members for nearly a year. However, if group members frequently report the bot account, it may be flagged by risk control.
|
||||
|
||||
- Run the message platform on a domestic host or a computer using a home network, and try to avoid using overseas hosts.
|
||||
|
||||
## Running Multiple Bot Services
|
||||
|
||||
If the bot's business is weakly related to the account itself, consider running multiple `message platforms` (for example, logging into two Lagrange instances with two accounts). If one bot is banned by Tencent, the other can continue to provide services.
|
||||
|
||||
## Using QQ Official Bot API
|
||||
|
||||
Tencent officially opened the Q group bot API in the second half of 2023. LangBot supports this API well, and you can refer to the deployment tutorial for configuration instructions.
|
||||
|
||||
However, the QQ official bot API has the following known limitations:
|
||||
|
||||
- Requires enterprise qualifications to apply
|
||||
- Only supports group usage, not private chats
|
||||
- Can only receive messages in the group that @mention the bot, and cannot receive other messages in the group
|
||||
- Limited number of active message sends per day
|
||||
- Tencent has strict reviews on bots with AIGC functionalities
|
||||
@@ -1,13 +0,0 @@
|
||||
# AI Content Compliance
|
||||
|
||||
> References to national regulations on AIGC management
|
||||
>
|
||||
> - [Interim Measures for the Management of Generative Artificial Intelligence Services](https://www.cac.gov.cn/2023-07/13/c_1690898327029107.htm)
|
||||
|
||||
In terms of content control, LangBot has built-in content filters such as `Keyword Detection` and `Baidu Intelligent Cloud Review`. For more details, please refer to the configuration file section.
|
||||
|
||||
In practice, content management should be supplemented by methods such as group administrator muting. Regarding the model, the following are recommended solutions (in order of recommendation):
|
||||
|
||||
1. Use domestic models.
|
||||
2. Use strict content filters (can be implemented independently, refer to the plugin function section for details).
|
||||
3. When using foreign models, supplement with strict Prompt controls.
|
||||
@@ -1,43 +0,0 @@
|
||||
# LangBot Command Details
|
||||
|
||||
> Parameters enclosed in `<>` are required; do not include `<>` when using them.
|
||||
> Parameters enclosed in `[]` are optional; do not include `[]` when using them.
|
||||
|
||||
Below is the default permission classification, which can be modified based on the command permission control described later.
|
||||
|
||||
> Only a brief list of commands is provided here. For specific usage, please use the `!cmd` command to view details.
|
||||
|
||||
## User-Level Commands
|
||||
|
||||
Available to any user.
|
||||
|
||||
```
|
||||
!help Display custom help information (can be modified in the configuration file)
|
||||
!cmd [command name] Display the command list or detailed information of a specified command
|
||||
!list [page number] List the historical session records of the current user
|
||||
!del <record number> Delete the specified historical record; the record number can be viewed via !list
|
||||
!del all Delete all historical records of the current session user
|
||||
!last Switch to the previous session
|
||||
!next Switch to the next session
|
||||
!reset Reset the current session
|
||||
!prompt View all records of the current session
|
||||
!version Check the current version and check for updates
|
||||
!resend Roll back the previous request
|
||||
!plugin For usage, please refer to the `Management` section on the plugin introduction page
|
||||
!default View available scenario presets
|
||||
```
|
||||
|
||||
## Administrator Commands
|
||||
|
||||
Only available when an administrator privately chats with the bot. Administrators must first be set in `data/config/system.json`.
|
||||
|
||||
```
|
||||
!update Perform automatic program updates
|
||||
!default set <scenario preset name> Set the default scenario preset for !reset
|
||||
!ollama [show|pull|del] [model name] Display, pull, or delete Ollama model data
|
||||
!model [show|set] [model name] Display or set the currently used model
|
||||
```
|
||||
|
||||
## Command Permission Control
|
||||
|
||||
You can edit `data/config/command.json` to set the permission level for command nodes. When a command is initiated, if the user's permission level (administrator is `2`, regular user is `1`) is greater than or equal to the command node's permission level, the command can be successfully executed. For specific configuration methods, please refer to the configuration file details page.
|
||||
@@ -1,27 +0,0 @@
|
||||
# LangBot Frequently Asked Questions
|
||||
|
||||
## Q: How to fill in the official bot IP whitelist?
|
||||
|
||||
If you are running the bot on your own computer: Open the [IP138](https://ip38.com/) website to get your network's outbound IP, and fill in this IP as shown in the image.
|
||||
|
||||

|
||||
|
||||
If it's not on your own computer (e.g., a cloud server), please check the public IP of the host yourself.
|
||||
|
||||
## Q: Various request failure error cases:
|
||||
|
||||
1. Your model API key is either not filled in or incorrect.
|
||||
|
||||

|
||||
|
||||
2. The relay station has run out of quota.
|
||||
|
||||

|
||||
|
||||
3. Check if the provider's address is correct (did you add /v1 at the end?).
|
||||
|
||||

|
||||
|
||||
## Q: Plugin installation failed?
|
||||
|
||||
Try enabling a network proxy on the host. For Linux, you need to set the environment variables `http_proxy` and `https_proxy`.
|
||||
@@ -1,20 +0,0 @@
|
||||
# Management Panel (Beta Testing)
|
||||
|
||||
The Management Panel (WebUI) will begin Beta testing starting from version v3.4.0. Any issues or suggestions are welcome and can be reported at: https://github.com/RockChinQ/LangBot/issues
|
||||
|
||||

|
||||
|
||||
## Deploying the WebUI
|
||||
|
||||
Instances newly deployed according to the methods described in this document will come with the WebUI enabled by default.
|
||||
|
||||
### Upgrading from a version below 3.4.0?
|
||||
|
||||
If you are using Docker to pull the latest image, it will also include the WebUI. For manually deployed instances, please download the latest version of the `langbot-xxx-all.zip` file from the [Releases](https://github.com/RockChinQ/LangBot) page and extract it to overwrite the previously deployed code directory.
|
||||
|
||||
## Unimplemented Features
|
||||
|
||||
- **Prompt Editor**: A dedicated page for an intuitive and convenient Prompt editor.
|
||||
- **Message Platform Management Page**: Currently, message platform modifications are only supported on the Settings page. In the future, modifications, reloading, and statistics for message platforms will be integrated into a dedicated page.
|
||||
- **Metadata File Editing**: Metadata editing is currently not supported. Please modify the file content according to the documentation for now.
|
||||
- **Model Data Changes**: Dynamic editing of model metadata, the models used, and session-specific model differentiation will be planned after metadata editing is supported. For now, please manually edit the files according to the documentation.
|
||||
@@ -1,31 +0,0 @@
|
||||
# Settings Management
|
||||
|
||||
The content of the settings editing page corresponds to the configuration files in the [Function Configuration Page](/config/function/platform.html). Currently, it supports two editing modes: `Visual Editing` and `JSON Editing`. The JSON editor is consistent with the configuration file content in the Function Configuration Page and can be directly edited.
|
||||
|
||||
## Visual Editing
|
||||
|
||||
### Basic Fields
|
||||
|
||||
Basic fields can be directly edited or selected.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### String Array
|
||||
|
||||
Enter the string you want to add and press the Enter key to add it.
|
||||
|
||||

|
||||
|
||||
### Object Array
|
||||
|
||||
For example, the message platform adapter, where the array contains objects. You can click the `Add` button below to add a new adapter. After selecting the type, the corresponding parameters that need to be filled will be displayed. Fill them in as described in the documentation.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
::: tip
|
||||
After changing the message platform adapter, you need to manually perform a [`Hot Reload`](/webui/system.html#%E7%83%AD%E9%87%8D%E8%BD%BD) to make it effective.
|
||||
:::
|
||||
@@ -1,17 +0,0 @@
|
||||
# System Operations
|
||||
|
||||
## Task List
|
||||
|
||||
The task list tracks the progress of time-consuming tasks such as `plugin updates`, `plugin installations`, and `plugin deletions`.
|
||||
Click the task list button at the bottom of the sidebar to open the task list dialog, where you can view task execution steps, logs, and other information.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Hot Reload
|
||||
|
||||
Currently, hot reload is supported for the message platform and plugins. Click the corresponding button in the system information section at the bottom of the sidebar to perform a hot reload.
|
||||
After modifying the `message platform adapter configuration`, a manual hot reload is required, while plugin changes will trigger an automatic hot reload.
|
||||
|
||||

|
||||
@@ -1,236 +0,0 @@
|
||||
# Integrating Dify on LangBot (NewAPI Relay Solution)
|
||||
|
||||
::: info
|
||||
This article is written by a community contributor.
|
||||
Direct integration with Dify Service API is now supported. Please refer to [How to Integrate Dify?](./dify-service-api) for details.
|
||||
:::
|
||||
|
||||
[Dify](https://dify.ai/) is an open-source AI application development platform that supports multiple AI models and a rich set of plugins for quickly building AI Agents, Workflows, and other applications. Through middleware, we can utilize Dify's features on LangBot.
|
||||
|
||||
::: warning
|
||||
This tutorial assumes the use of a Linux system with LangBot's messaging platform already configured. If you are unfamiliar with Linux or Debian, please do not use this tutorial. If LangBot is not deployed, please configure LangBot first before referring to this tutorial.
|
||||
:::
|
||||
|
||||
## Install and Configure Docker
|
||||
|
||||
Dify recommends using Docker for installation. If you have already started LangBot using Docker, you can skip this step.
|
||||
|
||||
```bash
|
||||
# For Debian:
|
||||
apt update
|
||||
apt install -y docker docker-compose-plugin
|
||||
# For Ubuntu:
|
||||
apt update
|
||||
apt install -y docker docker-compose-v2
|
||||
```
|
||||
|
||||
The Docker image repository is blocked in China, and the official repository is often inaccessible. Therefore, you need to switch to an available mirror site: https://docker.1panel.live
|
||||
|
||||
Use the vim editor to modify the `/etc/docker/daemon.json` file.
|
||||
|
||||
```bash
|
||||
vim /etc/docker/daemon.json
|
||||
```
|
||||
|
||||
The file should be empty. Press the "I" key to enter edit mode and paste the following content:
|
||||
|
||||
```json
|
||||
{
|
||||
"registry-mirrors": ["https://docker.1panel.live"]
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
Press the `Esc` key to exit edit mode, then enter `:wq` to save and exit.
|
||||
|
||||
Restart the Docker service:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
Use `docker info` to check if the change was successful.
|
||||
|
||||

|
||||
|
||||
## Install and Configure Dify
|
||||
|
||||
First, install git:
|
||||
|
||||
```bash
|
||||
apt install -y git
|
||||
```
|
||||
|
||||
Use git to clone the Dify source code and enter the Docker directory:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/langgenius/dify.git
|
||||
cd dify/docker
|
||||
```
|
||||
|
||||
Copy the environment configuration file and start Dify:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||

|
||||
|
||||
This process may take some time, so please be patient.
|
||||
|
||||
After all containers are running successfully, wait for 2-3 minutes, then use a browser to access `http://your-server-address` for the initial setup.
|
||||
|
||||
Set up the administrator account email and password. After setup, log in to Dify.
|
||||
|
||||
Click on the user icon in the top-left corner, then click on Settings.
|
||||
|
||||

|
||||
|
||||
Then click on `Model Providers`.
|
||||
|
||||

|
||||
|
||||
Here, I have already added the necessary configurations based on my requirements.
|
||||
|
||||
Go to the Studio → Create a Blank Application, and select `Chat Assistant`.
|
||||
|
||||
> Basic Orchestration: Fewer features but simpler configuration
|
||||
> Workflow Orchestration: Complex functionality based on workflows but harder to configure, not suitable for beginners
|
||||
>
|
||||
> Choose based on your needs.
|
||||
|
||||

|
||||
|
||||
Fill in the basic information such as the name, then click Create.
|
||||
|
||||

|
||||
|
||||
Select the model in the top-right corner.
|
||||
After setting up, click on Publish → Update in the top-right corner to update the application. If not updated, it cannot be used.
|
||||
|
||||

|
||||
|
||||
Then click on Access API, and in the top-right corner, click on API Keys → Create Key. Copy the generated key content.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
The Dify configuration part is now complete.
|
||||
|
||||
## Deploy the NewAPI Middleware
|
||||
|
||||
Dify's API does not use the standard OpenAI API, so a relay is needed.
|
||||
|
||||
We will use [new-api](https://github.com/Calcium-Ion/new-api).
|
||||
|
||||
Install wget:
|
||||
|
||||
```bash
|
||||
apt install -y wget
|
||||
```
|
||||
|
||||
Create a directory in the ~ directory to store new-api:
|
||||
|
||||
```bash
|
||||
mkdir ~/new-api
|
||||
```
|
||||
|
||||
Download New-api:
|
||||
|
||||
```bash
|
||||
cd new-api
|
||||
```
|
||||
|
||||
For arm64:
|
||||
|
||||
```bash
|
||||
wget https://github.com/Calcium-Ion/new-api/releases/download/v0.2.9.7/one-api-arm64
|
||||
```
|
||||
|
||||
For x86/64:
|
||||
|
||||
```bash
|
||||
wget https://github.com/Calcium-Ion/new-api/releases/download/v0.2.9.7/one-api
|
||||
```
|
||||
|
||||
(arm64 is generally for development boards. If you don't know what a development board is or what arm64 is, just use x86/64.)
|
||||
|
||||
Install screen for process management:
|
||||
|
||||
```bash
|
||||
apt install -y screen
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```bash
|
||||
screen -R name
|
||||
```
|
||||
|
||||
Create a new screen. If a screen with the same name exists, it will enter that screen.
|
||||
|
||||
```bash
|
||||
cd ~/new-api
|
||||
```
|
||||
|
||||
Add permissions:
|
||||
|
||||
```bash
|
||||
chmod 775 new-api
|
||||
```
|
||||
|
||||
Run new-api:
|
||||
|
||||
```bash
|
||||
./new-api
|
||||
```
|
||||
|
||||
Wait for it to finish running.
|
||||
|
||||
```bash
|
||||
Ctrl+a+d
|
||||
```
|
||||
|
||||
Exit the current window (run in the background).
|
||||
|
||||
Access the following URL in a browser:
|
||||
|
||||
```bash
|
||||
http://your-server-address:3000/
|
||||
```
|
||||
|
||||
Default username: root
|
||||
Default password: 123456
|
||||
|
||||
After logging in, go to:
|
||||
`User Management → Edit → Password`
|
||||
Change the root password.
|
||||
After changing the password, click on
|
||||
`Channels → Add Channel`
|
||||
|
||||

|
||||
|
||||
Select dify in the Type field, fill in the name, and click on Fill in the relevant models.
|
||||
Fill in the key, which is the key content generated during the Dify configuration.
|
||||
|
||||

|
||||
|
||||
Go to the Tokens page in new-api, click on Add Token, and fill in the basic information as prompted. Set the name, expiration, and quota as needed.
|
||||
|
||||

|
||||
|
||||
After submitting, find the newly created token, hover over `View`, and copy the sk- prefixed content.
|
||||
|
||||
The basic configuration of new-api is now complete. Configure the rest as needed.
|
||||
|
||||
## Configure LangBot
|
||||
|
||||
Use the OpenAI provider, set the NewAPI address as the API address, and the NewAPI key as the API Key.
|
||||
|
||||

|
||||
|
||||
Restart the LangBot project. The integration with Dify is now complete.
|
||||
@@ -1,20 +0,0 @@
|
||||
# Using Dify on LangBot
|
||||
|
||||
[Dify](https://dify.ai) is an open-source large language model (LLM) application development platform. It combines the concepts of Backend as a Service (BaaS) and LLMOps, enabling developers to quickly build production-grade generative AI applications.
|
||||
Dify can create applications such as chat assistants (with advanced orchestration), Agents, text generation applications, workflows, and more.
|
||||
|
||||
LangBot currently supports three types of Dify applications: `Chat Assistant`, `Agent`, and `Workflow`.
|
||||
|
||||
## Creating an Application on Dify
|
||||
|
||||
Please refer to the [Dify documentation](https://docs.dify.ai) to deploy Dify and create your application.
|
||||
|
||||
After publishing the application, generate an API key on the `Access API` page of the application.
|
||||
|
||||

|
||||
|
||||
Save the API server and API key, and configure them in the `provider.json` file of LangBot.
|
||||
|
||||
## Configuring LangBot
|
||||
|
||||
Refer to the [Dify Service API Configuration](../config/function/provider#dify-service-api-configuration-dify-service-api) documentation to configure the `provider.json` file of LangBot.
|
||||
@@ -1,71 +0,0 @@
|
||||
# Implementing a Message Platform Adapter
|
||||
|
||||
:::info
|
||||
Please read the chapter on Plugin Development -> Component Extension first to understand LangBot's component extension mechanism.
|
||||
:::
|
||||
|
||||
This article will use the `aiocqhttp` adapter as an example to explain how to implement a new message platform adapter for LangBot, enabling integration with new message platform protocols such as WhatsApp and Discord.
|
||||
|
||||
- The code in this article is based on version `v3.4.1.5`.
|
||||
|
||||
## Registration
|
||||
|
||||
First, refer to the instructions on the component extension page:
|
||||
|
||||
```text
|
||||
Add a new message platform adapter, for example, to integrate WhatsApp, Discord, etc.
|
||||
|
||||
- Base class: `pkg.platform.adapter.MessageSourceAdapter`
|
||||
- Decorator: `pkg.platform.adapter.adapter_class(name: str)`
|
||||
- Reference implementation: `pkg.platform.adapters/`
|
||||
- Usage: The configuration information in `data/config/platform.json` under `platform-adapters` will automatically look up the corresponding adapter implementation based on the `adapter` name during initialization, and pass the configuration to the adapter for initialization. The implementation of message platform adapters is complex, so it is recommended to refer to existing implementations.
|
||||
```
|
||||
|
||||
Implementing a message platform adapter essentially involves creating a class that inherits from the `base class` and registering it using the `decorator`. Finally, it will be available for users to select and use during runtime.
|
||||
|
||||
### Writing to a Plugin
|
||||
|
||||
Create a new `aiocqhttp.py` file in the plugin directory:
|
||||
|
||||
```python
|
||||
import pkg.platform.adapter
|
||||
|
||||
@pkg.platform.adapter.adapter_class("aiocqhttp")
|
||||
class AiocqhttpAdapter(pkg.platform.adapter.MessageSourceAdapter):
|
||||
pass
|
||||
```
|
||||
|
||||
During startup, LangBot's plugin loader will automatically load this module (file) and register it to the message platform adapter list.
|
||||
|
||||
### Contributing Directly to the Main Repository
|
||||
|
||||
Create a new `aiocqhttp.py` file in the `pkg/platform/sources/` directory:
|
||||
|
||||
```python
|
||||
from .. import adapter
|
||||
|
||||
@adapter.adapter_class("aiocqhttp")
|
||||
class AiocqhttpAdapter(adapter.MessageSourceAdapter):
|
||||
pass
|
||||
```
|
||||
|
||||
Also, import this module at line 40 in `pkg/platform/manager.py`:
|
||||
|
||||
```python
|
||||
from .sources import nakuru, aiocqhttp, qqbotpy
|
||||
```
|
||||
|
||||
## Event and Message Converters
|
||||
|
||||
The main task of a message platform adapter is to `receive events from the message platform protocol, convert them into LangBot's format`, and pass them to the core components. After processing, the core components will pass the content that needs to be replied back to the message platform adapter, which will then `convert the content into the platform protocol's format and send it to the message platform`.
|
||||
|
||||
The following diagram illustrates the processing patterns for two scenarios: message platform protocols without an SDK and those with a mature SDK. In the first scenario, we need to implement connection management and convert network format data into LB message Python objects based on the message platform protocol's documentation. In the second scenario, where the message platform has a mature SDK, we only need to create a connection by calling the SDK's API, register event listeners, and implement message converters based on the SDK's documentation.
|
||||
|
||||

|
||||
|
||||
In the `pkg.platform.sources.aiocqhttp` file, we can see not only `AiocqhttpAdapter`, but also `class AiocqhttpMessageConverter(adapter.MessageConverter):` and `class AiocqhttpEventConverter(adapter.EventConverter):`.
|
||||
|
||||
- `MessageConverter` is used to convert between LangBot messages and platform messages.
|
||||
- `EventConverter` is used to convert between LangBot events and platform events.
|
||||
|
||||
TBC...
|
||||
@@ -1,73 +0,0 @@
|
||||
# Integrating OneAPI, LinkAI, and Other Third-Party OpenAI-Compatible APIs into LangBot
|
||||
|
||||
::: info
|
||||
Reposted from: [https://rockchin.top/?p=295](https://rockchin.top/?p=295)
|
||||
:::
|
||||
|
||||
Since the rise of OneAPI, various "ghosts and goblins" models can now be accessed in OpenAI's format. Additionally, relay stations have become popular, and OpenAI's format has become the standard access format for AI App platforms and other AI tools. This article explains how to integrate the aforementioned OpenAI-compatible APIs into LangBot.
|
||||
|
||||
First, follow the LangBot documentation to deploy the messaging platform and the LangBot main program, and connect them. When you reach the step of configuring `provider.json`, refer to this document.
|
||||
|
||||
From here on, we will not distinguish between LinkAI, OneAPI, or relay stations, and will uniformly refer to them as OneAPI interfaces, representing third-party OpenAI-compatible interfaces.
|
||||
|
||||
## Obtaining the OneAPI Interface Address and Access Key
|
||||
|
||||
::: warning
|
||||
If you have deployed OneAPI yourself, you need to set up the channels first. Please refer to the OneAPI documentation for details. After configuration, you can obtain the key.
|
||||
:::
|
||||
|
||||
Taking OneAPI as an example, if you have deployed OneAPI locally using port 8080, the interface address would be `http://127.0.0.1:8080/v1`.
|
||||
|
||||
For others, please refer to their documentation or consult the relay station administrator. In general, the address usually needs to be suffixed with `/v1`.
|
||||
|
||||
For the access key, using OneAPI as an example, go to the "Tokens" page and create a new key.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Return to the Tokens page and click "Copy" to obtain the API key.
|
||||
|
||||
For other relay stations, please refer to their documentation or consult the administrator.
|
||||
|
||||
## Filling in the LangBot Configuration File
|
||||
|
||||
Modify the `provider` configuration in `data/config/provider.json` to use the `openai-chat-completions` requester:
|
||||
|
||||

|
||||
|
||||
Fill in the address you just obtained in the `base-url` field as shown in the image. In this example, it is my OneAPI station (for personal use).
|
||||
|
||||
Next, fill in the key you just obtained in the `keys` section under `openai`:
|
||||
|
||||

|
||||
|
||||
Please ensure it complies with JSON syntax.
|
||||
|
||||
Finally, configure the model to be used by filling in the model name provided by your OneAPI.
|
||||
|
||||

|
||||
|
||||
Note that some available model names are already preset in the metadata file `data/metadata/llm-models.json`. If the model you are using does not have corresponding metadata, you will need to add it yourself.
|
||||
|
||||
## Adding Models Not in the Preset
|
||||
|
||||
Check all elements in the `list` field of `data/metadata/llm-models.json`. If no element's `name` matches the model name you want to use, or if the corresponding `requester` or `token_mgr` is not `openai-chat-completions` or `openai`, you will need to add it.
|
||||
|
||||
Refer to the metadata configuration. In this example, we add a model with `requester` set to `openai-chat-completions` and `token_mgr` set to `openai`, for example:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "qwen",
|
||||
"requester": "openai-chat-completions",
|
||||
"token_mgr": "openai",
|
||||
"tool_call_supported": false,
|
||||
"vision_supported": false
|
||||
},
|
||||
```
|
||||
|
||||
`name` is your model name, corresponding to the model name provided by OneAPI, and matches the value filled in the `model` field above.
|
||||
|
||||
`tool_call_supported`: Whether the model supports tool usage, set according to the actual model capabilities.
|
||||
|
||||
`vision_supported`: Whether the model supports vision, set according to the actual model capabilities.
|
||||
@@ -210,225 +210,197 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
// en: {
|
||||
// label: "English",
|
||||
// lang: "en",
|
||||
// link: "/en/",
|
||||
// themeConfig: {
|
||||
// // https://vitepress.dev/reference/default-theme-config
|
||||
en: {
|
||||
title: "LangBot Docs",
|
||||
label: "English",
|
||||
lang: "en",
|
||||
link: "/en/",
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
|
||||
// nav: [
|
||||
// { text: "Home", link: "/en/" },
|
||||
// { text: "Insight", link: "/en/insight/guide" },
|
||||
// { text: "Deploy", link: "/en/deploy/langbot/manual" },
|
||||
// { text: "Plugin", link: "/en/plugin/plugin-intro" },
|
||||
// ],
|
||||
nav: [
|
||||
{ text: "Home", link: "https://langbot.app" },
|
||||
{ text: "Roadmap", link: "https://langbot.featurebase.app/roadmap" },
|
||||
],
|
||||
|
||||
// sidebar: [
|
||||
// {
|
||||
// text: "Insight",
|
||||
// items: [
|
||||
// { text: "Getting Started", link: "/en/insight/guide" },
|
||||
// { text: "Introduction", link: "/en/insight/intro" },
|
||||
// { text: "Community Resources", link: "/en/insight/community" },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Deploy",
|
||||
// items: [
|
||||
// {
|
||||
// text: "Deploy LangBot",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// {
|
||||
// text: "Deploy with Baota Panel",
|
||||
// link: "/en/deploy/langbot/one-click/bt",
|
||||
// },
|
||||
// {
|
||||
// text: "Deploy with Docker",
|
||||
// link: "/en/deploy/langbot/docker",
|
||||
// },
|
||||
// {
|
||||
// text: "Manual Deployment",
|
||||
// link: "/en/deploy/langbot/manual",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Deploy Message Platforms",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// {
|
||||
// text: "aiocqhttp",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// {
|
||||
// text: "NapCat",
|
||||
// link: "/en/deploy/platforms/aiocqhttp/napcat",
|
||||
// },
|
||||
// {
|
||||
// text: "Lagrange",
|
||||
// link: "/en/deploy/platforms/aiocqhttp/lagrange",
|
||||
// },
|
||||
// {
|
||||
// text: "llonebot",
|
||||
// link: "/en/deploy/platforms/aiocqhttp/llonebot",
|
||||
// },
|
||||
// {
|
||||
// text: "shamrock",
|
||||
// link: "/en/deploy/platforms/aiocqhttp/shamrock",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "go-cqhttp",
|
||||
// link: "/en/deploy/platforms/gocq",
|
||||
// },
|
||||
// {
|
||||
// text: "QQ Official",
|
||||
// link: "/en/deploy/platforms/official",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Fill in the Configuration",
|
||||
// link: "/en/deploy/quick-config/config",
|
||||
// },
|
||||
// {
|
||||
// text: "Network Configuration",
|
||||
// link: "/en/deploy/network-details",
|
||||
// },
|
||||
// {
|
||||
// text: "Update LangBot",
|
||||
// link: "/en/deploy/update",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
sidebar: [
|
||||
{
|
||||
text: "Overview",
|
||||
items: [
|
||||
{ text: "Getting Started (Must Read)", link: "/en/insight/guide" },
|
||||
{ text: "Community Resources", link: "/en/insight/community" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Deployment and Usage",
|
||||
items: [
|
||||
{
|
||||
text: "Deploy LangBot",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: "Docker Deployment", link: "/en/deploy/langbot/docker" },
|
||||
{
|
||||
text: "Baota Panel Deployment",
|
||||
link: "/en/deploy/langbot/one-click/bt",
|
||||
},
|
||||
{ text: "Manual Deployment", link: "/en/deploy/langbot/manual" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Configure Bots",
|
||||
collapsed: true,
|
||||
link: "/en/deploy/platforms/readme",
|
||||
items: [
|
||||
{
|
||||
text: "OneBot v11",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: "NapCat",
|
||||
link: "/en/deploy/platforms/qq/aiocqhttp/napcat",
|
||||
},
|
||||
{
|
||||
text: "Lagrange",
|
||||
link: "/en/deploy/platforms/qq/aiocqhttp/lagrange",
|
||||
},
|
||||
{
|
||||
text: "llonebot",
|
||||
link: "/en/deploy/platforms/qq/aiocqhttp/llonebot",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "QQ Official Bot",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: "Webhook Method",
|
||||
link: "/en/deploy/platforms/qq/official_webhook",
|
||||
},
|
||||
{
|
||||
text: "WebSocket Method",
|
||||
link: "/en/deploy/platforms/qq/official",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Personal WeChat",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: "Gewechat",
|
||||
link: "/en/deploy/platforms/wechat/gewechat",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "WeCom (Enterprise WeChat)",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: "Internal Application",
|
||||
link: "/en/deploy/platforms/wecom/wecom",
|
||||
},
|
||||
{
|
||||
text: "External Customer Service",
|
||||
link: "/en/deploy/platforms/wecom/wecomcs",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ text: "WeChat Official Account", link: "/en/deploy/platforms/wxoa" },
|
||||
{ text: "Feishu (Lark)", link: "/en/deploy/platforms/lark" },
|
||||
{ text: "DingTalk", link: "/en/deploy/platforms/dingtalk" },
|
||||
{ text: "Discord", link: "/en/deploy/platforms/discord" },
|
||||
{ text: "Telegram", link: "/en/deploy/platforms/telegram" },
|
||||
{ text: "Slack", link: "/en/deploy/platforms/slack" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Configure Models",
|
||||
link: "/en/deploy/models/readme",
|
||||
},
|
||||
{
|
||||
text: "Modify Dialogue Pipeline",
|
||||
link: "/en/deploy/pipelines/readme",
|
||||
},
|
||||
{
|
||||
text: "System Settings",
|
||||
link: "/en/deploy/settings",
|
||||
},
|
||||
{
|
||||
text: "Dialogue Commands",
|
||||
link: "/en/deploy/command",
|
||||
},
|
||||
{
|
||||
text: "Update LangBot",
|
||||
link: "/en/deploy/update",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Plugins",
|
||||
items: [
|
||||
{ text: "Plugin Introduction", link: "/en/plugin/plugin-intro" },
|
||||
{
|
||||
text: "Plugin Development",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: "Basic Tutorial", link: "/en/plugin/dev/tutor" },
|
||||
{ text: "Message Platform Entities", link: "/en/plugin/dev/messages" },
|
||||
{ text: "API Reference", link: "/en/plugin/dev/api-ref" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Workshops",
|
||||
items: [
|
||||
{
|
||||
text: "How to Integrate with Dify?",
|
||||
link: "/en/workshop/dify-service-api",
|
||||
},
|
||||
{
|
||||
text: "How to Implement a Message Platform Adapter?",
|
||||
link: "/en/workshop/impl-platform-adapter",
|
||||
},
|
||||
{
|
||||
text: "Integrating Complete MCP Ecosystem in LangBot",
|
||||
link: "/en/workshop/mcp-details"
|
||||
},
|
||||
{
|
||||
text: "Container Network Configuration Details",
|
||||
link: "/en/workshop/network-details",
|
||||
},
|
||||
{
|
||||
text: "Integrating PPIO API",
|
||||
link: "/en/workshop/ppio-integration"
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "Development",
|
||||
items: [
|
||||
{ text: "Development Configuration", link: "/en/develop/dev-config" },
|
||||
{ text: "Component Architecture", link: "/en/develop/comp-arch" },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// {
|
||||
// text: "Usage",
|
||||
// items: [
|
||||
// { text: "Command Usage", link: "/en/usage/command" },
|
||||
// { text: "FAQ", link: "/en/usage/faq" },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Config",
|
||||
// items: [
|
||||
// {
|
||||
// text: "Function Configuration",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// {
|
||||
// text: "platform.json",
|
||||
// link: "/en/config/function/platform",
|
||||
// },
|
||||
// {
|
||||
// text: "pipeline.json",
|
||||
// link: "/en/config/function/pipeline",
|
||||
// },
|
||||
// {
|
||||
// text: "provider.json",
|
||||
// link: "/en/config/function/provider",
|
||||
// },
|
||||
// { text: "command.json", link: "/en/config/function/command" },
|
||||
// { text: "system.json", link: "/en/config/function/system" },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Metadata Configuration",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// {
|
||||
// text: "sensitive-words.json",
|
||||
// link: "/en/config/metadata/sensitive-words",
|
||||
// },
|
||||
// {
|
||||
// text: "llm-models.json",
|
||||
// link: "/en/config/metadata/llm-models",
|
||||
// },
|
||||
// {
|
||||
// text: "adapter-qq-botpy.json",
|
||||
// link: "/en/config/metadata/adapter-qq-botpy",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Plugin",
|
||||
// items: [
|
||||
// { text: "Plugin Introduction", link: "/en/plugin/plugin-intro" },
|
||||
// {
|
||||
// text: "Plugin Development",
|
||||
// collapsed: true,
|
||||
// items: [
|
||||
// { text: "Basic Tutorial", link: "/en/plugin/dev/tutor" },
|
||||
// {
|
||||
// text: "Message Platform Entity",
|
||||
// link: "/en/plugin/dev/messages",
|
||||
// },
|
||||
// { text: "API Reference", link: "/en/plugin/dev/api-ref" },
|
||||
// {
|
||||
// text: "Component Extension",
|
||||
// link: "/en/plugin/dev/extension",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "WebUI (Beta)",
|
||||
// items: [
|
||||
// { text: "Introduction & Usage", link: "/en/webui/intro" },
|
||||
// { text: "System Operation", link: "/en/webui/system" },
|
||||
// { text: "Settings Management", link: "/en/webui/settings" },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Workshop",
|
||||
// items: [
|
||||
// {
|
||||
// text: "How to Access Dify Service API?",
|
||||
// link: "/en/workshop/dify-service-api",
|
||||
// },
|
||||
// {
|
||||
// text: "How to Access Dify Service API? - NewAPI Intermediate Solution",
|
||||
// link: "/en/workshop/dify-integration",
|
||||
// },
|
||||
// {
|
||||
// text: "How to Access Third-party OpenAI Format APIs like OneAPI, LinkAI?",
|
||||
// link: "/en/workshop/one-api",
|
||||
// },
|
||||
// {
|
||||
// text: "How to Implement a Message Platform Adapter?",
|
||||
// link: "/en/workshop/impl-platform-adapter",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// text: "Develop",
|
||||
// items: [
|
||||
// { text: "Component Architecture", link: "/en/develop/comp-arch" },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// edit link
|
||||
editLink: {
|
||||
pattern:
|
||||
"https://github.com/the-lazy-me/Langbot-Wiki/edit/main/docs/:path",
|
||||
},
|
||||
|
||||
// // edit link
|
||||
// editLink: {
|
||||
// pattern:
|
||||
// "https://github.com/the-lazy-me/Langbot-Wiki/edit/main/docs/:path",
|
||||
// },
|
||||
|
||||
// // social links in the navbar
|
||||
// socialLinks: [
|
||||
// {
|
||||
// icon: "github",
|
||||
// link: "https://github.com/the-lazy-me/QChatGPT-Wiki",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// social links in the navbar
|
||||
socialLinks: [
|
||||
{
|
||||
icon: "github",
|
||||
link: "https://github.com/RockChinQ/LangBot",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// 最后更新时间
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Command Details
|
||||
|
||||
> Parameters in `<>` are required, do not include `<>` when using
|
||||
> Parameters in `[]` are optional, do not include `[]` when using
|
||||
> Here we only list the commands briefly, for detailed usage please use the `!cmd` command
|
||||
|
||||
## Command List
|
||||
|
||||
Available to any object
|
||||
|
||||
```
|
||||
!help Display custom help information (can be changed in the configuration file)
|
||||
!cmd [command name] Display command list or detailed information for a specific command
|
||||
!list [page number] List the history sessions for this object
|
||||
!del <number> Delete the specified history record, you can view the number with !list
|
||||
!del all Delete all history records for this session object
|
||||
!last Switch to the previous session
|
||||
!next Switch to the next session
|
||||
!reset Reset the current session
|
||||
!prompt View all records of the current session
|
||||
!version Check the current version and check for updates
|
||||
!resend Rollback the previous request
|
||||
!plugin For usage, please see the `Management` section of the plugin introduction page
|
||||
```
|
||||
|
||||
## Command Permission Control
|
||||
|
||||
You can [edit the system environment settings](/en/deploy/settings.md) to set permissions for command nodes. When a command is initiated, if the user's permission level (administrator is `2`, regular user is `1`) is greater than or equal to the command node's permission level, the command can be successfully executed.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Docker Deployment
|
||||
|
||||
:::warning
|
||||
It is recommended that you first learn the following:
|
||||
|
||||
- Usage of `Docker` and `Docker Compose`
|
||||
- Docker container network communication configuration methods
|
||||
:::
|
||||
|
||||
:::info
|
||||
- Please ensure Git, Docker, and Docker Compose are installed
|
||||
:::
|
||||
|
||||
Clone the project:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/RockChinQ/LangBot
|
||||
cd LangBot
|
||||
```
|
||||
|
||||
Start the container:
|
||||
|
||||
```bash
|
||||
docker compose up
|
||||
```
|
||||
|
||||
The container maps port `5300` for WebUI access. You can visit `http://127.0.0.1:5300` to view the WebUI.
|
||||
It also maps ports `2280-2290` for reserved for message platform adapters.
|
||||
|
||||
After completing the LangBot deployment, please continue reading:
|
||||
|
||||
- [Bot Configuration Documentation](/en/deploy/platforms/readme).
|
||||
- [Model Configuration Documentation](/en/deploy/models/readme).
|
||||
@@ -0,0 +1,86 @@
|
||||
# Manual Deployment
|
||||
|
||||
:::warning
|
||||
1. Please use Python 3.10.1 (not including 3.10.0) or higher version, 3.10.14 is recommended. You need to install Python if you don't have it.
|
||||
2. This method is not recommended, manual deployment may not be supported in the future. Please consider using Docker deployment.
|
||||
:::
|
||||
|
||||
## Installing the Main Program
|
||||
|
||||
1. Go to the [Release](https://github.com/RockChinQ/LangBot/releases) page to download the latest version of the zip package (recommended) `langbot-xxx-all.zip` (do not download Source Code as it does not include WebUI). Extract it and open a command line (terminal) in the extracted directory.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
|
||||
You can also use the following commands to clone the latest code (may contain unstable code) and use it:
|
||||
|
||||
```bash
|
||||
# Clone the main repository
|
||||
git clone https://github.com/RockChinQ/LangBot
|
||||
cd LangBot
|
||||
```
|
||||
|
||||
If you are in mainland China, you can clone from the [GitCode mirror](https://gitcode.com/RockChinQ/LangBot):
|
||||
|
||||
```bash
|
||||
git clone https://gitcode.com/RockChinQ/LangBot
|
||||
cd LangBot
|
||||
```
|
||||
|
||||
Then manually build the frontend:
|
||||
|
||||
```bash
|
||||
# Build frontend, requires NodeJS >= 22
|
||||
cd web
|
||||
npm install && npm run build
|
||||
cd ..
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
2. (Recommended) Create a virtual environment
|
||||
|
||||
On some Linux systems that use system package managers to manage Python dependencies, dependency conflicts may occur, so please use venv to create a virtual environment. Windows users can skip this step.
|
||||
|
||||
```bash
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Or use Tsinghua mirror
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
```
|
||||
|
||||
4. Run the main program once to generate configuration files
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
You will see the following message:
|
||||
|
||||
```
|
||||
_ ___ _
|
||||
| | __ _ _ _ __ _| _ ) ___| |_
|
||||
| |__/ _` | ' \/ _` | _ \/ _ \ _|
|
||||
|____\__,_|_||_\__, |___/\___/\__|
|
||||
|___/
|
||||
|
||||
⭐️Open Source: https://github.com/RockChinQ/LangBot
|
||||
📖Documentation: https://docs.langbot.app
|
||||
|
||||
The following files do not exist and have been automatically generated. Please modify the configuration files as needed and restart:
|
||||
- plugins/__init__.py
|
||||
...
|
||||
```
|
||||
|
||||
You can now use Ctrl+C to exit the program and continue to the [Deploy Message Platform](/en/deploy/platforms/readme) page.
|
||||
@@ -0,0 +1,53 @@
|
||||
# aaPanel Deployment
|
||||
|
||||
Deploy LangBot with one click using [aaPanel](https://www.bt.cn/new/download.html?r=dk_LangBot).
|
||||
|
||||
:::warning
|
||||
- Unless you plan to use message platforms like Discord or Feishu that don't require additional containers, or you are familiar with Docker container networking on aaPanel, it's not recommended to use one-click deployment with aaPanel. Please consider using [Docker deployment](/en/deploy/langbot/docker).
|
||||
- If you already have aaPanel installed, please update to version **9.2.0** or higher
|
||||
:::
|
||||
|
||||
|
||||
## Installing aaPanel
|
||||
|
||||
> Recommended server systems (from aaPanel): Debian 12, Ubuntu 22, etc.
|
||||
>
|
||||
> This document assumes you have a server with a public IPv4 address. If you're using a home machine without a public IP, you can access the relevant pages through the internal network mentioned below.
|
||||
|
||||
Open [aaPanel](https://www.bt.cn/new/download.html?r=dk_LangBot), use the Linux panel installation script provided by aaPanel official, and select the corresponding script based on your system.
|
||||
|
||||

|
||||
|
||||
Copy the corresponding script and paste it into your server to execute.
|
||||
|
||||
## Installing LangBot
|
||||
|
||||
After waiting for a while, aaPanel installation will be complete.
|
||||
|
||||
You'll see a message similar to this, copy the external panel address and open it in your browser.
|
||||
|
||||

|
||||
|
||||
When you first open it, you should see a popup for `Recommended Installation Suite`. You can skip this by closing it.
|
||||
|
||||
Then click on `docker` in the sidebar. If it's your first time, you'll be prompted to install Docker and Docker Compose services. Click "Install Now" if prompted, or ignore if already installed.
|
||||
|
||||
Then go to `Docker -> App Store`, search for `LangBot` (note the case sensitivity), click `Install`, and use the default configuration.
|
||||
|
||||
After a short wait, you'll see a container named `langbot_XXXX` showing as `Running`.
|
||||
|
||||

|
||||
|
||||
Click the red circle in the image above to view the running logs.
|
||||
|
||||

|
||||
|
||||
You can see the external and internal access paths for the WebUI configuration page (visual configuration page). Copy the public address, for example `http://xxx.xxx.xxx.xxx:5300` (where xxx.xxx.xxx.xxx is your aaPanel IP, and 5300 is the port number, which may vary as shown in the image).
|
||||
|
||||
After opening it, enter your admin email and password, then click initialize.
|
||||
|
||||
You can then proceed with configuration in the visual interface.
|
||||
|
||||
If you prefer to directly modify JSON configuration files, you can look at the local mapping directory shown in the image above. Go to the installation directory, where the `data` folder is used to store configuration files, and the `plugins` folder is used for plugin-related files.
|
||||
|
||||
Next, please continue reading the [Deploy Message Platform](/en/deploy/platforms/readme) page.
|
||||
@@ -0,0 +1,31 @@
|
||||
# Configure Models (Models)
|
||||
|
||||
Models will be used by pipelines to process messages. The first model you configure will be set as the model for the default pipeline.
|
||||
|
||||

|
||||
|
||||
You can add multiple models, and then select which model to use in the pipeline.
|
||||
|
||||

|
||||
|
||||
Enter these four parameters: `Model Name`, `Model Provider`, `Request URL`, and `API Key`, then submit.
|
||||
|
||||
For model capabilities, please choose according to the specific model characteristics:
|
||||
|
||||
- Visual Capability: Needs to be enabled to recognize images
|
||||
|
||||
- Function Calling: Needs to be enabled to use Agent tools in conversations
|
||||
|
||||
:::info
|
||||
|
||||
*If you don't have an API Key, you can [get one from this relay station](https://api.qhaigc.net/)*
|
||||
|
||||
If you need to use third-party API relays or other model providers,
|
||||
|
||||
Select `OpenAI`
|
||||
|
||||
Fill in the relay's Base URL for the Request URL, for example:
|
||||
|
||||

|
||||
|
||||
:::
|
||||
@@ -0,0 +1,48 @@
|
||||
# Modify Dialogue Pipeline Configuration (Pipelines)
|
||||
|
||||
The pipeline controls the processing flow after receiving a message, as well as the information exchange with the large language model. Each bot can be bound to one pipeline, and the same pipeline can be bound to multiple bots.
|
||||
|
||||
LangBot automatically creates a default pipeline when first started. When creating a bot, it is automatically bound to the default pipeline. When creating the first model, it is automatically set as the model for the default pipeline.
|
||||
|
||||

|
||||
|
||||
You can create multiple pipelines for different bots to adapt to different scenarios.
|
||||
|
||||
|
||||
|
||||
The current pipeline can be configured with the following features:
|
||||
|
||||
## AI Capabilities
|
||||
|
||||
You can choose to use: regular large language model `Built-in Agent`, [`Dify`](https://dify.ai/), [`Alibaba Cloud Bailian`](https://www.aliyun.com/product/bailian?source=5176.29345612&userCode=ys4ad8gs)
|
||||
|
||||
AI capabilities are mainly divided into two parts: selecting the runner and configuring runner parameters.
|
||||
|
||||
The runner defines how to schedule the large model to process messages. The default is `Built-in Agent`, which is a multi-round Agent strategy implemented by LangBot. Only when this runner is selected will the models and tools configured internally in LangBot be used.
|
||||
|
||||
*<!--  -->*
|
||||
|
||||
<img width="400px" src="/assets/image/zh/deploy/pipelines/edit_pipeline_ai.png" alt="edit_pipeline" />
|
||||
|
||||
You can also choose to use external LLMOps platforms such as `Dify`, [`Alibaba Cloud Bailian`](https://www.aliyun.com/product/bailian?source=5176.29345612&userCode=ys4ad8gs). In this case, the models, prompts, tools, and other resources used will be provided by the LLMOps platform.
|
||||
|
||||
<img width="400px" src="/assets/image/zh/deploy/pipelines/more_runner.png" alt="more_runner" />
|
||||
|
||||
- For detailed steps on connecting to Dify, you can [refer to the tutorial](/en/workshop/dify-service-api.html).
|
||||
|
||||
### Conversation Variables
|
||||
|
||||
When using Dify or Alibaba Cloud Bailian, LangBot explicitly passes the following parameters, which you can add to the start node of the Dify workflow:
|
||||
|
||||
- `user_message_text`: The plain text of the user message
|
||||
- `session_id`: User session ID, `person_<id>` for private chat, `group_<id>` for group chat
|
||||
- `conversation_id`: String, user session ID, generated by LangBot. It will be regenerated after the user resets the session
|
||||
- `msg_create_time`: Numeric type, timestamp (seconds) when this message was received
|
||||
|
||||
You can [customize any variable through plugins](/en/plugin/dev/api-ref.html#%E8%AE%BE%E7%BD%AE%E8%AF%B7%E6%B1%82%E5%8F%98%E9%87%8F).
|
||||
|
||||

|
||||
|
||||
## Other Configurations
|
||||
|
||||
Please refer to the descriptions in the configuration form.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Deploy DingTalk Bot
|
||||
|
||||
Deploy LangBot to DingTalk.
|
||||
|
||||
## Create Bot
|
||||
|
||||
Enter the [DingTalk Developer Backend](https://open-dev.dingtalk.com/?spm=ding_open_doc.document.0.0.74f445e5MkawbT#/), log in and enter the organization. After successful login, enter the open platform, which looks like this:
|
||||

|
||||
|
||||
Click `Application Development` at the top, then click the blue button `Create Application` on the right, fill in the basic information of the bot, and click save.
|
||||
|
||||
Enter the bot's backend, for example, if we have a bot named langbot2, its management page looks like this:
|
||||

|
||||
|
||||
## Configure Bot
|
||||
|
||||
Click `Add Application Capability`, `Other Application Capabilities`, `Configure` in `Robot`, click configure and fill in the information, as shown below:
|
||||

|
||||
|
||||
Click `Publish` at the bottom of the page, after successful publication, click `Version Management and Publishing` at the bottom left of the bot page, as shown:
|
||||

|
||||
|
||||
If this is the first time creating a bot, the right side is empty, you need to click `Create New Version`, set information in it, then set `Application Visibility Range`, and click save.
|
||||
|
||||
Click `Event Subscription`, change the push method to `Stream Mode Push`.
|
||||
|
||||
## Fill in Configuration Information
|
||||
|
||||
Click `Credentials and Basic Information`, record `Client ID` and `Client Secret`,
|
||||
Click `Application Capabilities`, `Robot`, record the RobotCode and Robot Name.
|
||||
`markdown_card` is whether to enable Markdown form replies.
|
||||
Record the above configuration items and fill them in the LangBot bot configuration form
|
||||
|
||||

|
||||
|
||||
**Start LangBot**.
|
||||
|
||||
## Add Bot
|
||||
|
||||
This article uses DingTalk Windows desktop version as an example, click `Search` at the top, `Features`, then enter the name of the bot you just created, as shown:
|
||||

|
||||
|
||||
Click on the bot to chat with it.
|
||||
|
||||
If you want to add it to a group, click `Group Management`, `Robots`, `Add Robot` in the DingTalk group, then search for the bot name to use it in the group.
|
||||
@@ -0,0 +1,55 @@
|
||||
# Connect to Discord Bot
|
||||
|
||||
## Create Bot
|
||||
|
||||
Go to the [Discord Developer Portal](https://discord.com/developers/applications), log in, and create an application.
|
||||
|
||||

|
||||
|
||||
Modify the basic information, click `Save Changes` to save.
|
||||
|
||||

|
||||
|
||||
Click `Bot` on the left, click `Reset Token`, copy the generated Token.
|
||||
|
||||

|
||||
|
||||
And check all options in `Privileged Gateway Intents` on this page, click `Save Changes` to save.
|
||||
|
||||

|
||||
|
||||
**Finally, click `OAuth2` on the left, copy the `Client ID` on the page.**
|
||||
|
||||
## Connect to LangBot
|
||||
|
||||
Click to add a new bot, fill in the `Client ID` and `Token` obtained in the previous step into the configuration.
|
||||
|
||||

|
||||
|
||||
:::warning
|
||||
|
||||
If you are using this adapter within mainland China, you may need to set up a network proxy.
|
||||
|
||||
:::
|
||||
|
||||
After filling in, start LangBot. If configured successfully, the log will show `[02-02 16:48:15.263] manager.py (68) - [INFO] : Initializing platform adapter 1: discord`, keep LangBot running.
|
||||
|
||||
## Invite Bot to Server
|
||||
|
||||
You need to create a server first, then invite the bot to the server.
|
||||
|
||||
Go to the `OAuth2` page, select `URL Generator`, select `bot`, check the permissions as shown in the image.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Click `Copy`, paste the generated URL into your browser to open it, and invite the bot to your server.
|
||||
|
||||

|
||||
|
||||
## Use Bot
|
||||
|
||||
Now you can use the bot normally in groups or private messages.
|
||||
|
||||

|
||||
@@ -0,0 +1,76 @@
|
||||
# Connect to Feishu Bot
|
||||
|
||||
## Create Bot
|
||||
|
||||
Go to the [Feishu Open Platform](https://open.feishu.cn/app), log in, and create an enterprise self-built application.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Add bot capability to the application:
|
||||

|
||||
|
||||
Add the permissions shown in the image in the permission management:
|
||||
|
||||

|
||||
|
||||
## Connect to LangBot
|
||||
|
||||
Find `app_id` and `app_secret` on the `Credentials and Basic Information` page.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
Open LangBot's Webui configuration page, create a new bot
|
||||
|
||||
Fill in the relevant information in the form
|
||||
|
||||

|
||||
|
||||
After filling in, start LangBot. If configured successfully, the log will show `[01-29 23:42:56.796] manager.py (68) - [INFO] : Initializing platform adapter 1: lark`, keep LangBot running.
|
||||
|
||||
:::warning
|
||||
By default, WebSocket long connection mode is used, corresponding to the long connection subscription below. But in some cases (such as international version of Feishu), long connection mode is not available, in which case you need to use Webhook mode, corresponding to the `Send events to developer server` mode, please refer to the following configuration:
|
||||
|
||||
- `enable-webhook`: Set to `true`
|
||||
- `encrypt-key`: Set to `Encrypt Key` in the `Encryption Strategy` of the `Events and Callbacks` page
|
||||
|
||||
Note that in Webhook mode, LangBot needs to be deployed on a server with a public IP, and ensure that the firewall has opened the port configured above.
|
||||
:::
|
||||
|
||||
## Configure Event Subscription
|
||||
|
||||
Go to the `Events and Callbacks` page, configure the subscription method as `Long Connection`:
|
||||
|
||||

|
||||
|
||||
And add the event: `Receive Messages`
|
||||
|
||||

|
||||
|
||||
:::warning
|
||||
Webhook mode configuration method:
|
||||
|
||||

|
||||
|
||||
Please start LangBot first, fill in your server address and port here, the path is `/lark/callback`, click `Save`.
|
||||
|
||||
:::
|
||||
|
||||
## Publish Bot
|
||||
|
||||
Click `Create Version` at the top, fill in the version number and other information, click `Save` below.
|
||||
|
||||

|
||||
|
||||
Add the bot to a Feishu group to use it:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Private chat can also be used directly
|
||||
|
||||

|
||||
@@ -0,0 +1,67 @@
|
||||
# Deploy Message Platform Lagrange
|
||||
|
||||
## Lagrange Introduction
|
||||
|
||||
Lagrange is a QQNT protocol reverse engineering framework that is lightweight and relatively stable. Connect through the OneBot 11 protocol, you need to select `OneBot v11` as the adapter.
|
||||
|
||||
::: warning
|
||||
You need to use NT QQ to interact with the bot, old versions of QQ will not work properly
|
||||
:::
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
The following only provides general steps for Windows, for detailed steps or other platforms, please refer to the [Lagrange official documentation](https://lagrangedev.github.io/Lagrange.Doc/Lagrange.OneBot/)
|
||||
|
||||
### Environment Configuration
|
||||
|
||||
Install .NET 8 runtime, [Click here to go directly to Microsoft's official website to download](https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-desktop-8.0.4-windows-x64-installer)
|
||||
|
||||
### Download the latest build from Github Actions
|
||||
|
||||
You need to log in to Github to download. If you don't need certain features, you can download from Release, see image 3
|
||||
|
||||
[Github Actions](https://github.com/KonataDev/Lagrange.Core/actions)
|
||||
|
||||
Follow the images to download:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Final Steps
|
||||
|
||||
Extract the zip you downloaded, navigate to the directory containing Lagrange.OneBot.exe, open a cmd command prompt in this directory, and enter
|
||||
|
||||
```bash
|
||||
.\Lagrange.OneBot
|
||||
```
|
||||
|
||||
Run it once, if a QR code is output, you can directly scan it with the bot account to log in (if the QR code is not clear, you can look for the image file in the lagrange data directory).
|
||||
|
||||
If you cannot log in, please check if you have correctly filled in the signature address SignServerUrl in the lagrange configuration file appsettings.json. Please look for the signature address in the lagrange documentation.
|
||||
|
||||
## Modify Configuration
|
||||
|
||||
You need to configure Lagrange to connect to LangBot. Please edit Lagrange's configuration file appsettings.json and ensure that the connection configuration in Implementations matches the content in the image below:
|
||||
|
||||

|
||||
|
||||
The Type must be `ReverseWebSocket`;
|
||||
Host is the IP of the host running LangBot, if on the same host, you can write `127.0.0.1`;
|
||||
Suffix must be `/ws`;
|
||||
|
||||
## Lagrange Integration
|
||||
|
||||
Next, open the LangBot configuration page
|
||||
|
||||
Click on Bots, then click Add
|
||||
|
||||
Select `OneBot v11` for `Platform/Adapter Selection`
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
Note, if you have network connection issues involving multiple docker containers, please refer to [Network Configuration Details](/en/workshop/network-details)
|
||||
:::
|
||||
@@ -0,0 +1,27 @@
|
||||
# Deploy Message Platform LiteLoaderQQNT
|
||||
|
||||
Connect through the OneBot 11 protocol, you need to select ``OneBot v11`` as the adapter.
|
||||
|
||||
# LiteLoaderQQNT
|
||||
|
||||
- [LiteLoaderQQNT's OneBot API plugin](https://github.com/LLOneBot/LLOneBot) injects into the QQ client and converts it to the OneBot 11 protocol
|
||||
|
||||
Installation tutorial for LiteLoaderQQNT: https://llonebot.github.io/zh-CN/guide/getting-started
|
||||
|
||||

|
||||
|
||||
Make sure the IP address in the address is the address of the host running LangBot (if running on the same network, use 127.0.0.1)
|
||||
|
||||
## Lagrange Integration
|
||||
|
||||
Next, open the LangBot configuration page
|
||||
|
||||
Click on Bots, then click Add
|
||||
|
||||
Select `OneBot v11` for `Platform/Adapter Selection`
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
Note, if you have network connection issues involving multiple docker containers, please refer to [Network Configuration Details](/en/workshop/network-details)
|
||||
:::
|
||||
@@ -0,0 +1,33 @@
|
||||
# Deploy Message Platform NapCat
|
||||
|
||||
Connect through the OneBot 11 protocol, you need to select ``OneBot v11`` as the adapter.
|
||||
|
||||
## NapCat Installation Tutorial
|
||||
|
||||
Follow the [NapCat official documentation for installation](https://napcat.napneko.icu/guide/start-install)
|
||||
|
||||
## NapCat Configuration Tutorial
|
||||
|
||||
Only using webui operation as an example, for other configuration methods, please check the NapCat documentation.
|
||||
|
||||
After logging in, you can check the logs in the console or Bash, find `[NapCat] [WebUi] WebUi Publish Panel Url: http://x.x.x.x:6099/webui?token=xxxxx `
|
||||

|
||||
|
||||
Copy the Url to your browser or on Windows 11, press Ctrl and click the Url. After scanning the QR code to log in, you will enter the network configuration page.
|
||||
|
||||
Click Add Network Configuration, select WebSocket Client, click Enable, then fill in `ws://127.0.0.1:2280/ws` in the Url field and save.
|
||||

|
||||
|
||||
## NapCat Integration
|
||||
|
||||
Next, open the LangBot configuration page
|
||||
|
||||
Click on Bots, then click Add
|
||||
|
||||
Select `OneBot v11` for `Platform/Adapter Selection`
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
Note, if you have network connection issues involving multiple docker containers, please refer to [Network Configuration Details](/en/workshop/network-details)
|
||||
:::
|
||||
@@ -0,0 +1,107 @@
|
||||
# Using QQ Official Bot API (Using webhook method)
|
||||
|
||||
This article only provides the deployment of test bots. For the official launch of bots, please follow the [release process](https://q.qq.com/qqbot/#/home).
|
||||
|
||||
## Register QQ Bot (Test Bot)
|
||||
|
||||
### Configure Basic Bot Information
|
||||
|
||||
Go to the [QQ Open Platform](https://q.qq.com/#/), find `Application Management` at the bottom, click Create Bot, fill in the basic information, and then enter the bot page, as shown:
|
||||
|
||||

|
||||
|
||||
The `Release Process` in the `Home` option is the step to launch the bot. Since you are deploying a test version bot, you only need to complete the `Information` and `Sandbox Configuration` sections.<br>
|
||||
|
||||
First fill in the information, then click on Sandbox Configuration.
|
||||
|
||||
#### Configure Sandbox Settings
|
||||
|
||||
Click on `Sandbox Configuration`.
|
||||
If you want to deploy in a QQ group, follow the requirements under `QQ Group ID` to select a group chat, and add users with private chat permissions in the message list configuration.<br>
|
||||
If you want to deploy in a QQ channel, follow the requirements under `Channel ID` to select a channel ID, with bot type 0.
|
||||
|
||||
#### Configure Development Management
|
||||
|
||||
Click on `Development Management`.
|
||||
|
||||

|
||||
|
||||
Record the `AppID`, `Token`, and `AppSecret`, and add the IP address of the server where LangBot is located to the IP whitelist.
|
||||
|
||||
## Connect to LangBot
|
||||
|
||||
Next, open the LangBot configuration page
|
||||
|
||||
Click on Bots, then click Add
|
||||
|
||||
Select `OneBot v11` for `Platform/Adapter Selection`
|
||||
|
||||

|
||||
|
||||
|
||||
## Configure Callback Address
|
||||
|
||||
Since QQ official bots require the callback address to be an https request, but LangBot only provides http, you need to configure a reverse proxy yourself.
|
||||
|
||||
This article recommends using [Caddy](https://caddy2.dengxiaolong.com/docs/) for reverse proxy, with the process as follows.
|
||||
|
||||
### Caddy Operation Process
|
||||
|
||||
#### Install Caddy
|
||||
|
||||
Go to the [Caddy Installation Documentation](https://caddy2.dengxiaolong.com/docs/install). Choose the installation steps for your operating system and install.
|
||||
|
||||
#### Fill in Caddyfile
|
||||
|
||||
This article assumes that LangBot is deployed on an Ubuntu system, where the default location of Caddyfile is `/etc/caddy/Caddyfile`.
|
||||
Use vim or nano to edit Caddyfile, and fill in the Caddyfile as:
|
||||
```json
|
||||
your_domain_name {
|
||||
reverse_proxy 127.0.0.1:2284
|
||||
}
|
||||
```
|
||||
For example, if you have a domain testlb.com that resolves to your machine, and you have port **443** open, fill in:
|
||||
```json
|
||||
testlb.com {
|
||||
reverse_proxy 127.0.0.1:2284
|
||||
}
|
||||
```
|
||||
|
||||
Save and exit the file.
|
||||
|
||||
**Note, the Caddyfile format is very strict, please fill it in correctly. If you encounter problems, please refer to the Caddy documentation or ask AI.**
|
||||
|
||||
#### Start Caddy
|
||||
Enter the command
|
||||
```bash
|
||||
sudo systemctl start caddy
|
||||
```
|
||||
|
||||
After successful startup, check the Caddy status with:
|
||||
```bash
|
||||
sudo systemctl status caddy
|
||||
```
|
||||
|
||||
|
||||
#### Subsequent Configuration
|
||||
|
||||
If Caddy fails to start, please read the [Caddy documentation](https://caddy2.dengxiaolong.com/docs/quick-starts/caddyfile) or join the LangBot community group for help.<br>
|
||||
|
||||
Here are some possible issues:
|
||||
|
||||
- Port 443 is not open
|
||||
- The domain is not resolved to your machine
|
||||
- Caddyfile was not saved successfully
|
||||
|
||||
### Set Management Portal Callback Address
|
||||
|
||||
|
||||
First **start LangBot**.
|
||||
|
||||
Click on `Callback Configuration` in the bot management portal, check all events under `Add Event`. In the request address, enter the domain set in Caddyfile, with the suffix `/callback/command`.
|
||||
|
||||
For example, if the domain is `testlb.com`, then enter `testlb.com/callback/command` in the request address, and click to confirm the configuration. If the callback address is saved successfully, it means the deployment is successful. If you see `Verification Failed`, please carefully check if the above configuration items are filled in correctly.
|
||||
|
||||
## Publication Method
|
||||
|
||||
Enter the release process in `Home` and follow the process to publish and launch the bot.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Configure Bots (Bots)
|
||||
|
||||
Bots are used to receive message events from messaging platforms and call pipelines to process messages.
|
||||
|
||||

|
||||
|
||||
|
||||
| Platform | Status | Notes | Tutorial |
|
||||
| ------ | ---- | ---- | ---- |
|
||||
| Discord | ✅ | | [Tutorial](/en/deploy/platforms/discord) |
|
||||
| Telegram | ✅ | | [Tutorial](/en/deploy/platforms/telegram) |
|
||||
| Slack | ✅ | | [Tutorial](/en/deploy/platforms/slack) |
|
||||
| Lark | ✅ | | [Tutorial](/en/deploy/platforms/lark) |
|
||||
| DingTalk | ✅ | | [Tutorial](/en/deploy/platforms/dingtalk) |
|
||||
| WeCom (Enterprise WeChat) | ✅ | Enterprise internal bot | [Tutorial](/en/deploy/platforms/wecom/wecom) |
|
||||
| WeCom Customer Service | ✅ | Enterprise external bot | [Tutorial](/en/deploy/platforms/wecom/wecomcs) |
|
||||
| WeChat Official Account | ✅ | WeChat public platform bot | [Tutorial](/en/deploy/platforms/wxoa) |
|
||||
| Personal WeChat | ✅ | Personal WeChat bot | [Gewechat](/en/deploy/platforms/wechat/gewechat) |
|
||||
| OneBot v11 | ✅ | Uses a personal QQ account as a bot, requires an independent protocol client, supports OneBot v11 | [NapCat](/en/deploy/platforms/qq/aiocqhttp/napcat) <br> [Lagrange](/en/deploy/platforms/qq/aiocqhttp/lagrange) <br> [LiteLoaderQQNT](/en/deploy/platforms/qq/aiocqhttp/llonebot) |
|
||||
| QQ Official Bot | ✅ | Connects to the QQ Open Platform bot API | [Tutorial](/en/deploy/platforms/qq/official_webhook) |
|
||||
@@ -0,0 +1,53 @@
|
||||
# Connect to Slack Bot
|
||||
|
||||
## Create Bot
|
||||
|
||||
Go to the [Slack App Platform](https://api.slack.com/apps).
|
||||
|
||||

|
||||
|
||||
Click `Create New App` in the top right corner, select `from a manifest`, select the workspace where you want to deploy the bot, select next, and choose to create the bot.
|
||||
|
||||
Enter the `Basic Information` option on the left, record the `signing_secret`.
|
||||
|
||||
Enter `OAuth & Permissions` on the left, scroll down to `Scopes`, add the following bot permissions:
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
After adding the above permissions, click `Install to your workspace`, record the token starting with `xoxb-xxxxx`.<br>
|
||||
|
||||
**Note:**
|
||||
**If you didn't add all permissions at once, you'll need to reinstall the App later.**<br>
|
||||
|
||||
Enter the `App Home` tab on the left, scroll to the bottom where you'll find `Message Tab`, turn it on and check
|
||||
`Allow users to send Slash commands and messages from the messages tab`.
|
||||
|
||||
## Connect to LangBot
|
||||
|
||||
Enter `Event Subscriptions` on the left, turn on the switch, click `Subscribe to bot events`,
|
||||
add the following permissions:
|
||||

|
||||
|
||||
After completing all the above operations, open the LangBot Webui configuration page, add a new bot
|
||||
|
||||

|
||||
|
||||
## Start Bot
|
||||
|
||||
After filling in the Slack configuration items, **start LangBot**.
|
||||
Then in the `Request URL` of the Event Subscriptions you just configured, fill in the deployment address of your LangBot.
|
||||
|
||||
::: info
|
||||
Since Slack officially requires https, you can refer to the [Caddy configuration part in the QQ official bot deployment process](/en/deploy/platforms/qq/official_webhook.md#caddy-operation-process), note that the port uses the port configured in the Slack adapter.
|
||||
|
||||
:::
|
||||
|
||||
After filling in all the above configuration items, click save link. If it shows a green **Verified**, it means the deployment is successful.
|
||||
Otherwise, check if the above configuration items are filled in correctly.
|
||||
|
||||
## Effect Demonstration
|
||||
|
||||

|
||||
@@ -0,0 +1,29 @@
|
||||
# Connect to Telegram Bot
|
||||
|
||||
## Create Bot
|
||||
|
||||
Go to the [Telegram Bot Creation Page](https://t.me/botfather), follow the prompts, and create a bot.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
After creation, BotFather will return an API Token, please keep it safe. Next, turn off `Privacy Mode` to use it in group chats.
|
||||
|
||||

|
||||
|
||||
## Connect to LangBot
|
||||
|
||||
Open the LangBot Webui page, create a new bot
|
||||
|
||||

|
||||
|
||||
After filling in, start LangBot. If configured successfully, the log will show `[02-02 16:48:15.263] manager.py (68) - [INFO] : Initializing platform adapter 1: telegram`, keep LangBot running.
|
||||
|
||||
## Use Bot
|
||||
|
||||
Now you can use the bot normally in groups or private messages.
|
||||
|
||||

|
||||
|
||||

|
||||
@@ -0,0 +1,97 @@
|
||||
# Connect to Personal WeChat via Gewechat
|
||||
|
||||
:::warning
|
||||
The Gewechat project has stopped maintenance, please do not use it.
|
||||
:::
|
||||
|
||||
**This tutorial requires LangBot to be deployed as a Docker container**, please deploy LangBot to Docker according to the LangBot deployment documentation.
|
||||
|
||||
:::info
|
||||
- It is recommended to deploy on Ubuntu Linux system.
|
||||
- Recommended to use [Alibaba Cloud, server prices as low as 38 yuan per year, with an additional 20% discount](https://www.aliyun.com/minisite/goods?userCode=ys4ad8gs), choose Ubuntu 22.04 or 24.04 as the system.
|
||||
:::
|
||||
|
||||
## Create Docker Network
|
||||
|
||||
We need to deploy Gewechat and LangBot to the same Docker network to facilitate their communication.
|
||||
|
||||
```bash
|
||||
docker network create langbot-network
|
||||
```
|
||||
|
||||
Add network configuration to the `docker-compose.yaml` file in the LangBot directory (add to the `services.langbot` field, and add the `langbot-network` network configuration under the `networks` field):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
langbot:
|
||||
...
|
||||
networks:
|
||||
- langbot-network
|
||||
...
|
||||
|
||||
networks:
|
||||
langbot-network:
|
||||
external: true
|
||||
```
|
||||
|
||||
In the next step when deploying Gewechat, please add an additional network configuration `--network langbot-network` after `-itd` in the startup command (docker run command).
|
||||
|
||||
```bash
|
||||
# For example, the original command is
|
||||
docker run -itd -v /root/temp:/root/temp -p 2531:2531 -p 2532:2532 --privileged=true --name=gewe gewe /usr/sbin/init
|
||||
|
||||
# After adding network configuration, the command becomes
|
||||
docker run -itd --network langbot-network -v /root/temp:/root/temp -p 2531:2531 -p 2532:2532 --privileged=true --name=gewe gewe /usr/sbin/init
|
||||
```
|
||||
|
||||
## Deploy Gewechat
|
||||
|
||||
Please check the [Gewechat documentation](https://github.com/Devo919/Gewechat) and execute up to the `Start Service` step.
|
||||
|
||||
## Fill in Information in LangBot and Start
|
||||
|
||||
```json
|
||||
{
|
||||
"adapter": "gewechat",
|
||||
"enable": true,
|
||||
"gewechat_url": "http://gewe:2531",
|
||||
"gewechat_file_url": "http://gewe:2532",
|
||||
"port": 2286,
|
||||
"callback_url": "http://langbot:2286/gewechat/callback",
|
||||
"app_id": "",
|
||||
"token": ""
|
||||
}
|
||||
```
|
||||
|
||||
- `enable` Whether to enable the personal WeChat adapter, please modify to `true`
|
||||
- `gewechat_url` The Gewechat container address deployed in the previous step, the default port is 2531, no need to fill in the path
|
||||
- `gewechat_file_url` Gewechat file download address, the default port is 2532, the host is the same as `gewechat_url`, no need to fill in the path
|
||||
- `port` The port for LangBot to listen for Gewechat messages, default is 2286, do not modify unless necessary
|
||||
- `callback_url` The callback address, which is the address for the Gewechat container to push messages to the LangBot container, needs to be filled with the complete path, for example `http://langbot:2286/gewechat/callback`, the port is consistent with `port`, the path must be `/gewechat/callback`
|
||||
- `app_id` and `token` **Do not fill in**, these are used to store login information and will be automatically saved after scanning the QR code to log in for the first time
|
||||
|
||||
:::info
|
||||
Here we set the hostname of `gewechat_url` to `gewe`, which is the name of the Gewechat container deployed in the previous step.
|
||||
Set the hostname of `callback_url` to `langbot`, which is the name of the LangBot container deployed in the previous step.
|
||||
|
||||
- If you deploy according to the requirements of this tutorial, you can use the above defaults.
|
||||
- If you used other container names, or other situations, please change accordingly.
|
||||
:::
|
||||
|
||||
## Start LangBot
|
||||
|
||||
Start LangBot according to the startup command in the LangBot deployment documentation.
|
||||
|
||||
After LangBot starts, a QR code will be displayed, please scan this QR code with your personal WeChat to log in.
|
||||
|
||||

|
||||
|
||||
After successful login, login information will be displayed, and it will start listening for personal WeChat messages.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
After logging in, `app_id` and `token` will be saved to the configuration file, and you won't need to scan the QR code to log in again the next time you start.
|
||||
:::
|
||||
|
||||
Now you can chat with LangBot in private messages or group chats.
|
||||
@@ -0,0 +1,64 @@
|
||||
# Deploy WeCom Bot
|
||||
|
||||
Deploy WeCom (Enterprise WeChat) bot to connect with LangBot.
|
||||
|
||||
:::info
|
||||
This integration method is for internal enterprise applications, used within the enterprise. If you need external customer service, please check the [WeCom Customer Service integration solution](wecomcs.md).
|
||||
:::
|
||||
|
||||
|
||||
## Create Bot
|
||||
|
||||
Enter the [WeCom Admin Portal](https://work.weixin.qq.com/), log in to your account, after entering the main page, click `App Management`, `Build Your Own`, `Create App`, fill in the basic information of the bot, after creation, you will see a page similar to this:
|
||||

|
||||
|
||||
## Set Callback Address
|
||||
|
||||
### Get WeCom Configuration Items
|
||||
|
||||
1. Open the WeCom Admin Portal homepage, click `My Enterprise`, and record the Enterprise ID at the bottom.
|
||||
|
||||

|
||||
|
||||
2. Enable Contact Sync Permission
|
||||
|
||||
:::info
|
||||
- This configuration item is for implementing LangBot's mass messaging feature, the specific code is located in libs/wecom_api/api.py.
|
||||
- LangBot is still under development, so the functionality related to this configuration item has not been implemented yet.
|
||||
- This configuration item can be filled with random characters, but **cannot be empty**.
|
||||
:::
|
||||
|
||||

|
||||
|
||||
Click `Security and Management`, `Management Tools`, `Contact Sync`
|
||||
|
||||

|
||||
|
||||
Click `View Secret`, record it, this is the contacts_secret (Contact Sync Secret).
|
||||
|
||||
3. Click `App Management`, find the bot you just created, view the bot's secret, and record it.
|
||||
|
||||

|
||||
|
||||
At this point, you have obtained three configuration items: corpid (Enterprise ID), secret (Bot Secret), and contacts_secret (Contact Sync Secret).
|
||||
|
||||
### Configure Callback Address
|
||||
|
||||
Enter the bot page.
|
||||
|
||||
Click `Enterprise Trusted IP` at the bottom and add the server where LangBot is deployed.
|
||||
|
||||
Click `Receive Messages`, `Set API Reception`, and start filling in the server message reception configuration.
|
||||
|
||||
Fill in the URL as `http://your_ip_address:2290/callback/command`, where your IP address is the address of the server where LangBot is deployed.
|
||||
|
||||
Click to randomly generate the Token and EncodingAESKey, and record them
|
||||
|
||||
## Connect to LangBot
|
||||
|
||||

|
||||
|
||||
## Save Callback Address
|
||||
When the five configuration items above have been correctly obtained and accurately filled into the WeCom adapter, then **start LangBot**.
|
||||
|
||||
Return to the callback address configuration page and click save. If the above configuration items are filled in correctly, the save will be successful, which means that WeCom and LangBot can communicate (deployment successful). If you see **openapi request callback address failed**, please triple-check that your configuration items are filled in correctly.
|
||||
@@ -0,0 +1,25 @@
|
||||
# Deploy WeCom Customer Service
|
||||
|
||||
:::info
|
||||
|
||||
This article details the process of deploying LangBot to a WeCom customer service account, which allows conversations between the customer service account and regular WeChat. If you only need to use it within WeCom, please refer to [WeCom Internal Application Implementation](wecom.md).
|
||||
|
||||
**Deploying a WeCom customer service account requires enterprise qualifications**. Please check the [WeCom Customer Service Integration Guide](https://developer.work.weixin.qq.com/document/path/94638) and provide the corresponding enterprise qualification certificates according to this document.
|
||||
|
||||
:::
|
||||
|
||||
## Effect Demonstration
|
||||
|
||||

|
||||
|
||||
## Connect to LangBot
|
||||
|
||||

|
||||
|
||||
The subsequent configuration method and configuration items are the same as [WeCom Internal Application](wecom.md), except that `contacts_secret` is not required.
|
||||
|
||||
## Notes
|
||||
|
||||
1. Be sure to follow the steps in the official WeCom documentation above and add the customer service account to `API Management`.
|
||||
2. The steps are the same as for WeCom internal applications, don't miss anything. You also need to save the callback address, because essentially it's just adding other permissions to the WeCom internal application.
|
||||
3. LangBot will not read sensitive information such as chat records and enterprise qualification content.
|
||||
@@ -0,0 +1,55 @@
|
||||
# Deploy WeChat Official Account Bot
|
||||
|
||||
Deploy WeChat Official Account bot to connect with LangBot.
|
||||
|
||||
## LangBot WeChat Official Account Integration Modes
|
||||
|
||||
Currently, LangBot provides two ways to integrate with WeChat Official Accounts:
|
||||
|
||||
1. **Traditional Message Exchange Mode**
|
||||
- Official accounts require requests to be processed within **15 seconds**, AI-generated content that exceeds this timeout cannot be sent.
|
||||
- When AI content generation timeout occurs, LangBot will print request timeout information in the console.
|
||||
|
||||
2. **"Send Any Text to Get Reply" Mode**
|
||||
- This method can break the **15 second** limit, but **very long text** may not be sent successfully.
|
||||
- When using this method, after sending a message to the official account, it will reply "AI is thinking, please send any content to get the answer". At this point, you need to send any content to get the answer.
|
||||
|
||||
For more complex functionality, please contact the **LangBot team** for customized support.
|
||||
|
||||
## Create Bot
|
||||
|
||||
Enter the [WeChat Official Account Platform](https://mp.weixin.qq.com/), if you already have an official account, scan the QR code to log in and enter the console.
|
||||
If you haven't registered an official account before, click Register Now, select `Official Account`, fill in the information in sequence, and enter the console. The console looks like this:
|
||||

|
||||
|
||||
|
||||
## Set Callback Address
|
||||
|
||||
### Get Configuration Items
|
||||
|
||||
Click `Settings and Development`, `Development Interface Management`, and you'll see a page like this:
|
||||

|
||||
|
||||
Record the `Developer ID (AppID)`, `Developer Password (AppSecret)`, and add the server where LangBot is deployed to the `IP Whitelist`.
|
||||
|
||||
### Set Up Reverse Proxy
|
||||
|
||||
Since WeChat Official Accounts only support http (port 80) and https (port 443), this article assumes that port 80 is already occupied and uses port 443 to reverse proxy to LangBot.
|
||||
|
||||
The specific reverse proxy configuration tutorial is the same as the [QQ Official Bot Reverse Proxy Configuration](/en/deploy/platforms/qq/official_webhook.md#caddy-operation-process), except that `reverse_proxy 127.0.0.1:2284` is changed to `reverse_proxy 127.0.0.1:2287`.
|
||||
|
||||
### Save Callback Address
|
||||
|
||||
Click Set Server Configuration, enter `Token`, `EncodingAESKey`, and change the message encryption/decryption method to `Safe Mode`.
|
||||
|
||||
At this point, open the LangBot Webui page, create a new bot, and fill in the four configuration items obtained (AppID, AppSecret, token, EncodingAESKey)
|
||||
|
||||

|
||||
|
||||
In the configuration items, the `Mode` option is the selected integration mode, where the default is `drop`. `drop` is the traditional message exchange mode, and `passive` is the "send any text to get reply" mode.
|
||||
|
||||
The `LoadingMessage` option is the loading message, which can be changed to other content, and is only valid when the mode is `passive`. Set `enable` to `true`.
|
||||
|
||||
After filling in successfully, **start LangBot**.
|
||||
|
||||
Fill in the URL as `https://your_domain_name/callback/command`, where `your_domain_name` is the domain name filled in Caddy. Click Save. If it can be saved successfully, it means the deployment is successful. If you see **System error, please try again later**, please recheck whether the above configuration content is filled in correctly.
|
||||
@@ -0,0 +1,97 @@
|
||||
# System Environment Settings
|
||||
|
||||
Configure some environment information for system operation, located in the `data/config.yaml` file.
|
||||
Generally, no modification is needed.
|
||||
|
||||
```yaml
|
||||
# Administrator session list, only valid when processing commands
|
||||
# Format is session ID (person_xxxx or group_xxxx)
|
||||
# Session ID can be found in the console logs when sending messages
|
||||
# For example:
|
||||
# admins:
|
||||
# - person_1234567890
|
||||
# - group_1234567890
|
||||
admins: []
|
||||
|
||||
# API port
|
||||
api:
|
||||
port: 5300
|
||||
|
||||
# Command configuration
|
||||
command:
|
||||
# Command prefixes, messages with these prefixes will be recognized as commands
|
||||
prefix:
|
||||
- '!'
|
||||
- !
|
||||
|
||||
# Command permission configuration, key is the command prefix, value is the permission type
|
||||
privilege: {}
|
||||
|
||||
# Concurrency settings
|
||||
concurrency:
|
||||
# Single pipeline concurrency
|
||||
pipeline: 20
|
||||
# Single session concurrency
|
||||
session: 1
|
||||
|
||||
# MCP configuration
|
||||
# Should be configurable in WebUI in the future
|
||||
mcp:
|
||||
# MCP server list
|
||||
# Currently supports two protocol MCP servers:
|
||||
# - SSE
|
||||
# - Stdio (Python)
|
||||
#
|
||||
# Format:
|
||||
# SSE mode:
|
||||
# name Server name, self-defined
|
||||
# enable Whether to enable this Server
|
||||
# mode Fixed as SSE
|
||||
# url MCP SSE Server access URL
|
||||
# headers Connection headers, optional
|
||||
# timeout Connection timeout
|
||||
#
|
||||
# stdio mode:
|
||||
# name Server name, self-defined
|
||||
# enable Whether to enable this Server
|
||||
# mode Fixed as stdio
|
||||
# command Execution command
|
||||
# args Command parameters
|
||||
# env Command environment variables, optional
|
||||
#
|
||||
# For example:
|
||||
# servers:
|
||||
# - name: 'SSE Server'
|
||||
# enable: true
|
||||
# mode: SSE
|
||||
# url: 'http://127.0.0.1:8000/sse'
|
||||
# headers: {}
|
||||
# timeout: 10
|
||||
# - name: 'stdio Server'
|
||||
# enable: true
|
||||
# mode: stdio
|
||||
# command: 'python'
|
||||
# args: ['-m', 'weather']
|
||||
# env: {}
|
||||
servers: []
|
||||
|
||||
# Proxy configuration
|
||||
proxy:
|
||||
# HTTP proxy address
|
||||
# If proxy is already set in environment variables, no configuration is needed
|
||||
# For example:
|
||||
# proxy:
|
||||
# http: 'http://127.0.0.1:7890'
|
||||
# https: 'http://127.0.0.1:7890'
|
||||
http: ''
|
||||
https: ''
|
||||
|
||||
# System configuration
|
||||
system:
|
||||
# JWT configuration
|
||||
jwt:
|
||||
# JWT expiration time in seconds
|
||||
expire: 604800
|
||||
# JWT secret key, a key will be automatically generated on first startup
|
||||
secret: 'xxxx'
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
# Update LangBot
|
||||
|
||||
## Using Docker (or one-click deployment based on Docker)
|
||||
|
||||
Please execute in the `docker-compose.yaml` directory:
|
||||
|
||||
```bash
|
||||
docker compose up --force-recreate --pull always -d
|
||||
```
|
||||
|
||||
This command will pull the latest LangBot image and rebuild the container.
|
||||
|
||||
## Manual Deployment
|
||||
|
||||
Download the latest release's `langbot-<version>-all.zip` from the Assets section on the [Releases](https://github.com/RockChinQ/LangBot/releases) page, extract it to the original deployment directory, and restart.
|
||||
@@ -0,0 +1,3 @@
|
||||
# Component Architecture
|
||||
|
||||

|
||||
@@ -0,0 +1,41 @@
|
||||
# Development Configuration
|
||||
|
||||
> This document is based on LangBot version 4.0
|
||||
|
||||
LangBot is divided into frontend and backend. The frontend is developed using Next.js + shadcn, and the backend is developed using Quart (an asynchronous version of Flask).
|
||||
|
||||
## Backend
|
||||
|
||||
The code is located in the `pkg` directory and is started by the `main.py` file in the root directory.
|
||||
|
||||
Install dependencies
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Start the backend
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
At this point, the configuration file will be automatically generated in the `data/config.yaml` file.
|
||||
|
||||
## Frontend
|
||||
|
||||
The code is located in the `web` directory and requires Node.js.
|
||||
|
||||
Install dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Go to the `web/src/app/infra/http/HttpClient.ts` file and change `export const httpClient = new HttpClient('/');` at the bottom to `export const httpClient = new HttpClient('http://localhost:5300');` to ensure the frontend can access the standalone backend.
|
||||
|
||||
Start debugging
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
<script setup>
|
||||
window.location.href = '/zh/insight/guide'
|
||||
</script>
|
||||
@@ -0,0 +1,11 @@
|
||||
# Community Resources
|
||||
|
||||
|
||||
## Simplified Tutorials
|
||||
> Simplified tutorials: such as video tutorials, simpler text tutorials, suitable for beginners
|
||||
|
||||
Collected at: https://blog.thelazy.top/tags/langbot
|
||||
|
||||
## 🥰 Community
|
||||
|
||||
Join our community on Discord: [](https://discord.gg/wdNEHETs87)
|
||||
@@ -0,0 +1,46 @@
|
||||
# Welcome to LangBot Documentation
|
||||
|
||||
LangBot is an open-source Large Language Model (LLM) native instant messaging bot platform that supports multiple messaging platforms and model providers. It provides support for LLMOps platforms such as Dify. It also offers a WebUI for users to quickly deploy and use.
|
||||
|
||||
## Documentation Structure
|
||||
|
||||
The documentation is divided into the following sections:
|
||||
|
||||
- Deployment and Usage (Must Read): Detailed steps for deploying and using LangBot
|
||||
- Plugins: Information related to plugin usage and development
|
||||
- Practice: Many excellent use cases for LangBot
|
||||
- Development: Information related to participating in LangBot development
|
||||
|
||||
## Usage Examples
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
## Quick Start Guide
|
||||
|
||||
> Two ways to get started quickly:
|
||||
>
|
||||
> - Use the simplified tutorial from community resources (see left sidebar)
|
||||
> - Read the documentation to deploy it yourself (method described below)
|
||||
|
||||
### 1. Deploy LangBot
|
||||
|
||||
Read the **Deploy LangBot** section on the left and choose a method to deploy LangBot
|
||||
|
||||
After deployment, open `http://127.0.0.1:5300` or `http://your-server-public-ip:5300`
|
||||
|
||||
Complete the initialization by entering an email and password, and make sure to save them
|
||||
|
||||
### 2. Configure Bots
|
||||
|
||||
Check [Configure Bots](/en/deploy/platforms/readme) in the left sidebar
|
||||
|
||||
### 3. Configure Models
|
||||
|
||||
Check [Configure Dialogue Models](/en/deploy/models/readme) in the left sidebar
|
||||
|
||||
<br>
|
||||
|
||||
After completing the above two steps, you can start using LangBot. If you need to configure more features, you can set them in the [Pipeline](/en/deploy/pipelines/readme) section
|
||||
@@ -0,0 +1,164 @@
|
||||
# API Reference
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## Event API
|
||||
|
||||
The following APIs are only available in event handler functions.
|
||||
|
||||
### Reply to Message
|
||||
|
||||
```python
|
||||
await ctx.reply(message_chain: MessageChain)
|
||||
```
|
||||
|
||||
Reply to the conversation that initiated this event.
|
||||
|
||||
- `message_chain`: [Message Chain object](./messages.md), the program can automatically convert it to the target message platform's message chain
|
||||
|
||||
### Send Active Message
|
||||
|
||||
> Due to poor support for active messages in QQ Official API, if users are using QQ Official API, sending active messages may fail
|
||||
|
||||
```python
|
||||
await ctx.send_message(target_type: str, target_id: str, message_chain: MessageChain)
|
||||
```
|
||||
|
||||
Send an active message to the target.
|
||||
|
||||
- `target_type`: Target type, possible values: `"person"`, `"group"`
|
||||
- `target_id`: Target ID (QQ number or group number)
|
||||
- `message_chain`: [Message Chain object](./messages.md), the program can automatically convert it to the target message platform's message chain
|
||||
|
||||
### Prevent Default Event Behavior
|
||||
|
||||
```python
|
||||
ctx.prevent_default()
|
||||
```
|
||||
|
||||
Prevent the default behavior of this event, i.e., stop the subsequent behaviors in the processing flow (such as getting a reply from the interface when receiving a private chat message, getting a reply from the interface when receiving a group message, etc.).
|
||||
|
||||
### Prevent Subsequent Plugin Execution
|
||||
|
||||
```python
|
||||
ctx.prevent_postorder()
|
||||
```
|
||||
|
||||
Prevent the execution of subsequent plugins for this event. To modify the execution order of plugins, please change the priority through the methods described in the "Plugin Management" section of the "Plugin Introduction".
|
||||
|
||||
### Add Return Value
|
||||
|
||||
```python
|
||||
ctx.add_return(name: str, value: Any)
|
||||
```
|
||||
|
||||
Add a return value. Event return values are all **optional**. For return values supported by each event, please check the comments of each event in `pkg.plugin.events`.
|
||||
|
||||
## Request API
|
||||
|
||||
A `Request (Query)` refers to the program context when a user sends a question to LangBot and LangBot processes that question. The APIs in this section are used to interact with these contexts.
|
||||
|
||||
- In event handler functions, the Query object is usually located at `ctx.event.query`
|
||||
|
||||
### Set Request Variable
|
||||
|
||||
```python
|
||||
ctx.event.query.set_variable(key: str, value: typing.Any)
|
||||
```
|
||||
|
||||
Request variables are a `dict` bound to this Query, which contains some program context information. If you are using Dify or Alibaba Cloud Bailian or other LLMOps runners, [these variables will be passed to the corresponding platform's API as variables](/en/deploy/pipelines/readme.html#conversation-variables).
|
||||
If you need to set variables using plugins, it is recommended to handle them during the `PromptPreProcessing` event.
|
||||
|
||||
- `key`: The name of the variable
|
||||
- `value`: The value of the variable
|
||||
|
||||
### Get Request Variable
|
||||
|
||||
```python
|
||||
ctx.event.query.get_variable(key: str)
|
||||
```
|
||||
|
||||
Get a request variable.
|
||||
|
||||
- `key`: Variable name
|
||||
- Return value: `typing.Any`
|
||||
|
||||
### Get All Request Variables
|
||||
|
||||
```python
|
||||
ctx.event.query.get_variables()
|
||||
```
|
||||
|
||||
Get all variable values set for this Query object.
|
||||
|
||||
- Return value: `dict[str, typing.Any]`
|
||||
|
||||
|
||||
## LangBot API
|
||||
|
||||
The following APIs are provided directly by LangBot for plugins to call and can be called outside of event handler functions.
|
||||
|
||||
- `host` represents an object of the `pkg.plugin.context.APIHost` class, which is included in each plugin class.
|
||||
|
||||
### Get Enabled Message Platform Adapters List
|
||||
|
||||
```python
|
||||
host.get_platform_adapters()
|
||||
```
|
||||
|
||||
Get a list of enabled message platform adapters.
|
||||
|
||||
- Return value: `list[pkg.platform.adapter.MessageSourceAdapter]`
|
||||
|
||||
### Send Active Message
|
||||
|
||||
```python
|
||||
await host.send_active_message(adapter: pkg.platform.adapter.MessageSourceAdapter, target_type: str, target_id: str, message_chain: MessageChain)
|
||||
```
|
||||
|
||||
Send an active message to the target.
|
||||
|
||||
- `adapter`: Message platform adapter, obtained through `host.get_platform_adapters()` and selecting one of them
|
||||
- `target_type`: Target type, possible values: `"person"`, `"group"`
|
||||
- `target_id`: Target ID (QQ number or group number)
|
||||
- `message_chain`: [Message Chain object](./messages.md), the program can automatically convert it to the target message platform's message chain
|
||||
|
||||
:::info
|
||||
- Some message platforms may not support active messages or have strict limitations
|
||||
- Some message platform adapters (such as `aiocqhttp`) act as servers waiting for message platforms to connect and push messages. Before a successful connection, sending active messages will fail
|
||||
:::
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
import pkg.platform.types as platform_types
|
||||
|
||||
...
|
||||
|
||||
# initialize function of a plugin
|
||||
# This code will attempt to send a message "hello, world!" to QQ number 1010553892 10 seconds after LangBot starts
|
||||
async def initialize(self):
|
||||
print(self.host.get_platform_adapters())
|
||||
|
||||
async def send_message():
|
||||
print("send message start waiting")
|
||||
await asyncio.sleep(10)
|
||||
|
||||
try:
|
||||
await self.host.send_active_message(
|
||||
adapter=self.host.get_platform_adapters()[0],
|
||||
target_type="person",
|
||||
target_id="1010553892",
|
||||
message=platform_types.MessageChain([
|
||||
platform_types.Plain("hello, world!")
|
||||
])
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
print("send message end")
|
||||
|
||||
asyncio.get_running_loop().create_task(send_message())
|
||||
```
|
||||
@@ -0,0 +1,113 @@
|
||||
# Message Platform Entities
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
LangBot supports multiple messaging platforms, but the `message entity` format of each platform is different. To shield these differences, LangBot has a unified standard. Plugin developers only need to master and use the message entities described on this page in their plugins, and LangBot's internal message processing logic can automatically complete the parsing and conversion of messages.
|
||||
|
||||
:::info
|
||||
LangBot's message platform entities are modified based on the implementation of [YiriMirai](https://github.com/YiriMiraiProject/YiriMirai).
|
||||
:::
|
||||
|
||||
## Message Chain
|
||||
|
||||
The `message` of a message platform is different from the message used for AI interaction. The message of a message platform is described in the form of a `message chain`. Each independent message displayed on QQ is a message chain, which can contain multiple `message chain components` such as `text`, `image`, `@ component`, for example:
|
||||
|
||||

|
||||
|
||||
This is a message chain, containing one Plain component (Hello World) and one Image component (Usagi)
|
||||
|
||||
The definitions of message chain and message chain components are located in `pkg/platform/types/messages.py`.
|
||||
|
||||
### Constructing Message Chain
|
||||
|
||||
Please import the `pkg.platform.types` package first to use the message components.
|
||||
|
||||
```python
|
||||
from pkg.platform.types import *
|
||||
|
||||
# Build a message containing the text Hello LangBot and an image (from URL)
|
||||
msg_chain = MessageChain([
|
||||
Plain("Hello LangBot"),
|
||||
Image(url='https://qchatgpt.rockchin.top/langbot-logo.png')
|
||||
])
|
||||
|
||||
# Build a message containing @all and the text Hello LangBot
|
||||
msg_chain = MessageChain([
|
||||
AtAll(),
|
||||
Plain("Hello LangBot")
|
||||
])
|
||||
|
||||
# Build a message containing @specific member and the text Hello LangBot
|
||||
msg_chain = MessageChain([
|
||||
At(123456),
|
||||
Plain("Hello LangBot")
|
||||
])
|
||||
```
|
||||
|
||||
Currently supported message chain components:
|
||||
|
||||
- `Source` Source message chain information, if it is a message received from a message platform, this component will be included at the beginning of the message chain, recording message information
|
||||
- `Plain` Plain text message
|
||||
- `Quote` Quote message
|
||||
- `Image` Image message
|
||||
- `AtAll` @all members message
|
||||
- `At` @specific member message
|
||||
- `Voice` Voice message
|
||||
- Need to check message platform support
|
||||
- `Forward` Forward message
|
||||
- Not supported on many platforms, not recommended to use
|
||||
- `File` File message
|
||||
|
||||
For specific usage, please check the definitions in the source code `pkg/platform/types/messages.py`.
|
||||
|
||||
## Message Platform Events
|
||||
|
||||
These events are different from LangBot plugin events, they are an independent set of event systems for the message platform system. These events are the source events of LangBot messages, which can be obtained from each Query.message_event.
|
||||
|
||||
```python
|
||||
# For example in a plugin
|
||||
@handler(GroupMessageReceived)
|
||||
async def _(self, ctx: EventContext):
|
||||
# Get the message platform event
|
||||
message_event = ctx.query.message_event
|
||||
```
|
||||
|
||||
Message platform events are defined in `pkg/platform/types/events.py`.
|
||||
|
||||
## Other Entities
|
||||
|
||||
In addition to the above entities, there are also entities such as `Friend` and `Group`, which are defined in `pkg/platform/types/entities.py`.
|
||||
They are generally included in the above event objects, from which you can get some information not included in the plugin events.
|
||||
|
||||
## Accessing Message Platform Low-Level API
|
||||
|
||||
In order to smooth out the differences between various platforms, LangBot provides an abstraction layer on top of the message platform APIs, namely the content described above and the platform adapters in the `pkg/platform/sources` directory.
|
||||
However, due to the large differences between platforms, the entities and API encapsulation in the abstraction layer are not complete. If your plugin needs to access specific platform functions, you can access the low-level API according to the following instructions.
|
||||
|
||||
:::info
|
||||
The `adapter` here is the instantiated object of each adapter, corresponding to the `xxxAdapter(adapter.MessagePlatformAdapter)` class in each file under `pkg/platform/sources/`. It can be obtained from the plugin event's `query.adapter`, for example:
|
||||
|
||||
```python
|
||||
# For example in a plugin
|
||||
@handler(GroupMessageReceived)
|
||||
async def _(self, ctx: EventContext):
|
||||
# Get the adapter object
|
||||
adapter = ctx.query.adapter
|
||||
```
|
||||
:::
|
||||
|
||||
|
||||
| Platform | Adapter | Access Method | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| OneBot v11| aiocqhttp | adapter.bot | The bot object corresponds to the CQHttp object of [aiocqhttp](https://github.com/nonebot/aiocqhttp), please refer to the aiocqhttp documentation for detailed usage |
|
||||
| QQ Official API | qqofficial | adapter.bot | The bot object is the SDK object under libs/qq_official_api, for detailed usage, you can refer to the way of initiating HTTP requests in the `send_group_text_msg` method in `QQOfficialClient` in libs/qq_official_api/api.py, please check the QQ official API documentation for specific interface documentation|
|
||||
| Personal WeChat | gewechat | adapter.bot | The bot object is the GewechatClient object of [hanfangyuan4396/gewechat-client](https://github.com/hanfangyuan4396/gewechat-python), please refer to the documentation for detailed usage |
|
||||
| WeCom | wecom | adapter.bot | Refer to the way of initiating HTTP requests in the `send_image` method in `WecomClient` in libs/wecom_api/api.py, please check the WeCom API documentation for specific interface documentation |
|
||||
| WeChat Official Account | officialaccount | - | Please refer to the interface documentation information in the WeChat Official Account API documentation, the relevant credential information can be obtained from adapter.bot |
|
||||
| Feishu | lark | adapter.api_client | Feishu SDK's API Client object, please refer to [oapi-sdk-python](https://github.com/larksuite/oapi-sdk-python) |
|
||||
| DingTalk | dingtalk | - | Please refer to the DingTalk API documentation, the relevant credential information can be obtained from adapter.bot |
|
||||
| Discord | discord | adapter.bot | The bot object is the Discord object of [Rapptz/discord.py](https://github.com/Rapptz/discord.py), please refer to the documentation for detailed usage |
|
||||
| Telegram | telegram | adapter.bot | The bot object is the Telegram object of [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot), please refer to the documentation for detailed usage |
|
||||
| Slack | slack | adapter.bot | The bot object is the object in libs/slack_api/api.py, please refer to its code and Slack SDK for detailed usage |
|
||||
@@ -0,0 +1,308 @@
|
||||
# Plugin Development Tutorial
|
||||
|
||||
> Please read the [Plugin Introduction page](/en/plugin/plugin-intro) first
|
||||
> It is recommended to read the source code of this project first to understand the project architecture
|
||||
|
||||
> For questions and requirements, please open an issue in the repository
|
||||
> **Try to solve problems on your own before asking**
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## 💬 Introduction
|
||||
|
||||
This page explains the steps for developing a regular plugin. Plugins have two methods: event listeners and content functions.
|
||||
Event listeners can respond to certain events when triggered and change behavior. Content functions can be called by large language models, please check the plugin introduction page for details.
|
||||
|
||||
## 💻 Quick Start
|
||||
|
||||
Use [HelloPlugin](https://github.com/langbot-app/HelloPlugin) as a template to generate a plugin code repository, then clone the repository code to the `plugins` directory.
|
||||
|
||||
Modify the parts that need to be changed in the plugin's README.md file.
|
||||
|
||||
Edit `main.py` and enter the following content:
|
||||
|
||||
```Python
|
||||
from pkg.plugin.context import register, handler, llm_func, BasePlugin, APIHost, EventContext
|
||||
from pkg.plugin.events import * # Import event classes
|
||||
|
||||
|
||||
"""
|
||||
When receiving a private chat or group chat message "hello", reply with "hello, <sender id>!" or "hello, everyone!"
|
||||
"""
|
||||
|
||||
|
||||
class HelloPlugin(BasePlugin):
|
||||
|
||||
# Triggered when the plugin is loaded
|
||||
def __init__(self, host: APIHost):
|
||||
pass
|
||||
|
||||
# Asynchronous initialization
|
||||
async def initialize(self):
|
||||
pass
|
||||
|
||||
# Triggered when a personal message is received
|
||||
@handler(PersonNormalMessageReceived)
|
||||
async def person_normal_message_received(self, ctx: EventContext):
|
||||
msg = ctx.event.text_message # Here event is the PersonNormalMessageReceived object
|
||||
if msg == "hello": # If the message is hello
|
||||
|
||||
# Output debug information
|
||||
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
|
||||
|
||||
# Reply with message "hello, <sender id>!"
|
||||
ctx.add_return("reply", ["hello, {}!".format(ctx.event.sender_id)])
|
||||
|
||||
# Prevent the default behavior of this event (getting a reply from the API)
|
||||
ctx.prevent_default()
|
||||
|
||||
# Triggered when a group message is received
|
||||
@handler(GroupNormalMessageReceived)
|
||||
async def group_normal_message_received(self, ctx: EventContext):
|
||||
msg = ctx.event.text_message # Here event is the GroupNormalMessageReceived object
|
||||
if msg == "hello": # If the message is hello
|
||||
|
||||
# Output debug information
|
||||
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
|
||||
|
||||
# Reply with message "hello, everyone!"
|
||||
ctx.add_return("reply", ["hello, everyone!"])
|
||||
|
||||
# Prevent the default behavior of this event (getting a reply from the API)
|
||||
ctx.prevent_default()
|
||||
|
||||
# Triggered when the plugin is unloaded
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
```
|
||||
|
||||
:::info
|
||||
|
||||
Interpreting this plugin program
|
||||
|
||||
- `import pkg.plugin.context` imports `register (used to register plugin classes)`, `handler (used to register event listeners)`, `llm_func (used to register content functions)`, `BasePlugin (plugin base class)`, `APIHost (API host)`, `EventContext (event context class)` and other content
|
||||
- `import pkg.plugin.events` imports all supported event classes
|
||||
- Declare class `HelloPlugin` inheriting from `BasePlugin`, this class can be named arbitrarily, the plugin name is only related to the parameter when calling `register`
|
||||
- Declare the `__init__` method of this class, this method is optional, the code in it will be executed when the main program loads the plugin at startup
|
||||
- The plugin class also supports adding an asynchronous method `async def initialize(self)` for asynchronous initialization
|
||||
- `@handler` marks the method `person_normal_message_received` as an event listener, handling the `PersonNormalMessageReceived` (triggered when a private chat message is received and before getting an OpenAI reply) event, this method can be named arbitrarily, the bound event is only related to the parameter in `handler`, more supported events can be found in the `pkg.plugin.events` file or check the `API` section below
|
||||
- Output debug information through the `self.ap.logger` logger, the `ap` object in the plugin class parent class is the context object of the entire program, you can access all objects in the program through this object
|
||||
- The event listener method gets a second parameter `ctx` which is the context of this event, the `event` in it is the event object of this event, you can extract related parameters from it, for specific parameters that can be obtained from each event, please check the comments of each event class in the `pkg.plugin.events` file
|
||||
- The event listener method extracts the `text_message` parameter from the parameters, checks if it is `hello`, if so, sets the return value `reply` to `["hello, {}!".format(ctx.event.sender_id)]`, then calls the `ctx.prevent_default()` method to prevent the original program's default behavior
|
||||
- For return values supported by each event, please check the comments of each event in `pkg.plugin.events`
|
||||
- Register the `GroupNormalMessageReceived` event with similar code to handle group messages
|
||||
|
||||
After writing and saving, restart the main program, go to the WebUI plugin page to see the plugin
|
||||
:::
|
||||
|
||||
This plugin will implement: replying with `hello, <sender QQ number>!` when receiving a `hello` message in private chat, and replying with `hello, everyone!` when receiving a `hello` message in group chat.
|
||||
|
||||
### Writing the Manifest File
|
||||
|
||||
Starting from LangBot 4.0, manifest files will be used to register plugins.
|
||||
Please create a new file `manifest.yaml` in the same directory as main.py. If it already exists, please modify it according to the format below.
|
||||
|
||||
```yaml
|
||||
apiVersion: v1 # Do not change
|
||||
kind: Plugin # Do not change
|
||||
metadata:
|
||||
# author and name uniquely identify a plugin
|
||||
author: langbot # Plugin author, change to your name
|
||||
name: Hello # Plugin name, change to your plugin name
|
||||
repository: 'https://github.com/langbot-app/HelloPlugin' # Plugin repository address, change to your plugin GitHub repository address
|
||||
version: 0.1.0 # Plugin version, change to your plugin version
|
||||
description: # Plugin description, change to your plugin description, supports multiple languages. Language codes follow the RFC 1766 standard.
|
||||
en_US: Plugin for sending hello
|
||||
zh_CN: 示例插件
|
||||
label: # Plugin display name, supports multiple languages. The WebUI will display the label in the corresponding language. Language codes follow the RFC 1766 standard.
|
||||
en_US: Hello
|
||||
zh_CN: Hello
|
||||
spec:
|
||||
# Plugin configuration (optional), can configure multiple items
|
||||
config:
|
||||
- name: github_token # Configuration item name
|
||||
label: # Configuration item display name, supports multiple languages. Language codes follow the RFC 1766 standard.
|
||||
en_US: Github Token
|
||||
zh_CN: Github Token
|
||||
description: # Configuration item description, supports multiple languages. Optional.
|
||||
en_US: Image downloading requires a Github token
|
||||
zh_CN: If not filled in, image download may fail
|
||||
type: string # Configuration item type, supports string, integer, float, boolean, etc.
|
||||
default: '' # Configuration item default value
|
||||
required: false # Whether the configuration item is required
|
||||
execution:
|
||||
python:
|
||||
path: main.py # Plugin main program path, must be the same as the file name of the plugin entry code above
|
||||
attr: HelloPlugin # Plugin class name, must be the same as the class name declared in the code above
|
||||
```
|
||||
|
||||
:::info
|
||||
Configuration item supported types:
|
||||
|
||||
- string: String
|
||||
- integer: Integer
|
||||
- float: Floating point number
|
||||
- boolean: Boolean value
|
||||
- array[string]: String array
|
||||
- select: Dropdown box, can select one option from multiple options
|
||||
- Need to configure the options option, indicating the options in the dropdown box
|
||||
|
||||
```yaml
|
||||
- name: mode
|
||||
label:
|
||||
en_US: Mode
|
||||
zh_CN: Mode
|
||||
type: select
|
||||
options:
|
||||
- name: mode1
|
||||
label:
|
||||
en_US: Mode 1
|
||||
zh_CN: Mode 1
|
||||
- name: mode2
|
||||
label:
|
||||
en_US: Mode 2
|
||||
zh_CN: Mode 2
|
||||
```
|
||||
- prompt-editor: Prompt editor.
|
||||
- llm-model-selector: LLM model selector.
|
||||
|
||||
After the user modifies the configuration items through the WebUI, the plugin can get the values of the configuration items in self.config.
|
||||
:::
|
||||
|
||||
|
||||
## ❗ Standards (Important)
|
||||
|
||||
- Please keep each plugin in a separate directory for management, it is recommended to create a repository on Github to store a single plugin for easy retrieval and updates
|
||||
- Naming conventions (important):
|
||||
- Plugin author: Use English, case insensitive, such as `RockChinQ`
|
||||
- Plugin name: Use `PascalCase`, such as `Hello`, `ExamplePlugin`, `ChineseCommands`, etc.
|
||||
- Plugin repository: Please use PascalCase, it is recommended to be the same as the plugin name, such as `HelloPlugin`
|
||||
- Plugin description: It is recommended to include the phrase `LangBot Plugin`
|
||||
- Multiple Python program files can be stored in one directory to separate the various functions of the plugin for easy management by developers, but it is not recommended to register multiple plugins in one directory
|
||||
- Please specify the dependencies required by the plugin in the `requirements.txt` file in the plugin directory, the program will automatically install the dependencies when obtaining this plugin from the repository
|
||||
|
||||
## 🪝 Content Functions
|
||||
|
||||
`Content functions` implemented through [GPT's Function Calling capability](https://platform.openai.com/docs/guides/gpt/function-calling), which is a function embedded in the conversation and automatically called by GPT.
|
||||
|
||||
> Your plugin does not necessarily have to include content functions, please check the content function page to understand this feature first
|
||||
|
||||
### Content Function Writing Steps
|
||||
|
||||
1️⃣ Please first follow the steps above to write your plugin's basic structure, now please delete (of course you can also keep them, just for simplicity) the various class functions decorated by `@handler` in the above plugin content
|
||||
|
||||
<details>
|
||||
<summary>Class structure after deletion</summary>
|
||||
|
||||
```python
|
||||
|
||||
class HelloPlugin(Plugin):
|
||||
|
||||
# Triggered when the plugin is loaded
|
||||
def __init__(self, plugin_host: APIHost):
|
||||
pass
|
||||
|
||||
# Triggered when the plugin is unloaded
|
||||
def __del__(self):
|
||||
pass
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
2️⃣ Now we add the following function to the position of the functions we just deleted (as a class method)
|
||||
|
||||
```Python
|
||||
|
||||
# Function to add
|
||||
@llm_func(name="access_the_web") # Set function name
|
||||
async def access_web(self, query, url: str):
|
||||
"""Call this function to search about the question before you answer any questions.
|
||||
- Do not search through baidu.com at any time.
|
||||
- If you need to search somthing, visit https://www.google.com/search?q=xxx.
|
||||
- If user ask you to open a url (start with http:// or https://), visit it directly.
|
||||
- Summary the plain content result by yourself, DO NOT directly output anything in the result you got.
|
||||
|
||||
Args:
|
||||
url(str): url to visit
|
||||
|
||||
Returns:
|
||||
str: plain text content of the web page
|
||||
"""
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
# You need to first use
|
||||
# pip install beautifulsoup4
|
||||
# to install dependencies
|
||||
|
||||
r = requests.get(
|
||||
url,
|
||||
timeout=10,
|
||||
headers={
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183"
|
||||
}
|
||||
)
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
|
||||
s = soup.get_text()
|
||||
|
||||
# Remove extra blank lines or lines with only \t and spaces
|
||||
s = re.sub(r'\n\s*\n', '\n', s)
|
||||
|
||||
if len(s) >= 512: # Truncate the first 512 characters of the plain text content of the web page
|
||||
return s[:512]
|
||||
|
||||
return s
|
||||
|
||||
```
|
||||
|
||||
#### Please note:
|
||||
|
||||
- The function's comments must be strictly written according to the required format, please check [this document](https://github.com/RockChinQ/CallingGPT/wiki/1.-Function-Format#function-format) for the specific format
|
||||
- Content functions and `event listeners decorated with @handler` can coexist in the same plugin and are both controlled by the plugin switch
|
||||
- Make sure that the model you are using supports the function calling feature
|
||||
|
||||
3️⃣ Now your program has web access capability, restart the program, ask the bot about online content or directly send article links requesting summaries.
|
||||
|
||||
- This is just an example, for more efficient web access capability support plugin, please check [WebwlkrPlugin](https://github.com/RockChinQ/WebwlkrPlugin)
|
||||
|
||||
## 📦 Publishing to the Plugin Market
|
||||
|
||||
When your plugin development is complete, please upload it to GitHub and [open an issue in the LangBot repository](https://github.com/RockChinQ/LangBot/issues/new?assignees=&labels=%E7%8B%AC%E7%AB%8B%E6%8F%92%E4%BB%B6&projects=&template=submit-plugin.yml&title=%5BPlugin%5D%3A+%E8%AF%B7%E6%B1%82%E7%99%BB%E8%AE%B0%E6%96%B0%E6%8F%92%E4%BB%B6). After review, it will be added to the plugin market and will be visible on the LangBot WebUI plugin page's plugin market in about half an hour.
|
||||
|
||||

|
||||
|
||||
## 📄 Glossary
|
||||
|
||||
### Description
|
||||
|
||||
The `ctx: EventContext` object obtained by the event listener method can be viewed in the `pkg.plugin.context` module for its structure. The `event` attribute of the `ctx` object is the event object of this event, from which you can extract related parameters. For specific parameters that can be obtained from each event, please check the comments of each event class in the `pkg.plugin.events` file.
|
||||
Event return values are all **optional**, you can submit return values by calling `ctx.add_return(key: str, ret)`
|
||||
|
||||
### Events
|
||||
|
||||
If an event is an event in a request (user sending a message), its event object will contain a `query` object, which includes the context data in the processing of this request (i.e., the process of handling a user sending a message, a request process may trigger multiple events).
|
||||
For all supported events, please check the comments of each event class in the `pkg.plugin.events` file.
|
||||
For `message chain components`, please check [Message Platform Entities](./messages)
|
||||
|
||||
### BasePlugin Structure
|
||||
|
||||
#### self.ap
|
||||
|
||||
Accessing `self.ap` in the plugin's methods is an object of the `pkg.core.app.Application` class, which contains the context object of the entire program, you can access all objects in the program through this object.
|
||||
|
||||
#### self.host
|
||||
|
||||
Accessing `self.host` in the plugin's methods is an object of the `pkg.plugin.context.APIHost` class, which provides some APIs of the main program, please check its source code for details.
|
||||
|
||||
### API Reference
|
||||
|
||||
For APIs that plugins can call, please check [API Reference](./api-ref)
|
||||
|
||||
### Plugin Development Group
|
||||
|
||||
Plugin development, publishing, and discussion
|
||||
|
||||
- LangBot Plugin Development: 1032327138 ([Link](https://qm.qq.com/q/G7ENGTjeou))
|
||||
@@ -0,0 +1,66 @@
|
||||
# Plugin Introduction
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## Plugin Categories
|
||||
|
||||
**Plugins** are extension modules for LangBot, containing two types of executable content: **event listeners** and **content functions**. Event listeners are driven by events in the main program, while content functions are driven by content generated by GPT. Both driving methods are uniformly wrapped in the plugin class.
|
||||
|
||||
### Event Listeners
|
||||
|
||||
Plugins listen to various events during LangBot's operation. When an event occurs, LangBot calls the listener registered by the plugin with event-related information. Plugins can register listeners to be triggered in specific situations.
|
||||
|
||||
### Content Functions
|
||||
|
||||
Content functions differ from event-triggered plugins in that during a conversation, when the conversation content matches the description of a content function, GPT specifies which function to call, and LangBot makes the call.
|
||||
This is implemented based on [GPT's Function Calling capability](https://platform.openai.com/docs/guides/gpt/function-calling), which is a function embedded in the conversation and automatically called by GPT.
|
||||
|
||||
> It's like the official ChatGPT plugins
|
||||
|
||||
For example, if we provide GPT with a function `access_the_web` and provide detailed descriptions of it and its parameters, then when we talk to GPT about content similar to 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: Search for the weather in Qingyuan today
|
||||
```
|
||||
|
||||
GPT will respond with a function call request for `access_the_web`, LangBot will call the content function provided by the plugin, and return the call result to GPT for it to generate a new response.
|
||||
Of course, the function calling feature is not limited to web access, it can also implement image processing, scientific calculations, trip planning, and other functions that require function calls. Theoretically, we can implement the same functionality as `ChatGPT Plugins` through content functions.
|
||||
|
||||
## Plugin Usage
|
||||
|
||||
### Installation
|
||||
|
||||
> This only provides the basic installation method for plugins, for details please check each plugin's documentation or consult its developer
|
||||
|
||||
#### Install from Plugin GitHub Repository
|
||||
|
||||
In the WebUI's plugin management page, click the `Install` button, enter the plugin's GitHub repository address, and click the `Install` button.
|
||||
|
||||
#### From Plugin Market
|
||||
|
||||
Install from the plugin market in the WebUI's plugin management page.
|
||||
|
||||
#### Manual Installation
|
||||
|
||||
Place the obtained plugin program in the `plugins` directory. For specific usage, please check each plugin's documentation 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 the specified 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
|
||||
```
|
||||
@@ -0,0 +1,42 @@
|
||||
# Using Dify with LangBot
|
||||
|
||||
[Dify](https://dify.ai) is an open-source large language model (LLM) application development platform. It combines the concepts of Backend as Service and LLMOps, enabling developers to quickly build production-grade generative AI applications.
|
||||
Dify can create chat assistants (including Chatflow), Agents, text generation applications, workflows, and other types of applications.
|
||||
|
||||
LangBot currently supports three types of Dify applications: `Chat Assistant` (including Chatflow), `Agent`, and `Workflow`.
|
||||
|
||||
## Creating an Application in Dify
|
||||
|
||||
Please follow the [Dify documentation](https://docs.dify.ai) to deploy Dify and create your application.
|
||||
|
||||
After publishing your application, go to the `Access API` page of your application to generate an API key.
|
||||
|
||||

|
||||
|
||||
Save the API server and API key for configuring LangBot's pipeline `AI Capability`.
|
||||
|
||||
:::info
|
||||
The above is an example for Dify cloud service version. If you are using the self-hosted community version, please use your own Dify service address as the `base-url` in LangBot, and add `/v1` as the path.
|
||||
|
||||
- If LangBot and Dify are deployed on the same host and both are deployed using Docker, you can refer to the article: [Network Configuration Details](/zh/workshop/network-details.html#langbot-%E5%92%8C%E6%B6%88%E6%81%AF%E5%B9%B3%E5%8F%B0%E5%9D%87%E8%BF%90%E8%A1%8C%E5%9C%A8-docker-%E5%AE%B9%E5%99%A8%E4%B8%AD). In this case, add `langbot-network` to the `networks` of all containers in the docker-compose.yaml file that starts Dify, add the container name `dify-nginx` to the `nginx` container, and finally set `base-url` to `http://dify-nginx/v1` in the LangBot configuration.
|
||||
- For other cases, please consult your company's operations team.
|
||||
:::
|
||||
|
||||
## Configuring LangBot
|
||||
|
||||
Open the LangBot WebUI page, add a new pipeline or switch to the AI capability configuration page in an existing pipeline.
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
### Workflow Output Key
|
||||
|
||||
If you are using a Dify workflow application, please use `summary` as the key to pass the output content.
|
||||
|
||||

|
||||
|
||||
## Output Processing
|
||||
|
||||
When using a workflow application or Agent application, if you enable `track-function-calls` in LangBot's pipeline `Output Processing`, a message of `calling function xxx` will be output to the user when Dify executes each tool call.
|
||||
However, if you are using `ChatFlow` under the `chat` application (Chat Assistant -> Workflow Orchestration), it will only output the text returned by the Answer (direct reply) node regardless of the settings.
|
||||
:::
|
||||
@@ -0,0 +1,50 @@
|
||||
# Implementing a Message Platform Adapter
|
||||
|
||||
This article will use the `aiocqhttp` adapter as an example to explain how to implement a new message platform adapter for LangBot, in order to integrate new message platform protocols such as WhatsApp and Discord.
|
||||
|
||||
## Registration
|
||||
|
||||
```text
|
||||
Add a new message platform adapter, for example: integrate WhatsApp, Discord, etc.
|
||||
|
||||
- Base class: `pkg.platform.adapter.MessageSourceAdapter`
|
||||
- Decorator: `pkg.platform.adapter.adapter_class(name: str)`
|
||||
- Reference implementation: `pkg.platform.sources/`
|
||||
```
|
||||
|
||||
To implement a message platform adapter, we essentially need to implement a class that inherits from the `base class` and register it using the `decorator`. Finally, it will be available for users to select and use during runtime.
|
||||
|
||||
### Contributing to the Main Repository
|
||||
|
||||
Create a new file `aiocqhttp.py` in the `pkg/platform/sources/` directory:
|
||||
|
||||
```python
|
||||
from .. import adapter
|
||||
|
||||
@adapter.adapter_class("aiocqhttp")
|
||||
class AiocqhttpAdapter(adapter.MessageSourceAdapter):
|
||||
pass
|
||||
```
|
||||
|
||||
Also import this module in `pkg/platform/manager.py` at line 40:
|
||||
|
||||
```python
|
||||
from .sources import nakuru, aiocqhttp, qqbotpy
|
||||
```
|
||||
|
||||
Finally, write your own manifest file by referring to other adapters' manifest files.
|
||||
|
||||
## Event and Message Converters
|
||||
|
||||
The main work of a message platform adapter is to `receive events from the message platform protocol, convert them into LangBot's format`, pass them to the core components, and after LangBot's core components process them, pass the content that needs to be replied to the message platform adapter, which then `converts the content into the platform protocol format and sends it to the message platform`.
|
||||
|
||||
The following diagram shows the processing patterns for two scenarios: message platform protocol without SDK and with mature SDK. In the first case, we need to implement connection management and network format data conversion to LB message Python objects according to the message platform protocol documentation. In the second case, the message platform has a mature SDK, we only need to create connections according to the SDK documentation, register event listeners, and implement message converters.
|
||||
|
||||

|
||||
|
||||
In the `pkg.platform.sources.aiocqhttp` file, we can see not only `AiocqhttpAdapter`, but also `class AiocqhttpMessageConverter(adapter.MessageConverter):` and `class AiocqhttpEventConverter(adapter.EventConverter):`.
|
||||
|
||||
- `MessageConverter` is used for converting between LangBot messages and platform messages.
|
||||
- `EventConverter` is used for converting between LangBot events and platform events.
|
||||
|
||||
TBC...
|
||||
@@ -0,0 +1,25 @@
|
||||
# MCP Ecosystem Details
|
||||
|
||||
The [MCP Protocol](https://modelcontextprotocol.io/) is a protocol that describes the interaction between applications and LLMs, and has been adopted by various products. LangBot can act as an MCP Client to connect to MCP Servers, providing extensive tools for LLMs to use during conversations with users.
|
||||
|
||||
## Finding MCP Servers
|
||||
|
||||
To use MCP tools in LangBot, you need to find and connect to existing MCP Servers.
|
||||
There are two types of MCP Servers in the market:
|
||||
|
||||
- Executable files implemented in Node or Python, communicating with LangBot through `stdio` (standard input/output)
|
||||
- Web services based on HTTP protocol, communicating with LangBot through HTTP protocol
|
||||
|
||||
:::info
|
||||
|
||||
- You can check existing MCP Servers in the [MCP Server List](https://github.com/punkpeye/awesome-mcp-servers).
|
||||
- For online hosted MCP Servers, you can find them at [Composio MCP](https://mcp.composio.dev/).
|
||||
- To write your own MCP Server, you can refer to the [MCP Protocol Documentation](https://modelcontextprotocol.io/quickstart/server) and [MCP Server Examples](https://modelcontextprotocol.io/examples).
|
||||
|
||||
:::
|
||||
|
||||
## Configuring MCP Server
|
||||
|
||||
Please refer to the [System Settings Documentation](/zh/deploy/settings.html)
|
||||
|
||||
After configuration, you can use the `!func` command in chat to view registered MCP tools. When chatting with models that support Function Calling, LangBot will automatically call MCP tools.
|
||||
@@ -0,0 +1,62 @@
|
||||
# Network Configuration Details
|
||||
|
||||
::: info
|
||||
Some messaging platforms (such as personal QQ accounts) require an independent protocol endpoint to process messages. If you are using such messaging platforms, please refer to the following network configuration.
|
||||
At the same time, if your LangBot instance needs to connect to other services running in containers (such as Ollama), you can also refer to the following configuration, replacing `messaging platform` with `the service you want to connect to`.
|
||||
:::
|
||||
|
||||
LangBot and some messaging platforms can both be deployed using Docker. Below are network configuration details for four different scenarios.
|
||||
|
||||
:::info Table of Contents
|
||||
[[toc]]
|
||||
:::
|
||||
|
||||
## Both LangBot and Messaging Platform Running in Docker Containers
|
||||
|
||||
If the messaging platform (NapCat/Lagrange) and LangBot are both started using Docker, you need to configure Docker's network connection.
|
||||
|
||||
Create a new network:
|
||||
|
||||
```bash
|
||||
docker network create langbot-network
|
||||
```
|
||||
|
||||
Add network configuration to the `docker-compose.yaml` file in the LangBot directory (add to the `services.langbot` field, and add the `langbot-network` network configuration under the `networks` field):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
langbot:
|
||||
...
|
||||
networks:
|
||||
- langbot-network
|
||||
...
|
||||
|
||||
networks:
|
||||
langbot-network:
|
||||
external: true
|
||||
```
|
||||
|
||||
Then add the same network configuration to the messaging platform's `docker-compose.yaml` file (if started directly with docker run command, add `--network langbot-network` to the startup command). Then in the messaging platform configuration file, change the IP address in the WS reverse connection address to `langbot` (for example: `ws://langbot:2280/ws`).
|
||||
|
||||
Restart both containers.
|
||||
|
||||
|
||||
|
||||
## Only LangBot Running in Docker Container
|
||||
|
||||
When only LangBot is deployed using Docker, ports 2280 to 2290 are already mapped to outside the container by default. At this time, LangBot can only act as a WebSocket server, accepting connections from messaging platforms as clients.
|
||||
|
||||
Please set the messaging platform to ReverseWebSocket (called `reverse ws` or `WebSocket client`), with the port corresponding to the port enabled by LangBot's aiocqhttp adapter, connecting to local 127.0.0.1.
|
||||
|
||||
|
||||
## Neither LangBot nor Messaging Platform Using Docker Deployment
|
||||
|
||||
Configure the messaging platform and LangBot settings according to the documentation, set both ports to the same unused port, and both connect to local 127.0.0.1.
|
||||
|
||||
## Only Messaging Platform Running in Docker Container (Not Recommended)
|
||||
|
||||
:::warning
|
||||
Only supports Linux, or other systems that support host mode docker networking.
|
||||
:::
|
||||
|
||||
Currently, LangBot's aiocqhttp adapter only supports reverse WebSocket connections. When the messaging platform runs in a Docker container while LangBot runs directly on the host machine, the messaging platform must act as a client connecting to LangBot. In this case, you can only set the messaging platform's network to `host` mode, and then set its WS connection address to 127.0.0.1, with the port corresponding to the port enabled by LangBot's aiocqhttp adapter.
|
||||
@@ -0,0 +1,5 @@
|
||||
# Integrating Models with PPIO Cloud API
|
||||
|
||||
Open the WebUI page, and select [PPIO Cloud](https://ppio.cn/user/register?from=ppinfra&invited_by=QJKFYD&utm_source=github_langbot) when adding a model.
|
||||
|
||||

|
||||
@@ -1,4 +1,4 @@
|
||||
# 欢迎来到 LangBot 文档中心
|
||||
# 欢迎访问 LangBot 文档
|
||||
|
||||
LangBot 是一个开源的大语言模型(LLM)原生即时通信机器人平台,支持多种消息平台和模型供应商。提供对 Dify、阿里云百炼等 LLMOps 平台的支持。并提供 WebUI 供用户快速部署和使用。
|
||||
|
||||
|
||||