- 多语言支持
- 配置文件添加双语注释
- 新增负载均衡,可轮询或随机选择API key
- 优化构建配置,插件体积减小
- 项目规范化
This commit is contained in:
2025-03-17 22:36:34 +08:00
parent b815cc1129
commit 62f1a443ea
14 changed files with 765 additions and 392 deletions

135
readme.md
View File

@@ -1,10 +1,9 @@
# MineChatGPT
![minechatgpt](https://socialify.git.ci/ddaodan/minechatgpt/image?description=1&descriptionEditable=%E5%9C%A8Minecraft%E4%B8%AD%E4%B8%8EChatGPT%E4%BA%A4%E6%B5%81&font=Inter&issues=1&language=1&name=1&pattern=Solid&stargazers=1&theme=Auto)
![modrinth-gallery](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/documentation/modrinth-gallery_vector.svg) ![spigot](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/supported/spigot_vector.svg) ![paper](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/supported/paper_vector.svg) ![java8](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/built-with/java8_vector.svg)
![GitHub Release](https://img.shields.io/github/v/release/ddaodan/minechatgpt?label=version) ![bStats Servers](https://img.shields.io/bstats/servers/22635) ![bStats Players](https://img.shields.io/bstats/players/22635) ![Modrinth Downloads](https://img.shields.io/modrinth/dt/Op2X2eDG?logo=modrinth) ![Spiget Downloads](https://img.shields.io/spiget/downloads/118963?logo=spigotmc)
[![modrinth-gallery](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/documentation/modrinth-gallery_vector.svg)](https://modrinth.com/plugin/minechatgpt) [![spigot](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/supported/spigot_vector.svg)](https://www.spigotmc.org/resources/minechatgpt.118963/) ![paper](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/supported/paper_vector.svg) ![java8](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy-minimal/built-with/java8_vector.svg)
![GitHub Release](https://img.shields.io/github/v/release/ddaodan/minechatgpt?label=version) ![bStats Servers](https://img.shields.io/bstats/servers/22635) ![bStats Players](https://img.shields.io/bstats/players/22635) [![Modrinth Downloads](https://img.shields.io/modrinth/dt/Op2X2eDG?logo=modrinth)](https://modrinth.com/plugin/minechatgpt/versions) [![Spiget Downloads](https://img.shields.io/spiget/downloads/118963?logo=spigotmc)](https://www.spigotmc.org/resources/minechatgpt.118963/)
在Minecraft中与ChatGPT交流
理论支持全版本,欢迎测试
所有的代码都是ChatGPT写的哦
@@ -12,6 +11,7 @@
- OpenAPI格式
- 自定义模型
- ChatGPT反代
- 负载均衡
- 指令补全
- 上下文对话
- 多角色
@@ -20,98 +20,52 @@
## 安装
1. 下载插件放在plugins文件夹中
2. 重启服务器
> 为兼容更多版本插件没有规定Bukkit API version因此在较高版本加载插件时控制台可能会出现以下错误信息这属于正常现象。
> ```
> [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
> [Server thread/WARN]: Legacy plugin MineChatGPT v1.0 does not specify an api-version.
> ```
3. 打开配置文件`config.yml`,修改以下两项设置:
```yaml
# API 相关设置
api:
# 你的 OpenAI API key用于身份验证
# 获取 API key 的方法:访问 https://platform.openai.com/account/api-keys 并创建一个新的 API key
key: "sk-your_openai_api_key"
# OpenAI API 的基础 URL用于构建请求
base_url: "https://api.openai.com/v1"
```
> 为兼容更多版本插件没有规定Bukkit API version因此在较高版本加载插件时控制台可能会出现以下错误信息这属于正常现象。
> ```
> [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
> [Server thread/WARN]: Legacy plugin MineChatGPT v1.0 does not specify an api-version.
> ```
3. 打开配置文件`config.yml`,修改以下设置:
```yaml
# ======================================================
# API Configuration
# API 设置
# ======================================================
api:
# Your OpenAI API keys, used for authentication
# To obtain an API key, visit https://platform.openai.com/account/api-keys and create a new API key
# 你的 OpenAI API key用于身份验证
# 获取 API key 的方法:访问 https://platform.openai.com/account/api-keys 并创建一个新的 API key
keys:
- "sk-your_openai_api_key_1"
# You can add multiple API keys below
# 可以添加多个API key
# - "sk-your_openai_api_key_2"
# - "sk-your_openai_api_key_3"
# API key selection method: "round_robin" or "random"
# Round Robin: Use each API key in turn
# Random: Randomly select an API key
# API key 选择方法:"round_robin"(轮询)或 "random"(随机)
# 轮询依次使用每个API key
# 随机随机选择一个API key
selection_method: "round_robin"
# The base URL for the OpenAI API, used to construct requests
# If you cannot access the official API, you can use a proxy service
# OpenAI API 的基础 URL用于构建请求
# 如果你无法访问官方API可以使用代理服务
base_url: "https://api.openai.com/v1"
```
4. 在控制台中输入`/chatgpt reload`重新加载配置文件
## 截图
- 服务端截图Spigot 1.20.1
![](https://i.ddaodan.cn/images/CWindowssystem32cmd.exe_20240712406.png)
![](https://i.ddaodan.cc/images/CWindowssystem32cmd.exe_20240712406.png)
- 插件截图
![](https://i.ddaodan.cn/images/Minecraft_1.20.1_-__20240712407.png)
![](https://i.ddaodan.cc/images/Minecraft_1.20.1_-__20240712407.png)
- 对话截图使用FastGPT训练的自定义知识库
![](https://i.ddaodan.cn/images/Minecraft_1.20.1_-__20240712408.png)
## 配置文件`config.yml`
```yaml
# API 相关设置
api:
# 你的 OpenAI API key用于身份验证
# 获取 API key 的方法:访问 https://platform.openai.com/account/api-keys 并创建一个新的 API key
key: "sk-your_openai_api_key"
# OpenAI API 的基础 URL用于构建请求
base_url: "https://api.openai.com/v1"
# 支持的模型列表
models:
# OpenAI ChatGPT
- "gpt-3.5-turbo"
- "gpt-3.5-turbo-instruct"
- "gpt-4"
- "gpt-4-turbo"
- "gpt-4-turbo-preview"
- "gpt-4o"
- "gpt-4o-mini"
# Google Gemini
# - "gemini-pro"
# - "gemini-1.5-pro"
# Anthropic Claude
# - "claude-3-opus"
# - "claude-3-5-sonnet"
# 以及更多...
# 默认使用的模型
default_model: "gpt-3.5-turbo"
# 连续对话设置
conversation:
# 连续对话开关
context_enabled: false
# 最大历史记录保留数量
max_history_size: 10
# 角色设置
characters:
# 格式:
# 角色名称: "角色提示词"
ChatGPT: "You are a helpful assistant."
# 消息相关设置
messages:
reload: "&a已重新加载配置文件"
clear: "&a对话历史已清空"
help: "&e===== MineChatGPT 帮助 ====="
help_ask: "&e/chatgpt <text> - 向ChatGPT提问"
help_reload: "&e/chatgpt reload - 重新加载配置文件"
help_model: "&e/chatgpt model <model_name> - 切换至其他模型"
help_modellist: "&e/chatgpt modellist - 可用的模型列表"
help_context: "&e/chatgpt context - 切换连续对话模式"
help_clear: "&e/chatgpt clear - 清空对话历史"
help_character: "&e/chatgpt character [character_name] - 列出或切换角色"
context_toggle: "&e连续对话模式已%s。"
context_toggle_enabled: "&a开启"
context_toggle_disabled: "&c关闭"
current_model_info: "&e当前模型%s输入 /chatgpt model <model_name> 来切换模型。"
model_switch: "&a已切换至模型 %s"
chatgpt_error: "&c无法联系ChatGPT。"
chatgpt_response: "&b%s: %s"
question: "&b你: %s"
character_switched: "&a已切换至角色 %s"
available_characters: "&e可用的角色列表"
invalid_character: "&c无效的角色。使用 /chatgpt character 查看所有可用的角色。"
invalid_model: "&c模型无效。使用 /chatgpt modellist 查看可用模型。"
available_models: "&e可用模型列表"
no_permission: "&c你没有权限使用这个指令。需要的权限%s"
# 如果你不知道这是什么,请不要动
debug: false
```
![](https://i.ddaodan.cc/images/Minecraft_1.20.1_-__20240712408.png)
## 指令与权限
|指令|权限|描述|
@@ -142,7 +96,8 @@ debug: false
### 提问后控制台有`connect timeout` `connect reset`等类似的提示
检查`config.yml`中的`base_url`能否正常访问。如果你无法连接到OpenAI官方的API地址可以考虑使用其他反代。
### 我可以添加其他模型吗?
可以只要模型支持OpenAI的API就可以使用。
可以只要模型支持OpenAI的API就可以使用。
不推荐使用推理模型,因为推理模型的响应时间较长,在没有流式响应的情况下,玩家会认为插件出现了问题。
### 我没有ChatGPT的账号可以用吗
可以目前有很多代理网站可以很轻松地使用而且还支持其他模型费用通常来说也会比官方便宜。如果你愿意也可以使用我的代理目前仅在我的QQ群226385797中提供。
### 是否会支持Folia