优化百度文心一言保存版本到文件

This commit is contained in:
Yutou 2024-05-05 17:13:10 +08:00
parent 7e9fa60f6a
commit 400f2df6ab
3 changed files with 23 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class QQBotApplication {
public static final String version = "QQBot v.1.7";
public static final String version = "QQBot v.1.7.1";
public static void main(String[] args) {
System.out.println("version = " + version);

View File

@ -8,10 +8,14 @@ import com.yutou.qqbot.data.baidu.ResponseMessage;
import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.BaiduGPTManager;
import com.yutou.napcat.event.MessageEvent;
import com.yutou.qqbot.utlis.ConfigTools;
import com.yutou.qqbot.utlis.StringUtils;
@UseModel
public class BaiduGPT extends Model {
private static String version = null;
@Override
public boolean isUserPublic() {
return true;
@ -33,6 +37,18 @@ public class BaiduGPT extends Model {
@Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, isGroup);
if (version == null) {
version = ConfigTools.load(ConfigTools.CONFIG, "baidu.gpt.version", String.class);
if (StringUtils.isEmpty(version)) {
version = "3.5";
BaiduGPTManager.getManager().setModelFor35();
}
}
if ("3.5".equals(version)) {
BaiduGPTManager.getManager().setModelFor35();
} else if ("4.0".equals(version)) {
BaiduGPTManager.getManager().setModelFor40();
}
if (event.getTextMessage().equals(QQGroupCommands.GPT_CLEAR)) {
BaiduGPTManager.getManager().clear();
QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text("已经失忆捏"));
@ -61,4 +77,8 @@ public class BaiduGPT extends Model {
QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text(sb));
}
}
public static void main(String[] args) {
System.out.println(ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.version"));
}
}

View File

@ -40,10 +40,12 @@ public class BaiduGPTManager {
public void setModelFor40() {
url = url_4_0;
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","4.0");
}
public void setModelFor35() {
url = url_3_5;
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","3.5");
}
public void clear() {