不存在重大问题,但温度采样相关逻辑需要后需添加
This commit is contained in:
@@ -18,7 +18,7 @@ dependencies{
|
|||||||
implementation ("junit:junit:4.13.2")
|
implementation ("junit:junit:4.13.2")
|
||||||
implementation ("org.apache.logging.log4j:log4j-core:2.23.1")
|
implementation ("org.apache.logging.log4j:log4j-core:2.23.1")
|
||||||
implementation ("org.apache.logging.log4j:log4j-api:2.23.1")
|
implementation ("org.apache.logging.log4j:log4j-api:2.23.1")
|
||||||
implementation("top.mrxiaom.mirai:overflow-core-api:1.0.0.519-0d68f08-SNAPSHOT")
|
implementation("top.mrxiaom.mirai:overflow-core-all:1.0.0")
|
||||||
implementation ("com.alibaba:fastjson:1.2.73")
|
implementation ("com.alibaba:fastjson:1.2.73")
|
||||||
implementation ("org.projectlombok:lombok:1.18.36")
|
implementation ("org.projectlombok:lombok:1.18.36")
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.mamoe.mirai.event.events.MessageEvent;
|
|||||||
import plugin.chat.constant.Constant;
|
import plugin.chat.constant.Constant;
|
||||||
import plugin.config.Config;
|
import plugin.config.Config;
|
||||||
import plugin.config.CustomCommandTemplate;
|
import plugin.config.CustomCommandTemplate;
|
||||||
|
import plugin.config.ModelConfigTemplate;
|
||||||
import plugin.listener.FriendMessageListener;
|
import plugin.listener.FriendMessageListener;
|
||||||
import plugin.listener.GroupMessageListener;
|
import plugin.listener.GroupMessageListener;
|
||||||
import plugin.listener.OwnerMessageListener;
|
import plugin.listener.OwnerMessageListener;
|
||||||
@@ -117,7 +118,10 @@ public final class App extends JavaPlugin {
|
|||||||
helpMsg[0] += "\r\n";
|
helpMsg[0] += "\r\n";
|
||||||
helpMsg[0] += "————<模型列表>————";
|
helpMsg[0] += "————<模型列表>————";
|
||||||
for (int i = 0; i < Config.ConfigLoader.getConfig().getModelConfigTemplates().size(); i++) {
|
for (int i = 0; i < Config.ConfigLoader.getConfig().getModelConfigTemplates().size(); i++) {
|
||||||
helpMsg[0] += "\r\n\r\n"+"TemplateIndex: "+i+"\r\n"+Config.ConfigLoader.getConfig().getModelConfigTemplates().get(i).toString();
|
ModelConfigTemplate modelConfigTemplate = Config.ConfigLoader.getConfig().getModelConfigTemplates().get(i);
|
||||||
|
helpMsg[0] += "\r\n\r\n"+"TemplateIndex: "+i+"\r\n" +
|
||||||
|
"name: "+modelConfigTemplate.getTemplate_name() +
|
||||||
|
"base_url: "+modelConfigTemplate.getBase_url()+"\r\n";
|
||||||
}
|
}
|
||||||
event.getSubject().sendMessage(helpMsg[0]);
|
event.getSubject().sendMessage(helpMsg[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,11 +55,13 @@ public class ChatClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPromotion(String promotion){
|
public void setPromotion(String promotion){
|
||||||
|
if (!promotion.equals("null")) {
|
||||||
Message message = Message.builder()
|
Message message = Message.builder()
|
||||||
.role(Constant.Character.SYSTEM)
|
.role(Constant.Character.SYSTEM)
|
||||||
.content(promotion)
|
.content(promotion)
|
||||||
.build();
|
.build();
|
||||||
messages.add(0,message);
|
messages.add(0, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatResponse runChat(String content){
|
public ChatResponse runChat(String content){
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Constant {
|
|||||||
public static final String MATCH_IMAGE = "\\[mirai:image:(.*?)]";
|
public static final String MATCH_IMAGE = "\\[mirai:image:(.*?)]";
|
||||||
public static final String MATCH_MESSAGE = ".*[mirai:image:(https?://[\\w./?&=]+)].*";
|
public static final String MATCH_MESSAGE = ".*[mirai:image:(https?://[\\w./?&=]+)].*";
|
||||||
public static final String CUSTOM_SPLIT = "\\|";
|
public static final String CUSTOM_SPLIT = "\\|";
|
||||||
public static final String ADD_CUSTOM = "/[a-zA-Z]+\\|.*\\|.*";
|
public static final String ADD_CUSTOM = "/[a-zA-Z]+\\|[0-9]+\\|.*\\|.*";
|
||||||
public static final String MODEL_CHANGE = ".*\\|.*";
|
public static final String MODEL_CHANGE = ".*\\|.*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.inspector.TagInspector;
|
||||||
import plugin.chat.constant.Constant;
|
import plugin.chat.constant.Constant;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -76,10 +78,10 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Config load() throws IOException {
|
public static Config load() throws IOException {
|
||||||
Config config;
|
LoaderOptions loaderOptions = new LoaderOptions();
|
||||||
DumperOptions dumperOptions = new DumperOptions();
|
TagInspector tagInspector = tag -> true;
|
||||||
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
loaderOptions.setTagInspector(tagInspector);
|
||||||
Yaml yaml = new Yaml(dumperOptions);
|
Yaml yaml = new Yaml(loaderOptions);
|
||||||
File file = new File(Constant.Path.CONFIG_PATH);
|
File file = new File(Constant.Path.CONFIG_PATH);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileInputStream fileInputStream = new FileInputStream(Constant.Path.CONFIG_PATH);
|
FileInputStream fileInputStream = new FileInputStream(Constant.Path.CONFIG_PATH);
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ public class CustomCommandTemplate {
|
|||||||
return "command: " + command + "\r\n" +
|
return "command: " + command + "\r\n" +
|
||||||
"modelTemplateIndex: " + modelTemplateIndex + "\r\n" +
|
"modelTemplateIndex: " + modelTemplateIndex + "\r\n" +
|
||||||
"customModel: " + customModel + "\r\n" +
|
"customModel: " + customModel + "\r\n" +
|
||||||
"customPromotion: " + customPromotion + "\r\n";
|
"customPromotion: " + customPromotion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public class FriendMessageListener extends SimpleListenerHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OCRUtil.isSupported && url != null) {
|
if (OCRUtil.isSupported && url != null) {
|
||||||
content = content + "```content\r\n" + OCRUtil.getContentOfImage(url) + "\r\n```";
|
content = content.replace("[图片]","```recognized_image_content\r\n" + OCRUtil.getContentOfImage(url) + "\r\n```");
|
||||||
|
// content = content + "```image content\r\n" + OCRUtil.getContentOfImage(url) + "\r\n```";
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理消息头
|
//处理消息头
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class GroupMessageListener extends SimpleListenerHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OCRUtil.isSupported && url != null) {
|
if (OCRUtil.isSupported && url != null) {
|
||||||
content = content + "```content\r\n" + OCRUtil.getContentOfImage(url) + "\r\n```";
|
content = content.replace("[图片]","```recognized_image_content\r\n" + OCRUtil.getContentOfImage(url) + "\r\n```");
|
||||||
}
|
}
|
||||||
|
|
||||||
//消息头处理
|
//消息头处理
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class OwnerMessageListener extends SimpleListenerHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String instruction = primaryContent.split(Constant.Order.SPLIT_CUSTOM)[0];
|
String instruction = primaryContent.split(Constant.Order.SPLIT_CUSTOM)[0];
|
||||||
String arguments = primaryContent.substring(primaryContent.indexOf(Constant.Order.SPLIT_GUN) + 1);
|
String arguments = primaryContent.substring(instruction.length() + 1);
|
||||||
long id = event.getSender().getId();
|
long id = event.getSender().getId();
|
||||||
String response;
|
String response;
|
||||||
try {
|
try {
|
||||||
@@ -64,7 +64,7 @@ public class OwnerMessageListener extends SimpleListenerHost {
|
|||||||
String arguments;
|
String arguments;
|
||||||
try {
|
try {
|
||||||
instruction = primaryContent.split(Constant.Order.SPLIT_CUSTOM)[0];
|
instruction = primaryContent.split(Constant.Order.SPLIT_CUSTOM)[0];
|
||||||
arguments = primaryContent.substring(primaryContent.indexOf(Constant.Order.SPLIT_CUSTOM) + 1);
|
arguments = primaryContent.substring(instruction.length()+1);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
event.getFriend().sendMessage("操作失败,缺少参数");
|
event.getFriend().sendMessage("操作失败,缺少参数");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public class ChatUtil {
|
|||||||
|
|
||||||
private static void launchCleanerThread() {
|
private static void launchCleanerThread() {
|
||||||
Config config = Config.ConfigLoader.getConfig();
|
Config config = Config.ConfigLoader.getConfig();
|
||||||
long timeout = Long.parseLong(config.getTimeout());
|
long timeout = Long.parseLong(config.getTimeout().substring(1));
|
||||||
long timeCheck = Long.parseLong(config.getTimeCheck());
|
long timeCheck = Long.parseLong(config.getTimeCheck().substring(1));
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -77,6 +77,7 @@ public class ChatUtil {
|
|||||||
ChatClient chatClient = new ChatClient(chatId, url, apikey, customModel);
|
ChatClient chatClient = new ChatClient(chatId, url, apikey, customModel);
|
||||||
chatClient.setPromotion(customPromotion);
|
chatClient.setPromotion(customPromotion);
|
||||||
chatClients.put(chatId, chatClient);
|
chatClients.put(chatId, chatClient);
|
||||||
|
log.info("final content: {}",content);
|
||||||
chatResponse = chatClient.runChat(content);
|
chatResponse = chatClient.runChat(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,12 @@ public class MyTest {
|
|||||||
MiraiConsoleTerminalLoader.INSTANCE.startAsDaemon(terminal);
|
MiraiConsoleTerminalLoader.INSTANCE.startAsDaemon(terminal);
|
||||||
PluginManager.INSTANCE.loadPlugin(App.INSTANCE);
|
PluginManager.INSTANCE.loadPlugin(App.INSTANCE);
|
||||||
PluginManager.INSTANCE.enablePlugin(App.INSTANCE);
|
PluginManager.INSTANCE.enablePlugin(App.INSTANCE);
|
||||||
new Scanner(System.in).nextLine();
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
String input = scanner.nextLine();
|
||||||
|
while (true) {
|
||||||
|
if (input.equals("exit")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user