OpenAI Chat Bot plug-in under Mirai Console
Be based on https://chat.openai.com/
OpenAI currently has certain requirements for registration. Please read the registration first, and then create a Secret Key.
Note, it is not Cookie Token
, it is api-key
In addition, you can connect directly and do not need an agent. You only need an agent when registering an account.
api.openai.com
has been blacklisted. You need to configure the proxy. If not configured, this plug-in will try to do some special processing. It can also be used normally under normal circumstances
The IP address api.openai.com
was changed, and a layer of cloudflare
was applied. The special processing failed, and the response was 403
- text/html
chat
(chat_prefix) is used to trigger chat by default, based on the default model gpt-3.5-turbo
of /v1/chat/completions
Q&A
(question_prefix) is used to trigger Q&A by default, based on /v1/completions
default model text-davinci-003
When turning on image generation, use ?
(image_prefix) by default. When triggering to stop chat or Q&A, stop
is used by default to trigger reloading configuration. By default, openai-reload
(reload_prefix) is used to trigger. After use, the configuration will be reloaded without restarting Mirai Console
/v1/chat/completions
consumes fewer tokens
than /v1/completions
, but is specialized in chat. Please pay attention to the difference between the two. If you need to use GPT4
, please refer to Model endpoint compatibility to replace the model.
权限检查
is turned off by default and needs to be turned on in the basic configuration (after turning it on, the permission ID will be given in the log)
Preset prompt
(also called context or personality)
Usage example chat #猫娘
For custom configuration, please read the loading priority of the preset context default specified when starting the command ( chat #xxx
) > User-bound defaults > Group-bound defaults
Since 1.1.0, @
trigger chat configuration has been added (@ will be included when replying to messages on the mobile phone, please be careful not to accidentally touch it)
Since 1.2.0, the chat
function is connected to https://platform.openai.com/docs/api-reference/chat, saving Usage
Since 1.2.2 Fake SSLSocket
Since 1.3.0 added economic system docking and preset context
Since 1.3.1, add some configurations that may cause bugs.立刻开始聊天
and保持前缀检查
Since 1.4.0, the economic check logic has been modified to only check the balance before starting the chat.
Since 1.4.1 Add reference to binding preset ~
Since 1.5.0 add configuration to control cname
function, usage: add -Dxyz.cssxsh.openai.cname=false
in Java
startup parameters
chat
Q&A
picture
preset context
openai.yml
basic configuration
proxy
protocol supports socks
and http
, for example socks://127.0.0.1:7890
completion_prefix
custom model trigger prefix, used to test models and consumption, default >
image_prefix
Image generation trigger prefix, default ?
chat_prefix
chat model trigger prefix, default chat
question_prefix
Q&A model trigger prefix, default Q&A
reload_prefix
reload configuration trigger prefix, default openai-reload
economy_set_prefix
economy setting trigger prefix, default tokens
bind_set_prefix
binding sets trigger prefix, default bind
stop
stops chatting or Q&A, the default is stop
token
Secret Key, the plug-in will ask for input when it is started for the first time, so there is no need to edit the file again.error_reply
to the user when an error occurs, default true
end_reply
to the user when stopping chatting, default false
chat_limit
Chat service limitchat_by_at
chat model is triggered by @
, default false
has_permission
permission check, enabled when true
at_once
starts the chat/Q&A immediately (that is, it will not send聊天/问答将开始
, but directly follow the command to start the chat) Default is false
keep_prefix_check
keeps the prefix check (that is, the prefix / @
must be attached to trigger the conversation), the default is false
has_economy
economic system, turned on when true
@see https://github.com/cssxsh/mirai-economy-core completion.yml
custom model detailed configuration
model
max_tokens
answer lengthtemperature
is extreme, ranging from 0.0~2.0
image.yml
image generation model detailed configuration
number
of picturessize
is fixed, please do not change itformat
download method, please do not change it chat.yml
chat model detailed configuration
gpt_model
modeltimeout
wait for stop timemax_tokens
answer lengthtemperature
is extreme, ranging from 0.0~2.0
question.yml
question and answer model detailed configuration
model
timeout
wait for stop timemax_tokens
answer lengthtemperature
is extreme, ranging from 0.0~2.0
economy.yml
economy related
sign_plus_assign
number of tokens added by sign-in, default 1024
https://juejin.cn/post/7175153557941780541
Online test
https://platform.openai.com/playground
Official example
https://platform.openai.com/examples
@see https://github.com/cssxsh/mirai-economy-core
openai.com
calculates the fee through tokens
and the number of word segments (generally speaking, the longer the sentence, the longer the word segments).
In order to prevent some users from excessively consuming tokens
and causing the quota to be exhausted.
After docking, the economic system will calculate the tokens
amount for each user. When the individual's available tokens
are 0
, the chat function will refuse to respond and prompt.
管理员(未开启权限检查)
or持有经济权限的用户(已开启权限检查)
can set tokens
quotas for users.
Usage is tokens 114514 @12345
allocates 114514
tokens
to user 12345
Or tokens 12345
allocate 114514
tokens
to all group members.
Some people also describe it as人格
. In fact, this function is to tell the robot what role you need to play or what function you need to provide.
Configuration method, create a new XXX.txt
in the plug-in data directory data/xyz.cssxsh.mirai.plugin.mirai-openai-plugin/prompts
Then fill in the content you need to preset
Since 1.5, third-party contexts will be loaded from https://chathub.gg/api/community-prompts, and are compatible with spaces in the format of #<充当Linux 终端>
To use, append #XXX
after chat
, for example chat #猫娘
Or use bind
to bind a default prompt
to the current user, such as bind 猫娘
When the message is a group message and the current user is the administrator/group owner, the bound object will be群
, that is, setting the default for群
Since chat
will not enable the binding preset when there is additional content (the additional content will be treated as a preset), so to add a new function, use ~
or .
to refer to the binding preset, such as chat ~ ...
Please confirm that the version of mcl.jar is 2.1.0+
./mcl --update-package xyz.cssxsh.mirai:mirai-openai-plugin --channel maven-stable --type plugins
mirai2.jar
from Releases or Mavenplugins
folder