textList = responseVO.payload.choices.text;
// Test
// System.out.println("textList.size(): " + textList.size());
- // TODO 3. 拼接形成完整回答串 每个Response的test里面只有一个元素
+ // 3. 拼接形成完整回答串 每个Response的test里面只有一个元素
for (Choices.Text temp : textList) {
// System.out.println("temp.content: " + temp.content);
outBuffer.append(temp.content);
@@ -268,7 +264,6 @@ class LLMSocket extends WebSocketListener {
}
}
} catch (IOException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
diff --git a/src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java b/src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java
index 85a56c7..2f4e434 100644
--- a/src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java
+++ b/src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java
@@ -148,7 +148,6 @@ public class BigModelNew extends WebSocketListener {
}
}
} catch (IOException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index a503060..eeb2be5 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,5 +1,5 @@
server:
- port: 8080
+ port: 47001
tomcat:
uri-encoding: UTF-8
max-http-header-size: 8192
@@ -8,37 +8,38 @@ spring:
datasource:
url: jdbc:mysql://localhost:3306/chitchat?serverTimezone=Asia/Shanghai&characterEncoding=utf-8
username: chatter
- password: 7890-=
+ password: dgKNTmt2iLHNjEQajkDEZkq8
driver-class-name: com.mysql.cj.jdbc.Driver
- data:
- redis:
- database: 0
- host: localhost
- port: 6379
- # password:
- #配置jedis客户端,这里也可以jedis替换为lettuce客户端,下级配置都一样
- jedis:
- pool:
- # 连接池中的最大空闲连接 默认8
- max-idle: 8
- # 连接池中的最小空闲连接 默认0
- min-idle: 0
- # 连接池最大连接数 默认8 ,负数表示没有限制
- max-active: 8
- # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
- max-wait: -1
- timeout: 3000
- cache:
- type: redis # 指定使用的缓存类型
- # redis: 当自定义CacheManager时,这里的配置不起作用
- # use-key-prefix: true
- # key-prefix: "demo:"
- # time-to-live: 60000 #缓存超时时间 单位:ms
- # cache-null-values: false #是否缓存空值
- cache-names: user
+# data:
+# redis:
+# database: 0
+# host: localhost
+# port: 6379
+# # password:
+# #配置jedis客户端,这里也可以jedis替换为lettuce客户端,下级配置都一样
+# jedis:
+# pool:
+# # 连接池中的最大空闲连接 默认8
+# max-idle: 8
+# # 连接池中的最小空闲连接 默认0
+# min-idle: 0
+# # 连接池最大连接数 默认8 ,负数表示没有限制
+# max-active: 8
+# # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
+# max-wait: -1
+# timeout: 3000
+# cache:
+# type: redis # 指定使用的缓存类型
+# # redis: 当自定义CacheManager时,这里的配置不起作用
+# # use-key-prefix: true
+# # key-prefix: "demo:"
+# # time-to-live: 60000 #缓存超时时间 单位:ms
+# # cache-null-values: false #是否缓存空值
+# cache-names: user
# 公共配置,与profiles选择无关
mybatis:
+ # TODO 复制到别的项目记得改这里!!!否则显式指定的类型别名和注解均不会生效
type-aliases-package: qiwu.xfllmdemo.pojo
mapper-locations: classpath:mapper/*.xml
# 开启MyBatis的二级缓存
diff --git a/src/main/resources/mapper/DBMapper.xml b/src/main/resources/mapper/DBMapper.xml
index 5936f06..6dc2fc0 100644
--- a/src/main/resources/mapper/DBMapper.xml
+++ b/src/main/resources/mapper/DBMapper.xml
@@ -1,49 +1,93 @@
+
-
diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml
index d423842..f17e43d 100644
--- a/src/main/resources/mybatis-config.xml
+++ b/src/main/resources/mybatis-config.xml
@@ -12,14 +12,10 @@
-
-
-
-
-
+
-
+
@@ -30,12 +26,13 @@
-
+
+
diff --git a/src/main/resources/static/pages/index/index.html b/src/main/resources/static/pages/index/index.html
deleted file mode 100644
index f174fff..0000000
--- a/src/main/resources/static/pages/index/index.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
- Title
-
-
-
-fdgfdgfdcvberrereg
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/static/pages/index/index.js b/src/main/resources/static/pages/index/index.js
deleted file mode 100644
index e69de29..0000000
--- a/src/main/resources/static/pages/index/index.js
+++ /dev/null
diff --git a/src/main/resources/static/pre-generate.html b/src/main/resources/static/pre-generate.html
index d22c982..6a27a67 100644
--- a/src/main/resources/static/pre-generate.html
+++ b/src/main/resources/static/pre-generate.html
@@ -1,5 +1,5 @@
-
+
@@ -10,20 +10,59 @@
-
- 在此处上传预设用户话语txt(接受txt和csv格式)
+
+ 在此处上传预设用户话语txt(接受txt和csv格式)
-
-
- ------------------------------
-
-
-
- ------------------------------
-
-
+
+
+
+
+ ------------------------------
+ 生成选项
+
+
+
+
+
+
+
+ ------------------------------
+
+
+
-
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/static/pre-generate.js b/src/main/resources/static/pre-generate.js
index c7e1ebf..c4c4c33 100644
--- a/src/main/resources/static/pre-generate.js
+++ b/src/main/resources/static/pre-generate.js
@@ -1,6 +1,9 @@
// 导出一些常量,包括上传信息、允许上传的文件类型、块大小和上传接口的URL
// 这些常量将在前端和后端代码中使用
-const BASE_URL = 'http://127.0.0.1:8080';
+// noinspection LanguageDetectionInspection
+
+// const BASE_URL = 'http://localhost:47001'; // TODO 打包记得修改
+const BASE_URL = 'https://tx-gz18.heyqiwu.cn';
/**
* dic - key : value
@@ -14,8 +17,6 @@ export const UPLOAD_INFO = {
};
export const ALLOWED_TYPE = {
- // 'video/mp4': 'mp4',
- // 'video/ogg': 'ogg'
'text/csv': 'csv',
'text/plain': 'txt'
};
@@ -24,45 +25,48 @@ export const CHUNK_SIZE = 64 * 1024;
export const API_URLS = {
UPLOAD_FILE: BASE_URL + '/api/pregen/upload',
+ GET_ROLE_LIST: BASE_URL + '/api/pregen/getRoleList',
+ GET_KNOWN_BOTS: BASE_URL + '/api/pregen/getKnownBots',
+ CREATE_ROLE: BASE_URL + '/api/pregen/createRole',
+ DELETE_ROLE: BASE_URL + '/api/pregen/deleteRole',
+ UPDATE_ROLE: BASE_URL + '/api/pregen/updateRole',
START_GEN: BASE_URL + '/api/pregen/generate'
};
-// 在闭包内部,定义一个立即执行的匿名函数,接受document作为参数
-((doc) => {
- // 获取页面上的一些元素
- const uploadProgressBar = doc.querySelector('#uploadProgressBar'); // 上传进度条
- const fileUploadInput = doc.querySelector('#fileUploadInput'); // 文件上传输入框
- const uploadInfo = doc.querySelector('#uploadInfo'); // p,显示上传状态信息
- const uploadButton = doc.querySelector('#uploadButton'); // 上传按钮
- const requirementArea = $('#requirementArea');
- const genButton = doc.querySelector('#genButton'); // 开始生成按钮
- const genInfo = $('#genInfo'); // p,显示生成状态信息
- const downloadButton = doc.querySelector('#downloadButton');
- const downloadInfo = $('#downloadInfo');
+let roleList = []; // 所有角色列表
+let knownBotsList = []; // 当前已知的模版Bot列表
- let uploadedSize = 0; // 已上传的文件大小,用于控制分块上传
+// 获取页面上的一些元素
+const uploadProgressBar = document.querySelector('#uploadProgressBar'); // 上传进度条
+const fileUploadInput = document.querySelector('#fileUploadInput'); // 文件上传输入框
+const uploadInfo = document.querySelector('#uploadInfo'); // p,显示上传状态信息
+const uploadButton = document.querySelector('#uploadButton'); // 上传按钮
- /**
- * 初始化函数
- */
- const init = () => {
- // 绑定事件函数 - 为元素添加事件监听器
- uploadButton.addEventListener('click', uploadFile, false); // uploadButton -> uploadFile()
- genButton.addEventListener('click', startGen, false); // genButton -> startGen()
- downloadButton.addEventListener('click', onDownload, false); // downloadButton -> onDownload()
- }
+const roleIdP = $('#roleIdP');
+const roleNameInput = $('#roleNameInput');
+const roleNameDatalist = $('#roleNameDatalist');
+
+const roleInfoArea = $('#roleInfoArea');
+
+const roleOptInfo = $('#roleOptInfo');
+const botAccountInput = $('#botAccountInput');
+const botAccountDatalist = $('#botAccountDatalist');
+const llmInput = $('#llmInput');
+const genInfo = $('#genInfo'); // p,显示生成状态信息
+const downloadButton = document.querySelector('#downloadButton');
+const downloadInfo = $('#downloadInfo');
+
+/**
+ * 上传/下载文件模块
+ * 在闭包内部,定义一个立即执行的匿名函数,接受document作为参数
+ */
+((doc) => {
+ let uploadedSize = 0; // 已上传的文件大小,用于控制分块上传
/**
* 创建FormData函数,将文件块和相关信息添加到FormData对象中
*/
- function createFormData({
- name,
- type,
- size,
- fileName,
- uploadedSize,
- file
- }) {
+ function createFormData({name, type, size, fileName, uploadedSize, file}) {
const fd = new FormData();
fd.append('name', name);
fd.append('type', type);
@@ -72,59 +76,43 @@ export const API_URLS = {
fd.append('file', file);
return fd;
}
-
/**
- * 创建视频元素函数,用于在页面上展示上传成功的视频
- */
- // function createFile(src) {
- // const uploadedVideo = document.createElement('file');
- // uploadedVideo.controls = true;
- // uploadedVideo.width = '500';
- // uploadedVideo.src = src;
- // document.body.appendChild(uploadedVideo);
- // }
-
- /**
- * 异步上传函数
+ * 上传 按钮事件
*/
async function uploadFile() {
console.log("uploadFile()");
- // 获取文件对象
+ // 1. 获取文件对象
const {files: [file]} = fileUploadInput;
- // 检查是否选择了文件,如果没有则显示提示信息
+ // 1.1 检查是否选择了文件,如果没有则显示提示信息
if (!file) {
console.log("No file chosen");
uploadInfo.innerText = UPLOAD_INFO['NO_FILE'];
return;
}
- // 检查文件类型是否被允许,如果不允许则显示提示信息
+ // 1.2 检查文件类型是否被允许,如果不允许则显示提示信息
console.log(file.type.toString());
if (!ALLOWED_TYPE[file.type]) {
console.log("Invalid file chosen");
uploadInfo.innerText = UPLOAD_INFO['INVALID_TYPE'];
return;
}
- // 获取文件的一些基本信息
+ // 2. 获取文件的一些基本信息
const {name, type, size} = file;
const fileName = new Date().getTime() + '_' + name;
let uploadedResult = null;
uploadProgressBar.max = size;
uploadInfo.innerText = '';
-
+ // 3. 将文件分块上传
while (uploadedSize < size) {
// 若文件大,使用slice方法将文件切割成小块,实现分块上传
const fileChunk = file.slice(uploadedSize, uploadedSize + CHUNK_SIZE);
// 创建FormData对象,用于传递文件块和相关信息
const formData = createFormData({
- name,
- type,
- size,
- fileName,
- uploadedSize,
+ name, type, size, fileName, uploadedSize,
file: fileChunk
});
+ // Test
console.log("axios POST");
- // 使用axios库发送POST请求,将文件块上传到后端
try {
uploadedResult = await axios.post(API_URLS.UPLOAD_FILE, formData);
} catch (e) {
@@ -136,34 +124,13 @@ export const API_URLS = {
uploadProgressBar.value = uploadedSize;
}
- // 上传成功后,显示上传成功的提示信息,并将文件输入框置空
+ // 4. 上传成功后,显示上传成功的提示信息,并将文件输入框置空
uploadInfo.innerText = UPLOAD_INFO['UPLOAD_SUCCESS'];
fileUploadInput.value = null;
- // 根据后端返回的视频URL,创建一个视频元素并展示在页面上
- // createFile(uploadedResult.data.video_url);
}
-
- async function startGen() {
- console.log("startGen()");
- let requirement = requirementArea.val();
- // Test
- console.log(requirement);
- $.ajax({
- url: API_URLS["START_GEN"],
- type: "POST",
- data: requirement,
- dataType: "text",
- contentType: "text/plain",
- beforeSend() {
- genInfo.text("等待中...");
- },
- success(res) { // responding with String
- genInfo.text("生成完成!");
- console.log("startGen() success");
- }
- });
- }
-
+ /**
+ * 下载导出文件 按钮事件
+ */
async function onDownload() {
// 替换为你的Spring Boot Controller 的下载接口地址
let downloadUrl = "/download?path=/path/to/your/file";
@@ -179,12 +146,285 @@ export const API_URLS = {
link.click();
document.body.removeChild(link);
}
-
// ------------------------------------
+ /**
+ * 初始化函数 定义
+ */
+ const init = () => {
+ // 绑定事件函数 - 为元素添加事件监听器
+ uploadButton.addEventListener('click', uploadFile, false); // uploadButton -> uploadFile()
+ downloadButton.addEventListener('click', onDownload, false); // downloadButton -> onDownload()
+ }
/**
* 初始化,执行绑定事件函数
*/
init();
-
}) (document);
+
+
+/**
+ * 生成 按钮事件
+ */
+async function startGen() {
+ console.log("startGen()");
+ // 1. 获取请求的人物设定和模型
+ let genParams = {
+ roleId: roleIdP.text(),
+ roleInfo: roleInfoArea.val(),
+ botAccount: botAccountInput.val(),
+ usingModel: llmInput.val()
+ };
+ // Test
+ console.log("genParams: ", genParams);
+ // 2. 判合法
+ if (roleIdP.text() === "") {
+ genInfo.text("请先创建新角色!");
+ return;
+ }
+ if (genParams.roleInfo === "" || genParams.botAccount === "" || genParams.usingModel === "") {
+ genInfo.text("人物设定、所属Bot和模型选择请勿留空!");
+ return;
+ }
+ // 3. 请求
+ $.ajax({
+ url: API_URLS["START_GEN"],
+ type: "POST",
+ data: genParams,
+ contentType: "application/json",
+ beforeSend() {
+ genInfo.text("生成中...");
+ },
+ success(res) { // responding with String
+ genInfo.text("生成完成!");
+ },
+ error(xmlHttpRequest, status, error) {
+ genInfo.text("生成失败!错误:" + xmlHttpRequest.responseText);
+ }
+ });
+}
+
+
+// 角色模块 - 出错信息在响应体中以text/plain返回
+
+/**
+ * 获取已知角色列表 - 维护