mirror of
https://github.com/ddaodan/minechatgpt.git
synced 2025-11-03 21:24:14 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 138b1337ac | |||
| 73edeba78c | |||
| 293c9257aa | |||
| 65665d88df |
10
build.gradle
10
build.gradle
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com'
|
||||
version = '1.0'
|
||||
version = '2.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -16,17 +16,21 @@ repositories {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/groups/public/"
|
||||
}
|
||||
maven {
|
||||
url = 'https://repo.codemc.io/repository/maven-public/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT"
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
compileOnly 'org.bstats:bstats-bukkit:3.0.2'
|
||||
implementation 'org.jodd:jodd-http:6.3.0'
|
||||
implementation 'org.json:json:20231013'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "MineChatGPT-${project.version}.jar"
|
||||
relocate 'okhttp3', 'com.ddaodan.minechatgpt.libs.okhttp3'
|
||||
relocate 'jodd', 'com.ddaodan.shaded.jodd'
|
||||
relocate 'org.json', 'com.ddaodan.minechatgpt.libs.org.json'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# 更新日志
|
||||
## 2.1
|
||||
- 接入bStats
|
||||
- 调整配置文件,添加更新功能,现在更新插件应该不用再备份配置文件了
|
||||
- 修改了gradle中错误的依赖
|
||||
## 2.0
|
||||
- 更换为jodd-http库,减少插件大小
|
||||
- 支持指令补全
|
||||
- 现在可以在配置文件中修改所有消息的颜色了
|
||||
- 默认配置文件中增加了一些模型
|
||||
## 1.0
|
||||
- 插件发布
|
||||
87
readme.md
87
readme.md
@@ -1,5 +1,6 @@
|
||||
# MineChatGPT
|
||||
在Minecraft中与ChatGPT交流
|
||||
在Minecraft中与ChatGPT交流
|
||||
理论支持全版本,欢迎测试
|
||||
|
||||
所有的代码都是ChatGPT写的哦
|
||||
|
||||
@@ -7,54 +8,102 @@
|
||||
- [x] OpenAPI格式
|
||||
- [x] 自定义模型
|
||||
- [x] ChatGPT反代
|
||||
- [ ] 指令补全
|
||||
- [x] 指令补全
|
||||
- [ ] 上下文对话
|
||||
- [ ] 自定义prompt
|
||||
|
||||
## 安装
|
||||
- 下载插件,放在plugins文件夹中
|
||||
- 重启服务器
|
||||
> 为兼容更多版本,插件使用1.13版本进行构建,因此在较高版本加载插件时,控制台会出现以下错误信息,这属于正常现象。
|
||||
> ```
|
||||
> [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.
|
||||
> ```
|
||||
|
||||
## 截图
|
||||
- 服务端截图(Spigot 1.20.1)
|
||||

|
||||
- 插件截图
|
||||

|
||||
- 对话截图(使用FastGPT训练的自定义知识库)
|
||||

|
||||
## 配置文件`config.yml`
|
||||
```yaml
|
||||
# API 相关设置
|
||||
api:
|
||||
# 你的 OpenAI API key,用于身份验证
|
||||
# 获取 API key 的方法:访问 //platform.openai.com/account/api-keys 并创建一个新的 API key
|
||||
key: "your_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"
|
||||
# Google Gemini
|
||||
# - "gemini-pro"
|
||||
# - "gemini-1.5-pro"
|
||||
# Anthropic Claude
|
||||
# - "claude-3-opus"
|
||||
# - "claude-3-5-sonnet"
|
||||
# 以及更多...
|
||||
# 默认使用的模型
|
||||
default_model: "gpt-3.5-turbo"
|
||||
# 消息相关设置
|
||||
messages:
|
||||
reload: "已重新加载配置文件!"
|
||||
help: "===== MineChatGPT 帮助 ====="
|
||||
help_ask: "/chatgpt <text> - 向ChatGPT提问"
|
||||
help_reload: "/chatgpt reload - 重新加载配置文件"
|
||||
help_model: "/chatgpt model <model_name> - 切换至其他模型"
|
||||
help_modellist: "/chatgpt modellist - 可用的模型列表"
|
||||
usage: "输入: /chatgpt model <model_name>"
|
||||
model_switch: "已切换至模型 %s"
|
||||
chatgpt_error: "无法联系ChatGPT。"
|
||||
chatgpt_response: "ChatGPT: %s"
|
||||
question: "你: %s"
|
||||
invalid_model: "模型无效。使用 /chatgpt modellist 查看可用模型。"
|
||||
available_models: "可用模型列表:"
|
||||
no_permission: "你没有权限使用这个指令。需要的权限:%s"
|
||||
reload: "&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 - 可用的模型列表"
|
||||
model_switch: "&a已切换至模型 %s"
|
||||
chatgpt_error: "&c无法联系ChatGPT。"
|
||||
chatgpt_response: "&bChatGPT: %s"
|
||||
question: "&b你: %s"
|
||||
invalid_model: "&c模型无效。使用 /chatgpt modellist 查看可用模型。"
|
||||
available_models: "&e可用模型列表:"
|
||||
no_permission: "&c你没有权限使用这个指令。需要的权限:%s"
|
||||
# 不要动!!!!!
|
||||
version: 2.1
|
||||
```
|
||||
|
||||
## 指令与权限
|
||||
|指令|权限|描述|
|
||||
|-|-|-|
|
||||
|`/chatgpt`|chatgpt.use|查看插件帮助|
|
||||
|`/chatgpt <text>`|chatgpt.use|向ChatGPT提问|
|
||||
|`/chatgpt reload`|chatgpt.reload|重新加载配置文件|
|
||||
|`/chatgpt model <model_name>`|chatgpt.model|切换至其他模型|
|
||||
|`/chatgpt modellist`|chatgpt.modellist|查看可用的模型列表|
|
||||
|
||||
## 兼容的版本
|
||||
✔ = 完全支持
|
||||
? = 部分支持
|
||||
× = 不支持
|
||||
只列出经过测试的版本
|
||||
|服务端|支持情况|
|
||||
|-|-|
|
||||
|Mohist 1.20.1|✔|
|
||||
|Spigot 1.20.1|✔|
|
||||
|Spigot 1.12.2|✔|
|
||||
|
||||
## 常见问题
|
||||
### `Failed to contact ChatGPT.` `无法联系ChatGPT。`
|
||||
检查控制台输出的错误内容。
|
||||
### `connect timeout` `connect reset`
|
||||
检查`config.yml`中的`base_url`能否正常访问。如果你无法连接到OpenAI官方的API地址,可以考虑使用其他反代。
|
||||
|
||||
### 我可以添加其他模型吗?
|
||||
可以,只要模型支持OpenAI的API,就可以使用。
|
||||
## 我没有ChatGPT的账号,可以用吗?
|
||||
可以,目前有很多代理网站,可以很轻松地使用,而且还支持其他模型,费用通常来说也会比官方便宜。如果你愿意,也可以使用我的代理,目前仅在我的QQ群:226385797中提供。
|
||||
### 是否会支持Folia
|
||||
不会。Folia仍然在开发中,短期内不会支持。
|
||||
## 赞助
|
||||

|
||||
@@ -3,16 +3,15 @@ package com.ddaodan.MineChatGPT;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.ChatColor;
|
||||
import okhttp3.*;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.List;
|
||||
|
||||
import jodd.http.HttpRequest;
|
||||
import jodd.http.HttpResponse;
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
private final Main plugin;
|
||||
private final ConfigManager configManager;
|
||||
@@ -34,49 +33,49 @@ public class CommandHandler implements CommandExecutor {
|
||||
String subCommand = args[0];
|
||||
if (subCommand.equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("minechatgpt.reload")) {
|
||||
sender.sendMessage(ChatColor.RED + String.format(configManager.getNoPermissionMessage(), "minechatgpt.reload"));
|
||||
sender.sendMessage(configManager.getNoPermissionMessage().replace("%s", "minechatgpt.reload"));
|
||||
return true;
|
||||
}
|
||||
configManager.reloadConfig();
|
||||
sender.sendMessage(ChatColor.GREEN + configManager.getReloadMessage());
|
||||
sender.sendMessage(configManager.getReloadMessage());
|
||||
return true;
|
||||
} else if (subCommand.equalsIgnoreCase("model")) {
|
||||
if (!sender.hasPermission("minechatgpt.model")) {
|
||||
sender.sendMessage(ChatColor.RED + String.format(configManager.getNoPermissionMessage(), "minechatgpt.model"));
|
||||
sender.sendMessage(configManager.getNoPermissionMessage().replace("%s", "minechatgpt.model"));
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + configManager.getUsageMessage());
|
||||
sender.sendMessage(configManager.getHelpModelMessage());
|
||||
return true;
|
||||
}
|
||||
String model = args[1];
|
||||
List<String> models = configManager.getModels();
|
||||
if (models.contains(model)) {
|
||||
// Logic to switch model
|
||||
sender.sendMessage(ChatColor.GREEN + String.format(configManager.getModelSwitchMessage(), model));
|
||||
sender.sendMessage(configManager.getModelSwitchMessage().replace("%s", model));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + configManager.getInvalidModelMessage());
|
||||
sender.sendMessage(configManager.getInvalidModelMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (subCommand.equalsIgnoreCase("modellist")) {
|
||||
if (!sender.hasPermission("minechatgpt.modellist")) {
|
||||
sender.sendMessage(ChatColor.RED + String.format(configManager.getNoPermissionMessage(), "minechatgpt.modellist"));
|
||||
sender.sendMessage(configManager.getNoPermissionMessage().replace("%s", "minechatgpt.modellist"));
|
||||
return true;
|
||||
}
|
||||
List<String> models = configManager.getModels();
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getAvailableModelsMessage());
|
||||
sender.sendMessage(configManager.getAvailableModelsMessage());
|
||||
for (String model : models) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "- " + model);
|
||||
sender.sendMessage("- " + model);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (!sender.hasPermission("minechatgpt.use")) {
|
||||
sender.sendMessage(ChatColor.RED + String.format(configManager.getNoPermissionMessage(), "minechatgpt.use"));
|
||||
sender.sendMessage(configManager.getNoPermissionMessage().replace("%s", "minechatgpt.use"));
|
||||
return true;
|
||||
}
|
||||
String question = String.join(" ", args);
|
||||
// Logic to send question to ChatGPT
|
||||
sender.sendMessage(ChatColor.AQUA + String.format(configManager.getQuestionMessage(), question));
|
||||
sender.sendMessage(configManager.getQuestionMessage().replace("%s", question));
|
||||
askChatGPT(sender, question);
|
||||
return true;
|
||||
}
|
||||
@@ -85,9 +84,6 @@ public class CommandHandler implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void askChatGPT(CommandSender sender, String question) {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("model", configManager.getDefaultModel());
|
||||
JSONArray messages = new JSONArray();
|
||||
@@ -97,44 +93,30 @@ public class CommandHandler implements CommandExecutor {
|
||||
messages.put(message);
|
||||
json.put("messages", messages);
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, json.toString());
|
||||
Request request = new Request.Builder()
|
||||
.url(configManager.getBaseUrl() + "/chat/completions")
|
||||
.post(body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + configManager.getApiKey())
|
||||
.build();
|
||||
HttpRequest request = HttpRequest.post(configManager.getBaseUrl() + "/chat/completions")
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", "Bearer " + configManager.getApiKey())
|
||||
.body(json.toString());
|
||||
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.log(Level.SEVERE, "Failed to contact ChatGPT: " + e.getMessage(), e);
|
||||
sender.sendMessage(ChatColor.RED + configManager.getChatGPTErrorMessage());
|
||||
}
|
||||
HttpResponse response = request.send();
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
String responseBody = response.body().string();
|
||||
JSONObject jsonResponse = new JSONObject(responseBody);
|
||||
String answer = jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
|
||||
sender.sendMessage(ChatColor.AQUA + String.format(configManager.getChatGPTResponseMessage(), answer));
|
||||
} else {
|
||||
String errorBody = response.body().string();
|
||||
logger.log(Level.SEVERE, "Failed to get a response from ChatGPT: " + errorBody);
|
||||
sender.sendMessage(ChatColor.RED + configManager.getChatGPTErrorMessage());
|
||||
}
|
||||
response.close();
|
||||
}
|
||||
});
|
||||
if (response.statusCode() == 200) {
|
||||
String responseBody = response.bodyText();
|
||||
JSONObject jsonResponse = new JSONObject(responseBody);
|
||||
String answer = jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
|
||||
sender.sendMessage(configManager.getChatGPTResponseMessage().replace("%s", answer));
|
||||
} else {
|
||||
String errorBody = response.bodyText();
|
||||
logger.log(Level.SEVERE, "Failed to get a response from ChatGPT: " + errorBody);
|
||||
sender.sendMessage(configManager.getChatGPTErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendHelpMessage(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getHelpMessage());
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getHelpAskMessage());
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getHelpReloadMessage());
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getHelpModelMessage());
|
||||
sender.sendMessage(ChatColor.YELLOW + configManager.getHelpModelListMessage());
|
||||
sender.sendMessage(configManager.getHelpMessage());
|
||||
sender.sendMessage(configManager.getHelpAskMessage());
|
||||
sender.sendMessage(configManager.getHelpReloadMessage());
|
||||
sender.sendMessage(configManager.getHelpModelMessage());
|
||||
sender.sendMessage(configManager.getHelpModelListMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ddaodan.MineChatGPT;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,6 +18,12 @@ public class ConfigManager {
|
||||
config = plugin.getConfig();
|
||||
}
|
||||
|
||||
private String translateColorCodes(String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
public String getConfigVersion() {
|
||||
return config.getString("version", "1.0");
|
||||
}
|
||||
public String getApiKey() {
|
||||
return config.getString("api.key");
|
||||
}
|
||||
@@ -30,7 +37,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public String getReloadMessage() {
|
||||
return config.getString("messages.reload");
|
||||
return translateColorCodes(config.getString("messages.reload"));
|
||||
}
|
||||
|
||||
public List<String> getModels() {
|
||||
@@ -38,54 +45,50 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public String getHelpMessage() {
|
||||
return config.getString("messages.help");
|
||||
return translateColorCodes(config.getString("messages.help"));
|
||||
}
|
||||
|
||||
public String getHelpAskMessage() {
|
||||
return config.getString("messages.help_ask");
|
||||
}
|
||||
|
||||
public String getHelpModelListMessage() {
|
||||
return config.getString("messages.help_modellist");
|
||||
return translateColorCodes(config.getString("messages.help_ask"));
|
||||
}
|
||||
|
||||
public String getHelpReloadMessage() {
|
||||
return config.getString("messages.help_reload");
|
||||
return translateColorCodes(config.getString("messages.help_reload"));
|
||||
}
|
||||
|
||||
public String getHelpModelMessage() {
|
||||
return config.getString("messages.help_model");
|
||||
return translateColorCodes(config.getString("messages.help_model"));
|
||||
}
|
||||
|
||||
public String getUsageMessage() {
|
||||
return config.getString("messages.usage");
|
||||
public String getHelpModelListMessage() {
|
||||
return translateColorCodes(config.getString("messages.help_modellist"));
|
||||
}
|
||||
|
||||
public String getModelSwitchMessage() {
|
||||
return config.getString("messages.model_switch");
|
||||
return translateColorCodes(config.getString("messages.model_switch"));
|
||||
}
|
||||
|
||||
public String getChatGPTErrorMessage() {
|
||||
return config.getString("messages.chatgpt_error");
|
||||
return translateColorCodes(config.getString("messages.chatgpt_error"));
|
||||
}
|
||||
|
||||
public String getChatGPTResponseMessage() {
|
||||
return config.getString("messages.chatgpt_response");
|
||||
return translateColorCodes(config.getString("messages.chatgpt_response"));
|
||||
}
|
||||
|
||||
public String getQuestionMessage() {
|
||||
return config.getString("messages.question");
|
||||
return translateColorCodes(config.getString("messages.question"));
|
||||
}
|
||||
|
||||
public String getInvalidModelMessage() {
|
||||
return config.getString("messages.invalid_model");
|
||||
return translateColorCodes(config.getString("messages.invalid_model"));
|
||||
}
|
||||
|
||||
public String getAvailableModelsMessage() {
|
||||
return config.getString("messages.available_models");
|
||||
return translateColorCodes(config.getString("messages.available_models"));
|
||||
}
|
||||
|
||||
public String getNoPermissionMessage() {
|
||||
return config.getString("messages.no_permission");
|
||||
return translateColorCodes(config.getString("messages.no_permission"));
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,58 @@
|
||||
package com.ddaodan.MineChatGPT;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
private ConfigManager configManager;
|
||||
private CommandHandler commandHandler;
|
||||
private MineChatGPTTabCompleter tabCompleter;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
saveDefaultConfig();
|
||||
configManager = new ConfigManager(this);
|
||||
commandHandler = new CommandHandler(this, configManager);
|
||||
tabCompleter = new MineChatGPTTabCompleter(configManager);
|
||||
Objects.requireNonNull(getCommand("chatgpt")).setExecutor(commandHandler);
|
||||
Objects.requireNonNull(getCommand("chatgpt")).setTabCompleter(tabCompleter);
|
||||
// Initialize bStats
|
||||
int pluginId = 22635;
|
||||
new Metrics(this, pluginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndUpdateConfig() {
|
||||
String currentVersion = getConfig().getString("version", "1.0");
|
||||
String pluginVersion = getDescription().getVersion();
|
||||
|
||||
if (!currentVersion.equals(pluginVersion)) {
|
||||
// 备份旧配置文件
|
||||
saveConfig();
|
||||
saveResource("config.old.yml", true);
|
||||
|
||||
// 加载默认配置文件
|
||||
FileConfiguration defaultConfig = getConfig();
|
||||
reloadConfig();
|
||||
FileConfiguration newConfig = getConfig();
|
||||
|
||||
// 合并配置文件
|
||||
for (String key : defaultConfig.getKeys(true)) {
|
||||
if (!newConfig.contains(key)) {
|
||||
newConfig.set(key, defaultConfig.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新版本号
|
||||
newConfig.set("version", pluginVersion);
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ddaodan.MineChatGPT;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
public class MineChatGPTTabCompleter implements TabCompleter {
|
||||
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public MineChatGPTTabCompleter(ConfigManager configManager) {
|
||||
this.configManager = configManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> completions = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
// 补全子命令
|
||||
completions.add("reload");
|
||||
completions.add("model");
|
||||
completions.add("modellist");
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("model")) {
|
||||
// 补全模型名称
|
||||
completions.addAll(configManager.getModels());
|
||||
}
|
||||
|
||||
// 过滤补全列表以匹配输入
|
||||
completions.removeIf(completion -> !completion.toLowerCase().startsWith(args[args.length - 1].toLowerCase()));
|
||||
|
||||
return completions;
|
||||
}
|
||||
}
|
||||
@@ -9,22 +9,34 @@ api:
|
||||
models:
|
||||
# OpenAI ChatGPT
|
||||
- "gpt-3.5-turbo"
|
||||
- "gpt-3.5-turbo-instruct"
|
||||
- "gpt-4"
|
||||
- "gpt-4-turbo"
|
||||
- "gpt-4-turbo-preview"
|
||||
- "gpt-4o"
|
||||
# Google Gemini
|
||||
# - "gemini-pro"
|
||||
# - "gemini-1.5-pro"
|
||||
# Anthropic Claude
|
||||
# - "claude-3-opus"
|
||||
# - "claude-3-5-sonnet"
|
||||
# And more...
|
||||
# The default model to use
|
||||
default_model: "gpt-3.5-turbo"
|
||||
# Message settings
|
||||
messages:
|
||||
reload: "Configuration reloaded successfully!"
|
||||
help: "===== MineChatGPT Help ====="
|
||||
help_ask: "/chatgpt <text> - Ask ChatGPT a question."
|
||||
help_reload: "/chatgpt reload - Reload the configuration file."
|
||||
help_model: "/chatgpt model <model_name> - Switch to a different model."
|
||||
help_modellist: "/chatgpt modellist - List available models."
|
||||
usage: "Usage: /chatgpt model <model_name>"
|
||||
model_switch: "Model switched to %s"
|
||||
chatgpt_error: "Failed to contact ChatGPT."
|
||||
chatgpt_response: "ChatGPT: %s"
|
||||
question: "Question: %s"
|
||||
invalid_model: "Invalid model. Use /chatgpt modellist to see available models."
|
||||
available_models: "Available models:"
|
||||
no_permission: "You do not have permission to use this command. Required permission: %s"
|
||||
reload: "&aConfiguration reloaded successfully!"
|
||||
help: "&e===== MineChatGPT Help ====="
|
||||
help_ask: "&e/chatgpt <text> - Ask ChatGPT a question."
|
||||
help_reload: "&e/chatgpt reload - Reload the configuration file."
|
||||
help_model: "&e/chatgpt model <model_name> - Switch to a different model."
|
||||
help_modellist: "&e/chatgpt modellist - List available models."
|
||||
model_switch: "&aModel switched to %s"
|
||||
chatgpt_error: "&cFailed to contact ChatGPT."
|
||||
chatgpt_response: "&bChatGPT: %s"
|
||||
question: "&bYou: %s"
|
||||
invalid_model: "&cInvalid model. Use /chatgpt modellist to see available models."
|
||||
available_models: "&eAvailable models:"
|
||||
no_permission: "&cYou do not have permission to use this command. Required permission: %s"
|
||||
# DO NOT EDIT!!!!!
|
||||
version: 2.1
|
||||
@@ -1,30 +1,42 @@
|
||||
# API 相关设置
|
||||
api:
|
||||
# 你的 OpenAI API key,用于身份验证
|
||||
# 获取 API key 的方法:访问 //platform.openai.com/account/api-keys 并创建一个新的 API key
|
||||
key: "your_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"
|
||||
# Google Gemini
|
||||
# - "gemini-pro"
|
||||
# - "gemini-1.5-pro"
|
||||
# Anthropic Claude
|
||||
# - "claude-3-opus"
|
||||
# - "claude-3-5-sonnet"
|
||||
# 以及更多...
|
||||
# 默认使用的模型
|
||||
default_model: "gpt-3.5-turbo"
|
||||
# 消息相关设置
|
||||
messages:
|
||||
reload: "已重新加载配置文件!"
|
||||
help: "===== MineChatGPT 帮助 ====="
|
||||
help_ask: "/chatgpt <text> - 向ChatGPT提问"
|
||||
help_reload: "/chatgpt reload - 重新加载配置文件"
|
||||
help_model: "/chatgpt model <model_name> - 切换至其他模型"
|
||||
help_modellist: "/chatgpt modellist - 可用的模型列表"
|
||||
usage: "输入: /chatgpt model <model_name>"
|
||||
model_switch: "已切换至模型 %s"
|
||||
chatgpt_error: "无法联系ChatGPT。"
|
||||
chatgpt_response: "ChatGPT: %s"
|
||||
question: "你: %s"
|
||||
invalid_model: "模型无效。使用 /chatgpt modellist 查看可用模型。"
|
||||
available_models: "可用模型列表:"
|
||||
no_permission: "你没有权限使用这个指令。需要的权限:%s"
|
||||
reload: "&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 - 可用的模型列表"
|
||||
model_switch: "&a已切换至模型 %s"
|
||||
chatgpt_error: "&c无法联系ChatGPT。"
|
||||
chatgpt_response: "&bChatGPT: %s"
|
||||
question: "&b你: %s"
|
||||
invalid_model: "&c模型无效。使用 /chatgpt modellist 查看可用模型。"
|
||||
available_models: "&e可用模型列表:"
|
||||
no_permission: "&c你没有权限使用这个指令。需要的权限:%s"
|
||||
# 不要动!!!!!
|
||||
version: 2.1
|
||||
@@ -7,7 +7,7 @@ description: A Spigot plugin for interacting with ChatGPT
|
||||
commands:
|
||||
chatgpt:
|
||||
description: Interact with ChatGPT
|
||||
usage: /chatgpt <question>
|
||||
usage: /chatgpt <text>
|
||||
permissions:
|
||||
minechatgpt.use:
|
||||
description: Allows using the /chatgpt command to interact with AI
|
||||
|
||||
Reference in New Issue
Block a user