Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
XfLLMDemo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈宥希
XfLLMDemo
Commits
df378329
Commit
df378329
authored
Sep 19, 2023
by
cyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit 20230919 Tue
parent
4bbe7675
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
434 additions
and
555 deletions
+434
-555
pom.xml
pom.xml
+6
-4
HttpMsgConverterConfig.java
src/main/java/qiwu/xfllmdemo/HttpMsgConverterConfig.java
+27
-0
AuditController.java
src/main/java/qiwu/xfllmdemo/controller/AuditController.java
+33
-9
PreGenerateController.java
...java/qiwu/xfllmdemo/controller/PreGenerateController.java
+0
-0
QueryController.java
src/main/java/qiwu/xfllmdemo/controller/QueryController.java
+0
-25
RedisTap.java
src/main/java/qiwu/xfllmdemo/controller/RedisTap.java
+0
-34
DBMapper.java
src/main/java/qiwu/xfllmdemo/mapper/DBMapper.java
+57
-5
AuditDataDAO.java
src/main/java/qiwu/xfllmdemo/pojo/AuditDataDAO.java
+15
-74
AuditQueryDAO.java
src/main/java/qiwu/xfllmdemo/pojo/AuditQueryDAO.java
+13
-64
AuditResponseVO.java
src/main/java/qiwu/xfllmdemo/pojo/AuditResponseVO.java
+8
-5
DialogueVO.java
src/main/java/qiwu/xfllmdemo/pojo/DialogueVO.java
+10
-12
GenParamsVO.java
src/main/java/qiwu/xfllmdemo/pojo/GenParamsVO.java
+23
-0
IntentionDAO.java
src/main/java/qiwu/xfllmdemo/pojo/IntentionDAO.java
+14
-46
LLMAnswerVO.java
src/main/java/qiwu/xfllmdemo/pojo/LLMAnswerVO.java
+3
-4
LLMQueryVO.java
src/main/java/qiwu/xfllmdemo/pojo/LLMQueryVO.java
+3
-4
LLMRequestVO.java
src/main/java/qiwu/xfllmdemo/pojo/LLMRequestVO.java
+4
-3
LLMResponseVO.java
src/main/java/qiwu/xfllmdemo/pojo/LLMResponseVO.java
+10
-10
OptDAO.java
src/main/java/qiwu/xfllmdemo/pojo/OptDAO.java
+16
-54
QueryRequestVO.java
src/main/java/qiwu/xfllmdemo/pojo/QueryRequestVO.java
+0
-18
QueryResponseVO.java
src/main/java/qiwu/xfllmdemo/pojo/QueryResponseVO.java
+0
-18
RolesDAO.java
src/main/java/qiwu/xfllmdemo/pojo/RolesDAO.java
+12
-34
LLMService.java
src/main/java/qiwu/xfllmdemo/service/LLMService.java
+15
-20
BigModelNew.java
src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java
+0
-1
application.yml
src/main/resources/application.yml
+29
-28
DBMapper.xml
src/main/resources/mapper/DBMapper.xml
+71
-31
mybatis-config.xml
src/main/resources/mybatis-config.xml
+4
-7
index.html
src/main/resources/static/pages/index/index.html
+0
-23
index.js
src/main/resources/static/pages/index/index.js
+0
-0
pre-generate.html
src/main/resources/static/pre-generate.html
+53
-13
pre-generate.js
src/main/resources/static/pre-generate.js
+0
-0
getAuditDataTest.http
src/test/getAuditDataTest.http
+2
-2
XfLLMDemoApplicationTests.java
src/test/java/qiwu/xfllmdemo/XfLLMDemoApplicationTests.java
+6
-7
No files found.
pom.xml
View file @
df378329
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
3.1.2
</version>
<version>
2.7.15
</version>
<relativePath/>
<!-- lookup parent from repository -->
<relativePath/>
<!-- lookup parent from repository -->
</parent>
</parent>
<groupId>
qiwu
</groupId>
<groupId>
qiwu
</groupId>
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<name>
xfLLMDemo
</name>
<name>
xfLLMDemo
</name>
<description>
xfLLMDemo
</description>
<description>
xfLLMDemo
</description>
<properties>
<properties>
<java.version>
17
</java.version>
<java.version>
8
</java.version>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
...
@@ -79,13 +79,15 @@
...
@@ -79,13 +79,15 @@
<dependency>
<dependency>
<groupId>
org.mybatis
</groupId>
<groupId>
org.mybatis
</groupId>
<artifactId>
mybatis-spring
</artifactId>
<artifactId>
mybatis-spring
</artifactId>
<version>
3.0.2
</version>
<!-- <version>3.0.2</version>-->
<version>
2.1.1
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
3.0.2
</version>
<!-- <version>3.0.2</version>-->
<version>
2.3.1
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
src/main/java/qiwu/xfllmdemo/HttpMsgConverterConfig.java
0 → 100644
View file @
df378329
package
qiwu
.
xfllmdemo
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
/**
* 配置使用哪种JSON转换器进行HTTP请求体/响应体与对象间的转换 - 使用FastJSON
*/
@Configuration
public
class
HttpMsgConverterConfig
implements
WebMvcConfigurer
{
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
// 创建FastJSON消息转换器
FastJsonHttpMessageConverter
fastJsonConverter
=
new
FastJsonHttpMessageConverter
();
// 配置FastJSON参数
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
// 这里可以配置一些FastJSON的参数,如日期格式化等
fastJsonConverter
.
setFastJsonConfig
(
fastJsonConfig
);
// 添加FastJSON消息转换器到消息转换器列表
converters
.
add
(
fastJsonConverter
);
}
}
src/main/java/qiwu/xfllmdemo/controller/AuditController.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
controller
;
package
qiwu
.
xfllmdemo
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
ja
karta
.servlet.http.HttpServletResponse
;
import
ja
vax
.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.lang.Nullable
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
qiwu.xfllmdemo.mapper.DBMapper
;
import
qiwu.xfllmdemo.mapper.DBMapper
;
...
@@ -17,16 +16,21 @@ public class AuditController {
...
@@ -17,16 +16,21 @@ public class AuditController {
@Autowired
@Autowired
private
DBMapper
dbMapper
;
private
DBMapper
dbMapper
;
@GetMapping
(
value
=
"/getAuditData"
)
/**
* 请求一页审核页面内容
*/
@CrossOrigin
// 允许跨域请求
@CrossOrigin
// 允许跨域请求
@ResponseBody
// 令返回值作为响应体内容
@ResponseBody
// 令返回值作为响应体内容
@GetMapping
(
value
=
"/getAuditData"
)
public
String
getAuditData
(
@RequestParam
(
"searchText"
)
String
searchText
,
public
String
getAuditData
(
@RequestParam
(
"searchText"
)
String
searchText
,
@RequestParam
(
"auditStatus"
)
String
auditStatus
,
@RequestParam
(
"auditStatus"
)
String
auditStatus
,
@RequestParam
(
"pageNum"
)
int
pageNum
,
@RequestParam
(
"pageNum"
)
int
pageNum
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sortMethod"
)
String
sortMethod
,
@RequestParam
(
"sortMethod"
)
String
sortMethod
,
@RequestParam
(
"ofBot"
)
String
ofBot
,
@RequestParam
(
"ofModel"
)
String
ofModel
,
HttpServletResponse
response
)
{
HttpServletResponse
response
)
{
//
TODO
1. 参数处理、请求
// 1. 参数处理、请求
int
offset
=
(
pageNum
-
1
)
*
pageSize
;
int
offset
=
(
pageNum
-
1
)
*
pageSize
;
Short
as
;
Short
as
;
try
{
try
{
...
@@ -34,10 +38,10 @@ public class AuditController {
...
@@ -34,10 +38,10 @@ public class AuditController {
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
as
=
null
;
as
=
null
;
}
}
AuditQueryDAO
aqDAO
=
new
AuditQueryDAO
(
searchText
,
as
,
offset
,
pageSize
,
sortMethod
);
AuditQueryDAO
aqDAO
=
new
AuditQueryDAO
(
searchText
,
as
,
offset
,
pageSize
,
sortMethod
,
ofBot
,
ofModel
);
// Test
// Test
System
.
out
.
println
(
"aqDAO: "
+
aqDAO
);
System
.
out
.
println
(
"aqDAO: "
+
aqDAO
);
//
TODO 2. 构造回复
//
2. 构造响应体
AuditResponseVO
arVO
=
new
AuditResponseVO
();
AuditResponseVO
arVO
=
new
AuditResponseVO
();
try
{
try
{
arVO
.
data
.
pageNum
=
pageNum
;
arVO
.
data
.
pageNum
=
pageNum
;
...
@@ -54,16 +58,36 @@ public class AuditController {
...
@@ -54,16 +58,36 @@ public class AuditController {
}
}
/**
/**
* 更新一条模型回复的审核状态
(一并提交人工修改)
* 更新一条模型回复的审核状态
或提交人工修改
* @param adDAO 前端需传入:该条回复的optId、新的auditStatus;如有人工修改则传入新的reply,否则reply留null
* @param adDAO 前端需传入:该条回复的optId、新的auditStatus;如有人工修改则传入新的reply,否则reply留null
* @return {"code": , "msg": }
* @return {"code": , "msg": }
*/
*/
@PutMapping
(
value
=
"/putAuditData"
)
@CrossOrigin
// 允许跨域请求
@CrossOrigin
// 允许跨域请求
@ResponseBody
// 令返回值作为响应体内容
@ResponseBody
// 令返回值作为响应体内容
@PutMapping
(
value
=
"/putAuditData"
)
public
String
putAuditData
(
@RequestBody
AuditDataDAO
adDAO
,
HttpServletResponse
response
)
{
public
String
putAuditData
(
@RequestBody
AuditDataDAO
adDAO
,
HttpServletResponse
response
)
{
try
{
try
{
Integer
i
=
dbMapper
.
putAuditData
(
adDAO
);
// TODO Returning i?
dbMapper
.
putAuditData
(
adDAO
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
return
"{\"code\": 1, \"msg\": \"成功\"}"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
response
.
setStatus
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
return
"{\"code\": 0, \"msg\": \"失败\"}"
;
}
}
/**
* 删除一条模型回复
* @param adDAO 前端需传入:该条回复的optId
* @return {"code": , "msg": }
*/
@CrossOrigin
// 允许跨域请求
@ResponseBody
// 令返回值作为响应体内容
@PostMapping
(
value
=
"/deleteReply"
)
public
String
deleteReply
(
@RequestBody
AuditDataDAO
adDAO
,
HttpServletResponse
response
)
{
try
{
dbMapper
.
deleteFromOpt
(
adDAO
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
return
"{\"code\": 1, \"msg\": \"成功\"}"
;
return
"{\"code\": 1, \"msg\": \"成功\"}"
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/qiwu/xfllmdemo/controller/PreGenerateController.java
View file @
df378329
This diff is collapsed.
Click to expand it.
src/main/java/qiwu/xfllmdemo/controller/QueryController.java
deleted
100644 → 0
View file @
4bbe7675
package
qiwu
.
xfllmdemo
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
qiwu.xfllmdemo.pojo.LLMQueryVO
;
import
qiwu.xfllmdemo.pojo.LLMAnswerVO
;
import
qiwu.xfllmdemo.pojo.QueryRequestVO
;
import
qiwu.xfllmdemo.pojo.QueryResponseVO
;
import
qiwu.xfllmdemo.service.LLMService
;
@RestController
@RequestMapping
(
"/request"
)
public
class
QueryController
{
@Autowired
LLMService
llmService
=
new
LLMService
();
@RequestMapping
(
value
=
"/queryModel"
,
method
=
RequestMethod
.
POST
,
headers
=
"Accept=application/json"
)
public
QueryResponseVO
queryModel
(
@RequestBody
QueryRequestVO
queryRequestVO
)
throws
Exception
{
LLMAnswerVO
res
=
llmService
.
query
(
new
LLMQueryVO
(
queryRequestVO
),
1
,
true
);
QueryResponseVO
repVO
=
new
QueryResponseVO
(
res
);
return
repVO
;
}
}
src/main/java/qiwu/xfllmdemo/controller/RedisTap.java
deleted
100644 → 0
View file @
4bbe7675
package
qiwu
.
xfllmdemo
.
controller
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisPool
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
RedisTap
{
JedisPool
pool
=
new
JedisPool
(
"localhost"
,
6379
);
Jedis
jedis
;
RedisTap
()
{
jedis
=
pool
.
getResource
();
// jedis.close();
try
{
// Store & Retrieve a simple string
jedis
.
set
(
"foo"
,
"bar"
);
System
.
out
.
println
(
jedis
.
get
(
"foo"
));
// prints bar
// Store & Retrieve a HashMap
Map
<
String
,
String
>
hash
=
new
HashMap
<>();;
hash
.
put
(
"name"
,
"John"
);
hash
.
put
(
"surname"
,
"Smith"
);
hash
.
put
(
"company"
,
"Redis"
);
hash
.
put
(
"age"
,
"29"
);
jedis
.
hset
(
"user-session:123"
,
hash
);
System
.
out
.
println
(
jedis
.
hgetAll
(
"user-session:123"
));
// Prints: {name=John, surname=Smith, company=Redis, age=29}
}
catch
(
Exception
ignored
)
{
}
}
}
src/main/java/qiwu/xfllmdemo/mapper/DBMapper.java
View file @
df378329
...
@@ -10,27 +10,79 @@ import java.util.List;
...
@@ -10,27 +10,79 @@ import java.util.List;
@Component
@Component
@Mapper
@Mapper
public
interface
DBMapper
{
public
interface
DBMapper
{
//
/pregen
//
预生成部分
/**
/**
* 获得当前最大的意图ID
* 获得当前最大的意图ID
*/
*/
Integer
getMaxIntentionID
();
Integer
getMaxIntentionID
();
/**
* 将传入的intentionDAOList中所有记录插入intention表
*/
Integer
insertIntoIntention
(
List
<
IntentionDAO
>
intentionDAOList
);
Integer
insertIntoIntention
(
List
<
IntentionDAO
>
intentionDAOList
);
/**
* 将传入的optDAOList中所有记录插入opt表
*/
Integer
insertIntoOpt
(
List
<
OptDAO
>
optDAOList
);
Integer
insertIntoOpt
(
List
<
OptDAO
>
optDAOList
);
List
<
DialogueVO
>
getReply
(
String
user_words
);
// /audit
/**
* 在intention表中查询传入的<用户话语,bot编号>是否有已经分配的意图ID
* @return 已经分配的意图ID,若没有则为null
*/
Integer
getRoleIdByUWBA
(
@Param
(
"userWords"
)
String
userWords
,
@Param
(
"botAccount"
)
String
botAccount
);
/**
* 预生成界面上,提供选角色功能,需先查询角色列表
*/
List
<
RolesDAO
>
getRoleList
();
/**
* 创建一个新角色
*
* @param rolesDAO 需传入角色名、角色设定、所属Bot
*/
void
insertIntoRoles
(
RolesDAO
rolesDAO
);
/**
* 修改一个角色的信息(角色名、角色设定、所属Bot)
*
* @param rolesDAO 需传入roleId和待修改的参数
*/
void
updateRoleById
(
RolesDAO
rolesDAO
);
/**
* 删除一个角色
*
* @param rolesDAO 需传入roleId
*/
void
deleteFromRoles
(
RolesDAO
rolesDAO
);
/**
* 获取所有角色的Bot列表(去重)
*/
List
<
String
>
getKnownBots
();
// 审核部分
/**
/**
* 根据审核页面的查询条件取得对应的结果(经过LIMIT和OFFSET)
* 根据审核页面的查询条件取得对应的结果(经过LIMIT和OFFSET)
*/
*/
List
<
AuditDataDAO
>
getAuditData
(
AuditQueryDAO
auditQueryDAO
);
List
<
AuditDataDAO
>
getAuditData
(
AuditQueryDAO
auditQueryDAO
);
/**
/**
* 根据审核页面的查询条件取得对应的结果总数(未经过LIMIT和OFFSET)
* 根据审核页面的查询条件取得对应的结果总数(未经过LIMIT和OFFSET)
*/
*/
Integer
getAuditDataTotal
(
AuditQueryDAO
auditQueryDAO
);
Integer
getAuditDataTotal
(
AuditQueryDAO
auditQueryDAO
);
Integer
putAuditData
(
AuditDataDAO
auditDataDAO
);
/**
* 根据传入的optId,更新这条回答(修改审核状态、提交人工修改后的回答)
*
* @param auditDataDAO 需传入optId
*/
void
putAuditData
(
AuditDataDAO
auditDataDAO
);
/**
* 审核界面上“重新生成”按钮,根据传入的角色名查找对应的人物设定,提供给模型进行生成
* @param rolesDAO 需传入roleId
*/
RolesDAO
getRoleById
(
RolesDAO
rolesDAO
);
RolesDAO
getRoleById
(
RolesDAO
rolesDAO
);
/**
* 审核界面上“删除”按钮,删除这条回答
*
* @param auditDataDAO 需传入optId
*/
void
deleteFromOpt
(
AuditDataDAO
auditDataDAO
);
}
}
src/main/java/qiwu/xfllmdemo/pojo/AuditDataDAO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.apache.ibatis.type.Alias
;
/**
/**
* 审核页面查询响应体中的每条数据 信息结构
* 审核页面查询响应体中的
records[]的
每条数据 信息结构
*/
*/
@Getter
@Setter
@ToString
@Alias
(
value
=
"AuditDataDAO"
)
public
class
AuditDataDAO
{
public
class
AuditDataDAO
{
@JSONField
@JSONField
String
userWords
;
String
userWords
;
@JSONField
@JSONField
int
optId
;
Integer
optId
;
@JSONField
@JSONField
int
intentionId
;
Integer
intentionId
;
@JSONField
@JSONField
int
roleId
;
Integer
roleId
;
@JSONField
@JSONField
String
roleName
;
String
roleName
;
@JSONField
@JSONField
String
reply
;
String
reply
;
@JSONField
@JSONField
short
auditStatus
;
Short
auditStatus
;
@JSONField
public
int
getOptId
()
{
String
fromModel
;
return
optId
;
}
public
void
setOptId
(
int
optId
)
{
this
.
optId
=
optId
;
}
public
String
getUserWords
()
{
return
userWords
;
}
public
void
setUserWords
(
String
userWords
)
{
this
.
userWords
=
userWords
;
}
public
int
getIntentionId
()
{
return
intentionId
;
}
public
void
setIntentionId
(
int
intentionId
)
{
this
.
intentionId
=
intentionId
;
}
public
int
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
int
roleId
)
{
this
.
roleId
=
roleId
;
}
public
String
getRoleName
()
{
return
roleName
;
}
public
void
setRoleName
(
String
roleName
)
{
this
.
roleName
=
roleName
;
}
public
String
getReply
()
{
return
reply
;
}
public
void
setReply
(
String
reply
)
{
this
.
reply
=
reply
;
}
public
short
getAuditStatus
()
{
return
auditStatus
;
}
public
void
setAuditStatus
(
short
auditStatus
)
{
this
.
auditStatus
=
auditStatus
;
}
@Override
public
String
toString
()
{
return
"AuditBO{"
+
"optId="
+
optId
+
", userWords='"
+
userWords
+
'\''
+
", intentionId="
+
intentionId
+
", roleId="
+
roleId
+
", roleName='"
+
roleName
+
'\''
+
", reply='"
+
reply
+
'\''
+
", auditStatus="
+
auditStatus
+
'}'
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/AuditQueryDAO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
lombok.*
;
import
org.apache.ibatis.type.Alias
;
/**
/**
* 审核页面查询请求体 信息结构
* 审核页面查询请求体 信息结构
*/
*/
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Alias
(
value
=
"AuditQueryDAO"
)
public
class
AuditQueryDAO
{
public
class
AuditQueryDAO
{
String
searchText
;
String
searchText
;
Short
auditStatus
;
Short
auditStatus
;
int
offset
;
Integer
offset
;
int
pageSize
;
Integer
pageSize
;
String
sortMethod
;
String
sortMethod
;
String
ofBot
;
public
AuditQueryDAO
()
{
String
ofModel
;
}
public
AuditQueryDAO
(
String
searchText
,
Short
auditStatus
,
int
offset
,
int
pageSize
,
String
sortMethod
)
{
this
.
searchText
=
searchText
;
this
.
auditStatus
=
auditStatus
;
this
.
offset
=
offset
;
this
.
pageSize
=
pageSize
;
this
.
sortMethod
=
sortMethod
;
}
public
String
getSearchText
()
{
return
searchText
;
}
public
void
setSearchText
(
String
searchText
)
{
this
.
searchText
=
searchText
;
}
public
Short
getAuditStatus
()
{
return
auditStatus
;
}
public
void
setAuditStatus
(
Short
auditStatus
)
{
this
.
auditStatus
=
auditStatus
;
}
public
int
getOffset
()
{
return
offset
;
}
public
void
setOffset
(
int
offset
)
{
this
.
offset
=
offset
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
String
getSortMethod
()
{
return
sortMethod
;
}
public
void
setSortMethod
(
String
sortMethod
)
{
this
.
sortMethod
=
sortMethod
;
}
@Override
public
String
toString
()
{
return
"AuditQueryDAO{"
+
"searchText='"
+
searchText
+
'\''
+
", auditStatus='"
+
auditStatus
+
'\''
+
", pageNum='"
+
offset
+
'\''
+
", pageSize='"
+
pageSize
+
'\''
+
", sortMethod='"
+
sortMethod
+
'\''
+
'}'
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/AuditResponseVO.java
View file @
df378329
...
@@ -8,26 +8,29 @@ import lombok.NoArgsConstructor;
...
@@ -8,26 +8,29 @@ import lombok.NoArgsConstructor;
import
java.util.List
;
import
java.util.List
;
/**
* 返回给请求某一页审核页面的信息结构,含回答数据、页数、页面大小
*/
@Data
@Data
@Builder
@Builder
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
public
class
AuditResponseVO
{
public
class
AuditResponseVO
{
@JSONField
@JSONField
public
int
code
=
1
;
public
Integer
code
=
1
;
@JSONField
@JSONField
public
String
msg
=
"成功"
;
public
String
msg
=
"成功"
;
@JSONField
@JSONField
public
Data
data
=
new
Data
();
public
Data
data
=
new
Data
();
public
static
class
Data
{
public
static
class
Data
{
@JSONField
@JSONField
public
int
pages
;
public
Integer
pages
;
@JSONField
@JSONField
public
int
pageNum
;
public
Integer
pageNum
;
@JSONField
@JSONField
public
int
pageSize
;
public
Integer
pageSize
;
@JSONField
@JSONField
public
int
total
;
public
Integer
total
;
@JSONField
@JSONField
public
List
<
AuditDataDAO
>
records
;
public
List
<
AuditDataDAO
>
records
;
}
}
...
...
src/main/java/qiwu/xfllmdemo/pojo/DialogueVO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
/**
* 当前仅用于测试时输出结果
* 当前仅用于测试时输出结果
*/
*/
@Getter
@Setter
@ToString
public
class
DialogueVO
{
public
class
DialogueVO
{
String
user_words
;
String
user_words
;
int
intention_id
;
Integer
intention_id
;
String
reply
;
String
reply
;
public
DialogueVO
()
{}
public
DialogueVO
()
{}
public
DialogueVO
(
String
user_words
,
int
intention_id
)
{
public
DialogueVO
(
String
user_words
,
Integer
intention_id
)
{
this
.
user_words
=
user_words
;
this
.
user_words
=
user_words
;
this
.
intention_id
=
intention_id
;
this
.
intention_id
=
intention_id
;
}
}
public
DialogueVO
(
String
user_words
,
int
intention_id
,
String
reply
)
{
public
DialogueVO
(
String
user_words
,
Integer
intention_id
,
String
reply
)
{
this
.
user_words
=
user_words
;
this
.
user_words
=
user_words
;
this
.
intention_id
=
intention_id
;
this
.
intention_id
=
intention_id
;
this
.
reply
=
reply
;
this
.
reply
=
reply
;
}
}
@Override
public
String
toString
()
{
return
"DialogueVO{"
+
"user_words='"
+
user_words
+
'\''
+
", intention_id="
+
intention_id
+
", \nreply='"
+
reply
+
'\''
+
'}'
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/GenParamsVO.java
0 → 100644
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* 请求模型生成回答所需的参数 信息结构
*/
@Getter
@Setter
@ToString
public
class
GenParamsVO
{
@JSONField
Integer
roleId
;
@JSONField
String
roleInfo
;
@JSONField
String
botAccount
;
@JSONField
String
usingModel
;
}
src/main/java/qiwu/xfllmdemo/pojo/IntentionDAO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.apache.ibatis.type.Alias
;
/**
/**
* intention表 信息结构
* intention表 信息结构
*/
*/
@Getter
@Setter
@ToString
@Alias
(
value
=
"IntentionDAO"
)
public
class
IntentionDAO
{
public
class
IntentionDAO
{
int
id
;
Integer
id
;
String
userWords
;
String
userWords
;
int
intentionId
;
Integer
intentionId
;
int
roleId
;
String
botAccount
;
public
IntentionDAO
(
String
userWords
,
int
intentionId
)
{
public
IntentionDAO
(
String
userWords
,
Integer
intentionId
,
String
botAccount
)
{
this
.
userWords
=
userWords
;
this
.
userWords
=
userWords
;
this
.
intentionId
=
intentionId
;
this
.
intentionId
=
intentionId
;
}
this
.
botAccount
=
botAccount
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getUserWords
()
{
return
userWords
;
}
public
void
setUserWords
(
String
userWords
)
{
this
.
userWords
=
userWords
;
}
public
int
getIntentionId
()
{
return
intentionId
;
}
public
void
setIntentionId
(
int
intentionId
)
{
this
.
intentionId
=
intentionId
;
}
public
int
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
int
roleId
)
{
this
.
roleId
=
roleId
;
}
@Override
public
String
toString
()
{
return
"IntentionDAO{"
+
"id="
+
id
+
", userWords='"
+
userWords
+
'\''
+
", intentionId="
+
intentionId
+
", roleId="
+
roleId
+
'}'
;
}
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/LLMAnswerVO.java
View file @
df378329
...
@@ -2,6 +2,9 @@ package qiwu.xfllmdemo.pojo;
...
@@ -2,6 +2,9 @@ package qiwu.xfllmdemo.pojo;
import
java.util.UUID
;
import
java.util.UUID
;
/**
* 讯飞星火 对某一句用户话语请求的回复
*/
public
class
LLMAnswerVO
{
public
class
LLMAnswerVO
{
public
UUID
userID
;
public
UUID
userID
;
public
String
answer
;
public
String
answer
;
...
@@ -11,8 +14,4 @@ public class LLMAnswerVO {
...
@@ -11,8 +14,4 @@ public class LLMAnswerVO {
this
.
userID
=
userID
;
this
.
userID
=
userID
;
this
.
answer
=
answer
;
this
.
answer
=
answer
;
}
}
public
LLMAnswerVO
(
QueryResponseVO
queryResponseVO
)
{
this
.
userID
=
queryResponseVO
.
userID
;
this
.
answer
=
queryResponseVO
.
answer
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/LLMQueryVO.java
View file @
df378329
...
@@ -2,6 +2,9 @@ package qiwu.xfllmdemo.pojo;
...
@@ -2,6 +2,9 @@ package qiwu.xfllmdemo.pojo;
import
java.util.UUID
;
import
java.util.UUID
;
/**
* 讯飞星火 对某一句用户话语发起的请求
*/
public
class
LLMQueryVO
{
public
class
LLMQueryVO
{
public
UUID
userID
;
public
UUID
userID
;
public
String
question
;
public
String
question
;
...
@@ -11,8 +14,4 @@ public class LLMQueryVO {
...
@@ -11,8 +14,4 @@ public class LLMQueryVO {
this
.
userID
=
userID
;
this
.
userID
=
userID
;
this
.
question
=
question
;
this
.
question
=
question
;
}
}
public
LLMQueryVO
(
QueryRequestVO
queryRequestVO
)
{
this
.
userID
=
queryRequestVO
.
userID
;
this
.
question
=
queryRequestVO
.
question
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/LLMRequestVO.java
View file @
df378329
...
@@ -10,7 +10,7 @@ import java.util.ArrayList;
...
@@ -10,7 +10,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 请求模型接口时的JSON格式
* 请求
讯飞星火
模型接口时的JSON格式
*/
*/
@Data
@Data
@Builder
@Builder
...
@@ -59,12 +59,12 @@ public class LLMRequestVO {
...
@@ -59,12 +59,12 @@ public class LLMRequestVO {
* 模型回答的tokens的最大长度 - 非必须,取值为[1,4096],默认2048
* 模型回答的tokens的最大长度 - 非必须,取值为[1,4096],默认2048
*/
*/
@JSONField
@JSONField
public
int
max_tokens
=
1024
;
public
Integer
max_tokens
=
1024
;
/**
/**
* 从k个候选中随机选择⼀个(⾮等概率) - 非必须,取值为[1,6],默认4
* 从k个候选中随机选择⼀个(⾮等概率) - 非必须,取值为[1,6],默认4
*/
*/
@JSONField
@JSONField
public
int
top_k
=
4
;
public
Integer
top_k
=
4
;
/**
/**
* 用于关联用户会话 - 非必须,需要保障用户下的唯一性
* 用于关联用户会话 - 非必须,需要保障用户下的唯一性
*/
*/
...
@@ -76,6 +76,7 @@ public class LLMRequestVO {
...
@@ -76,6 +76,7 @@ public class LLMRequestVO {
@JSONField
@JSONField
public
Payload
payload
=
new
Payload
();
public
Payload
payload
=
new
Payload
();
@Data
public
static
class
Payload
{
public
static
class
Payload
{
@JSONField
@JSONField
public
Message
message
=
new
Message
();
public
Message
message
=
new
Message
();
...
...
src/main/java/qiwu/xfllmdemo/pojo/LLMResponseVO.java
View file @
df378329
...
@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
...
@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 模型接口返回的JSON格式
*
讯飞星火
模型接口返回的JSON格式
* 接口为流式返回(一次Request对应多次Response),开发者需要将接口多次返回的结果进行拼接展示
* 接口为流式返回(一次Request对应多次Response),开发者需要将接口多次返回的结果进行拼接展示
*/
*/
@Data
@Data
...
@@ -28,7 +28,7 @@ public class LLMResponseVO {
...
@@ -28,7 +28,7 @@ public class LLMResponseVO {
* 错误码,0表示正常,非0表示出错
* 错误码,0表示正常,非0表示出错
*/
*/
@JSONField
@JSONField
public
int
code
;
public
Integer
code
;
/**
/**
* 会话是否成功的描述信息
* 会话是否成功的描述信息
*/
*/
...
@@ -43,7 +43,7 @@ public class LLMResponseVO {
...
@@ -43,7 +43,7 @@ public class LLMResponseVO {
* 会话状态,取值为[0,1,2];0代表首次结果;1代表中间结果;2代表最后一个结果
* 会话状态,取值为[0,1,2];0代表首次结果;1代表中间结果;2代表最后一个结果
*/
*/
@JSONField
@JSONField
public
int
status
;
public
Integer
status
;
}
}
@JSONField
@JSONField
...
@@ -60,12 +60,12 @@ public class LLMResponseVO {
...
@@ -60,12 +60,12 @@ public class LLMResponseVO {
* 文本响应状态,取值为[0,1,2]; 0代表首个文本结果;1代表中间文本结果;2代表最后一个文本结果
* 文本响应状态,取值为[0,1,2]; 0代表首个文本结果;1代表中间文本结果;2代表最后一个文本结果
*/
*/
@JSONField
@JSONField
public
int
status
;
public
Integer
status
;
/**
/**
* 返回的数据序号,取值为[0,9999999]
* 返回的数据序号,取值为[0,9999999]
*/
*/
@JSONField
@JSONField
public
int
seq
;
public
Integer
seq
;
@JSONField
@JSONField
public
List
<
Text
>
text
;
public
List
<
Text
>
text
;
...
@@ -85,7 +85,7 @@ public class LLMResponseVO {
...
@@ -85,7 +85,7 @@ public class LLMResponseVO {
* 结果序号,取值为[0,10]; 当前为保留字段,开发者可忽略
* 结果序号,取值为[0,10]; 当前为保留字段,开发者可忽略
*/
*/
@JSONField
@JSONField
public
int
index
;
public
Integer
index
;
}
}
}
}
...
@@ -98,22 +98,22 @@ public class LLMResponseVO {
...
@@ -98,22 +98,22 @@ public class LLMResponseVO {
* 保留字段,可忽略
* 保留字段,可忽略
*/
*/
@JSONField
@JSONField
public
int
question_tokens
;
public
Integer
question_tokens
;
/**
/**
* 包含历史问题的总tokens大小
* 包含历史问题的总tokens大小
*/
*/
@JSONField
@JSONField
public
int
prompt_tokens
;
public
Integer
prompt_tokens
;
/**
/**
* 回答的tokens大小
* 回答的tokens大小
*/
*/
@JSONField
@JSONField
public
int
completion_tokens
;
public
Integer
completion_tokens
;
/**
/**
* prompt_tokens和completion_tokens之和,即本次交互计费的tokens大小
* prompt_tokens和completion_tokens之和,即本次交互计费的tokens大小
*/
*/
@JSONField
@JSONField
public
int
total_tokens
;
public
Integer
total_tokens
;
}
}
}
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/OptDAO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.apache.ibatis.type.Alias
;
/**
/**
* opt表 信息结构
* opt表 信息结构
*/
*/
@Getter
@Setter
@ToString
@Alias
(
value
=
"OptDAO"
)
public
class
OptDAO
{
public
class
OptDAO
{
int
id
;
Integer
id
;
int
intentionId
;
Integer
intentionId
;
String
reply
;
String
reply
;
/**
/**
* 0未审核,1审核通过,2审核不通过
* 0未审核,1审核通过,2审核不通过
*/
*/
short
auditStatus
=
0
;
Short
auditStatus
=
0
;
int
roleId
;
Integer
roleId
;
String
fromModel
;
public
OptDAO
(
int
intentionId
,
String
reply
)
{
this
.
intentionId
=
intentionId
;
this
.
reply
=
reply
;
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getIntentionId
()
{
public
OptDAO
(
Integer
intentionId
,
String
reply
,
Integer
roleId
,
String
fromModel
)
{
return
intentionId
;
}
public
void
setIntentionId
(
int
intentionId
)
{
this
.
intentionId
=
intentionId
;
this
.
intentionId
=
intentionId
;
}
public
String
getReply
()
{
return
reply
;
}
public
void
setReply
(
String
reply
)
{
this
.
reply
=
reply
;
this
.
reply
=
reply
;
}
public
short
getAuditStatus
()
{
return
auditStatus
;
}
public
void
setAuditStatus
(
short
auditStatus
)
{
this
.
auditStatus
=
auditStatus
;
}
public
int
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
int
roleId
)
{
this
.
roleId
=
roleId
;
this
.
roleId
=
roleId
;
this
.
fromModel
=
fromModel
;
}
}
@Override
public
String
toString
()
{
return
"OptDAO{"
+
"id="
+
id
+
", intentionId="
+
intentionId
+
", reply='"
+
reply
+
'\''
+
", auditStatus="
+
auditStatus
+
", roleId="
+
roleId
+
'}'
;
}
}
}
src/main/java/qiwu/xfllmdemo/pojo/QueryRequestVO.java
deleted
100644 → 0
View file @
4bbe7675
package
qiwu
.
xfllmdemo
.
pojo
;
import
java.util.UUID
;
public
class
QueryRequestVO
{
public
UUID
userID
;
public
String
question
;
public
QueryRequestVO
()
{
}
public
QueryRequestVO
(
UUID
userID
,
String
question
)
{
this
.
userID
=
userID
;
this
.
question
=
question
;
}
public
QueryRequestVO
(
LLMQueryVO
llmQueryVO
)
{
this
.
userID
=
llmQueryVO
.
userID
;
this
.
question
=
llmQueryVO
.
question
;
}
}
src/main/java/qiwu/xfllmdemo/pojo/QueryResponseVO.java
deleted
100644 → 0
View file @
4bbe7675
package
qiwu
.
xfllmdemo
.
pojo
;
import
java.util.UUID
;
public
class
QueryResponseVO
{
public
UUID
userID
;
public
String
answer
;
public
QueryResponseVO
()
{
}
public
QueryResponseVO
(
UUID
userID
,
String
answer
)
{
this
.
userID
=
userID
;
this
.
answer
=
answer
;
}
public
QueryResponseVO
(
LLMAnswerVO
llmAnswerVO
)
{
this
.
userID
=
llmAnswerVO
.
userID
;
this
.
answer
=
llmAnswerVO
.
answer
;
}
}
src/main/java/qiwu/xfllmdemo/pojo/RolesDAO.java
View file @
df378329
package
qiwu
.
xfllmdemo
.
pojo
;
package
qiwu
.
xfllmdemo
.
pojo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.apache.ibatis.type.Alias
;
/**
/**
* roles表 信息结构
* roles表 信息结构
*/
*/
@Getter
@Setter
@ToString
@Alias
(
value
=
"RolesDAO"
)
public
class
RolesDAO
{
public
class
RolesDAO
{
int
id
;
Integer
id
;
String
roleName
;
String
roleName
;
String
roleInfo
;
String
roleInfo
;
String
botAccount
;
public
int
getId
()
{
String
fromModel
;
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getRoleName
()
{
return
roleName
;
}
public
void
setRoleName
(
String
roleName
)
{
this
.
roleName
=
roleName
;
}
public
String
getRoleInfo
()
{
return
roleInfo
;
}
public
void
setRoleInfo
(
String
roleInfo
)
{
this
.
roleInfo
=
roleInfo
;
}
@Override
public
String
toString
()
{
return
"RoleDAO{"
+
"id="
+
id
+
", roleName='"
+
roleName
+
'\''
+
", roleInfo='"
+
roleInfo
+
'\''
+
'}'
;
}
}
}
src/main/java/qiwu/xfllmdemo/service/LLMService.java
View file @
df378329
...
@@ -26,7 +26,8 @@ public class LLMService {
...
@@ -26,7 +26,8 @@ public class LLMService {
/**
/**
* 所有用户的对话历史列表,<userID, 历史对话List>
* 所有用户的对话历史列表,<userID, 历史对话List>
*/
*/
static
HashMap
<
UUID
,
List
<
Message
.
Text
>>
chatHistory
;
// TODO 前端 清空历史对话按钮?
// static ArrayList<UUID> userList;
// static ArrayList<UUID> userList;
static
final
String
appid
=
"76f57fca"
;
static
final
String
appid
=
"76f57fca"
;
static
final
String
apiSecret
=
"ZGFiZDAxMWVkM2I5ZDg0YzJhMzVjMjc0"
;
static
final
String
apiSecret
=
"ZGFiZDAxMWVkM2I5ZDg0YzJhMzVjMjc0"
;
...
@@ -77,26 +78,25 @@ public class LLMService {
...
@@ -77,26 +78,25 @@ public class LLMService {
}
}
}
}
public
LLMService
()
{
public
LLMService
()
{}
chatHistory
=
new
HashMap
<>();
}
/**
/**
* 根据对话ID(用户ID)和用户话语发起请求
* 根据对话ID(用户ID)和用户话语发起一次请求
* @param chatHistory 本次请求的对话历史
* @param inVO 本次请求的对话ID(用户ID)和用户话语
* @param inVO 本次请求的对话ID(用户ID)和用户话语
* @param modelVersion 要请求的模型版本 1:v1.5,2:v2
* @param modelVersion 要请求的模型版本 1:v1.5,2:v2
* @param addToHistory 请求时是否
发送
历史对话
* @param addToHistory 请求时是否
将本次的用户话语加入到
历史对话
* @return 本次请求的对话ID(用户ID)和模型的回复
* @return 本次请求的对话ID(用户ID)和模型的回复
*/
*/
public
LLMAnswerVO
query
(
LLMQueryVO
inVO
,
int
modelVersion
,
boolean
addToHistory
)
throws
Exception
{
public
LLMAnswerVO
query
(
HashMap
<
UUID
,
List
<
Message
.
Text
>>
chatHistory
,
LLMQueryVO
inVO
,
int
modelVersion
,
boolean
addToHistory
)
throws
Exception
{
//
TODO 1. 根据入参获得
用户id和对话历史
//
1. 根据入参获得本次请求的
用户id和对话历史
List
<
Message
.
Text
>
thisHistory
=
chatHistory
.
get
(
inVO
.
userID
);
List
<
Message
.
Text
>
thisHistory
=
chatHistory
.
get
(
inVO
.
userID
);
if
(
thisHistory
==
null
)
{
if
(
thisHistory
==
null
)
{
// outVO = UUID.randomUUID().toString().substring(0, 10);
// outVO = UUID.randomUUID().toString().substring(0, 10);
thisHistory
=
new
LinkedList
<
Message
.
Text
>();
thisHistory
=
new
LinkedList
<
Message
.
Text
>();
chatHistory
.
put
(
inVO
.
userID
,
thisHistory
);
chatHistory
.
put
(
inVO
.
userID
,
thisHistory
);
}
}
//
TODO
2. 构造模型请求JSON,将问题添加到对话历史
// 2. 构造模型请求JSON,将问题添加到对话历史
LLMRequestVO
toReq
=
new
LLMRequestVO
();
LLMRequestVO
toReq
=
new
LLMRequestVO
();
toReq
.
header
.
app_id
=
appid
;
toReq
.
header
.
app_id
=
appid
;
toReq
.
header
.
uid
=
inVO
.
userID
.
toString
().
substring
(
0
,
20
);
toReq
.
header
.
uid
=
inVO
.
userID
.
toString
().
substring
(
0
,
20
);
...
@@ -109,7 +109,7 @@ public class LLMService {
...
@@ -109,7 +109,7 @@ public class LLMService {
}
}
toReq
.
parameter
.
chat
.
chat_id
=
inVO
.
userID
.
toString
();
// 以UUID区分用户
toReq
.
parameter
.
chat
.
chat_id
=
inVO
.
userID
.
toString
();
// 以UUID区分用户
Message
.
Text
thisTimeWords
=
new
Message
.
Text
(
"user"
,
inVO
.
question
);
Message
.
Text
thisTimeWords
=
new
Message
.
Text
(
"user"
,
inVO
.
question
);
//
TODO
on addToHistory
// on addToHistory
if
(
addToHistory
)
{
if
(
addToHistory
)
{
thisHistory
.
add
(
thisTimeWords
);
thisHistory
.
add
(
thisTimeWords
);
toReq
.
payload
.
message
.
text
=
thisHistory
;
toReq
.
payload
.
message
.
text
=
thisHistory
;
...
@@ -122,11 +122,11 @@ public class LLMService {
...
@@ -122,11 +122,11 @@ public class LLMService {
// Test
// Test
// System.out.println("------\n" + "toReqJSON: \n" + toReqJSON);
// System.out.println("------\n" + "toReqJSON: \n" + toReqJSON);
// System.out.println("authURL: \n" + authURL + "\n------");
// System.out.println("authURL: \n" + authURL + "\n------");
//
TODO
3. 发起请求,获得回复,将回复添加到对话历史,返回
// 3. 发起请求,获得回复,将回复添加到对话历史,返回
genAuthURL
(
modelVersion
);
// 时间戳偏差需控制在300s范围内,故每次请求都需要调用
genAuthURL
(
modelVersion
);
// 时间戳偏差需控制在300s范围内,故每次请求都需要调用
LLMSocket
llmSocket
=
new
LLMSocket
(
authURL
,
toReqJSON
);
LLMSocket
llmSocket
=
new
LLMSocket
(
authURL
,
toReqJSON
);
String
thisAnswer
=
llmSocket
.
executeQuery
().
toString
();
String
thisAnswer
=
llmSocket
.
executeQuery
().
toString
();
//
TODO
on addToHistory
// on addToHistory
if
(
addToHistory
)
{
if
(
addToHistory
)
{
thisHistory
.
add
(
new
Message
.
Text
(
"assistant"
,
thisAnswer
));
thisHistory
.
add
(
new
Message
.
Text
(
"assistant"
,
thisAnswer
));
}
}
...
@@ -204,8 +204,6 @@ class LLMSocket extends WebSocketListener {
...
@@ -204,8 +204,6 @@ class LLMSocket extends WebSocketListener {
/**
/**
* WebSocket连接建立后,启动线程,托管webSocket(等待关闭时机)
* WebSocket连接建立后,启动线程,托管webSocket(等待关闭时机)
* @param webSocket
* @param response
*/
*/
@Override
@Override
public
void
onOpen
(
@NotNull
WebSocket
webSocket
,
@NotNull
Response
response
)
{
public
void
onOpen
(
@NotNull
WebSocket
webSocket
,
@NotNull
Response
response
)
{
...
@@ -217,8 +215,6 @@ class LLMSocket extends WebSocketListener {
...
@@ -217,8 +215,6 @@ class LLMSocket extends WebSocketListener {
/**
/**
* 收到一个Response执行一次
* 收到一个Response执行一次
* @param webSocket
* @param text
*/
*/
@Override
@Override
public
synchronized
void
onMessage
(
@NotNull
WebSocket
webSocket
,
@NotNull
String
text
)
{
public
synchronized
void
onMessage
(
@NotNull
WebSocket
webSocket
,
@NotNull
String
text
)
{
...
@@ -228,7 +224,7 @@ class LLMSocket extends WebSocketListener {
...
@@ -228,7 +224,7 @@ class LLMSocket extends WebSocketListener {
threadNum
++;
threadNum
++;
// Test
// Test
// System.out.println("LLMResponseJSON: " + text);
// System.out.println("LLMResponseJSON: " + text);
//
TODO
1. 解析返回的JSON,若出错处理
// 1. 解析返回的JSON,若出错处理
// 使用JSON.parseObject()时注意,传入的class中每个属性的类型必须与JSON字符串中严格相同,否则方法会阻塞且不会有任何异常抛出
// 使用JSON.parseObject()时注意,传入的class中每个属性的类型必须与JSON字符串中严格相同,否则方法会阻塞且不会有任何异常抛出
LLMResponseVO
responseVO
=
JSON
.
parseObject
(
text
,
LLMResponseVO
.
class
);
LLMResponseVO
responseVO
=
JSON
.
parseObject
(
text
,
LLMResponseVO
.
class
);
if
(
responseVO
.
header
.
code
!=
0
)
{
if
(
responseVO
.
header
.
code
!=
0
)
{
...
@@ -239,11 +235,11 @@ class LLMSocket extends WebSocketListener {
...
@@ -239,11 +235,11 @@ class LLMSocket extends WebSocketListener {
}
}
// Test
// Test
// System.out.println("responseVO: " + responseVO);
// System.out.println("responseVO: " + responseVO);
//
TODO
2. 提取其中的回答串
// 2. 提取其中的回答串
List
<
Choices
.
Text
>
textList
=
responseVO
.
payload
.
choices
.
text
;
List
<
Choices
.
Text
>
textList
=
responseVO
.
payload
.
choices
.
text
;
// Test
// Test
// System.out.println("textList.size(): " + textList.size());
// System.out.println("textList.size(): " + textList.size());
//
TODO
3. 拼接形成完整回答串 每个Response的test里面只有一个元素
// 3. 拼接形成完整回答串 每个Response的test里面只有一个元素
for
(
Choices
.
Text
temp
:
textList
)
{
for
(
Choices
.
Text
temp
:
textList
)
{
// System.out.println("temp.content: " + temp.content);
// System.out.println("temp.content: " + temp.content);
outBuffer
.
append
(
temp
.
content
);
outBuffer
.
append
(
temp
.
content
);
...
@@ -268,7 +264,6 @@ class LLMSocket extends WebSocketListener {
...
@@ -268,7 +264,6 @@ class LLMSocket extends WebSocketListener {
}
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
...
...
src/main/java/qiwu/xfllmdemo/utils/BigModelNew.java
View file @
df378329
...
@@ -148,7 +148,6 @@ public class BigModelNew extends WebSocketListener {
...
@@ -148,7 +148,6 @@ public class BigModelNew extends WebSocketListener {
}
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
...
...
src/main/resources/application.yml
View file @
df378329
server
:
server
:
port
:
8080
port
:
47001
tomcat
:
tomcat
:
uri-encoding
:
UTF-8
uri-encoding
:
UTF-8
max-http-header-size
:
8192
max-http-header-size
:
8192
...
@@ -8,37 +8,38 @@ spring:
...
@@ -8,37 +8,38 @@ spring:
datasource
:
datasource
:
url
:
jdbc:mysql://localhost:3306/chitchat?serverTimezone=Asia/Shanghai&characterEncoding=utf-8
url
:
jdbc:mysql://localhost:3306/chitchat?serverTimezone=Asia/Shanghai&characterEncoding=utf-8
username
:
chatter
username
:
chatter
password
:
7890-=
password
:
dgKNTmt2iLHNjEQajkDEZkq8
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
data
:
#
data:
redis
:
#
redis:
database
:
0
#
database: 0
host
:
localhost
#
host: localhost
port
:
6379
#
port: 6379
# password:
#
# password:
#配置jedis客户端,这里也可以jedis替换为lettuce客户端,下级配置都一样
#
#配置jedis客户端,这里也可以jedis替换为lettuce客户端,下级配置都一样
jedis
:
#
jedis:
pool
:
#
pool:
# 连接池中的最大空闲连接 默认8
#
# 连接池中的最大空闲连接 默认8
max-idle
:
8
#
max-idle: 8
# 连接池中的最小空闲连接 默认0
#
# 连接池中的最小空闲连接 默认0
min-idle
:
0
#
min-idle: 0
# 连接池最大连接数 默认8 ,负数表示没有限制
#
# 连接池最大连接数 默认8 ,负数表示没有限制
max-active
:
8
#
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
#
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
max-wait
:
-1
#
max-wait: -1
timeout
:
3000
#
timeout: 3000
cache
:
#
cache:
type
:
redis
# 指定使用的缓存类型
#
type: redis # 指定使用的缓存类型
# redis: 当自定义CacheManager时,这里的配置不起作用
#
# redis: 当自定义CacheManager时,这里的配置不起作用
# use-key-prefix: true
#
# use-key-prefix: true
# key-prefix: "demo:"
#
# key-prefix: "demo:"
# time-to-live: 60000 #缓存超时时间 单位:ms
#
# time-to-live: 60000 #缓存超时时间 单位:ms
# cache-null-values: false #是否缓存空值
#
# cache-null-values: false #是否缓存空值
cache-names
:
user
#
cache-names: user
# 公共配置,与profiles选择无关
# 公共配置,与profiles选择无关
mybatis
:
mybatis
:
# TODO 复制到别的项目记得改这里!!!否则显式指定的类型别名和注解均不会生效
type-aliases-package
:
qiwu.xfllmdemo.pojo
type-aliases-package
:
qiwu.xfllmdemo.pojo
mapper-locations
:
classpath:mapper/*.xml
mapper-locations
:
classpath:mapper/*.xml
# 开启MyBatis的二级缓存
# 开启MyBatis的二级缓存
...
...
src/main/resources/mapper/DBMapper.xml
View file @
df378329
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- TODO 复制到别的项目记得改这里!!! -->
<mapper
namespace=
"qiwu.xfllmdemo.mapper.DBMapper"
>
<mapper
namespace=
"qiwu.xfllmdemo.mapper.DBMapper"
>
<!-- 预生成部分 -->
<!-- 预生成部分 -->
<!-- project_name as projectName -->
<!-- project_name as projectName -->
<select
id=
"getMaxIntentionID"
resultType=
"
int
"
>
<select
id=
"getMaxIntentionID"
resultType=
"
Integer
"
>
SELECT max(intention_id)
SELECT max(intention_id)
FROM intention
FROM intention
</select>
</select>
<!-- 返回值:成功插入的行数? -->
<!-- 返回值:成功插入的行数? -->
<insert
id=
"insertIntoIntention"
parameterType=
"List"
>
<insert
id=
"insertIntoIntention"
parameterType=
"List"
>
INSERT INTO intention (user_words, intention_id,
role_id
)
INSERT INTO intention (user_words, intention_id,
bot_account
)
VALUES
VALUES
<foreach
collection=
"list"
index=
"index"
item=
"item"
separator=
","
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
separator=
","
>
(#{item.userWords
, jdbcType=VARCHAR}, #{item.intentionId, jdbcType=INTEGER}, null
)
(#{item.userWords
}, #{item.intentionId}, #{item.botAccount}
)
</foreach>
</foreach>
</insert>
</insert>
<insert
id=
"insertIntoOpt"
parameterType=
"List"
>
<insert
id=
"insertIntoOpt"
parameterType=
"List"
>
INSERT INTO opt (intention_id, reply, audit_status, role_id)
INSERT INTO opt (intention_id, reply, audit_status, role_id
, from_model
)
VALUES
VALUES
<foreach
collection=
"list"
index=
"index"
item=
"item"
separator=
","
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
separator=
","
>
(#{item.intentionId, jdbcType=INTEGER}, #{item.reply, jdbcType=VARCHAR},
(#{item.intentionId, jdbcType=INTEGER}, #{item.reply, jdbcType=VARCHAR},
#{item.auditStatus, jdbcType=TINYINT}, null)
#{item.auditStatus, jdbcType=TINYINT}, #{item.roleId, , jdbcType=INTEGER},
#{item.fromModel, jdbcType=VARCHAR})
</foreach>
</foreach>
</insert>
</insert>
<insert
id=
"insertIntoRole"
parameterType=
"RolesDAO"
>
INSERT INTO opt (role_name, role_info)
<select
id=
"getRoleIdByUWBA"
resultType=
"Integer"
>
VALUES (#{roleName, jdbcType=VARCHAR}, #{roleInfo, jdbcType=VARCHAR})
SELECT intention_id
FROM intention
WHERE user_words = #{userWords} AND bot_account = #{botAccount}
</select>
<select
id=
"getRoleList"
parameterType=
"RolesDAO"
>
SELECT id AS id,
role_name AS roleName,
role_info AS roleInfo,
bot_account AS botAccount
FROM roles
</select>
<select
id=
"getKnownBots"
resultType=
"String"
>
SELECT DISTINCT roles.bot_account
FROM roles
</select>
<insert
id=
"insertIntoRoles"
parameterType=
"RolesDAO"
>
INSERT INTO roles (role_name, role_info, bot_account)
VALUES (#{roleName}, #{roleInfo}, #{botAccount})
</insert>
</insert>
<!-- role_name 具有唯一约束,若有重复角色名则会有DBException -->
<update
id=
"updateRoleById"
parameterType=
"RolesDAO"
>
UPDATE roles
SET role_name = #{roleName},
role_info = #{roleInfo},
bot_account = #{botAccount}
WHERE id = #{id}
</update>
<!-- TODO 若涉及删除角色,则需要重新配置数据库外键约束,设置级联删除等 -->
<delete
id=
"deleteFromRoles"
parameterType=
"RolesDAO"
>
DELETE FROM roles
WHERE id = #{id}
</delete>
<!-- 审核部分 -->
<!-- 审核部分 -->
<select
id=
"getAuditData"
parameterType=
"AuditQueryDAO"
resultType=
"AuditDataDAO"
>
<select
id=
"getAuditData"
parameterType=
"AuditQueryDAO"
resultType=
"AuditDataDAO"
>
SELECT intention.user_words as userWords, opt.id as optId, intention.intention_id as intentionId,
SELECT intention.user_words as userWords, opt.id as optId, intention.intention_id as intentionId,
roles.id as roleId, roles.role_name as roleName, opt.reply as reply,
opt.audit_status as auditStatus
roles.id as roleId, roles.role_name as roleName, opt.reply as reply,
FROM intention JOIN roles ON intention.role_id = roles.id
opt.audit_status as auditStatus, opt.from_model as fromModel
JOIN opt ON intention.intention_id = opt.intention_id
FROM intention LEFT OUTER
JOIN opt ON intention.intention_id = opt.intention_id
WHERE (intention.user_words LIKE '%${searchText}%'
JOIN roles ON opt.role_id = roles.id
OR roles.role_name = #{searchText})
WHERE (intention.user_words LIKE '%${searchText}%'
OR roles.role_name = #{searchText})
<if
test=
'auditStatus != null'
>
<if
test=
'auditStatus != null'
>
AND opt.audit_status = #{auditStatus}
AND opt.audit_status = #{auditStatus}
</if>
</if>
<if
test=
'ofBot != ""'
>
AND roles.bot_account = #{ofBot}
</if>
<if
test=
'ofModel != ""'
>
AND opt.from_model = #{ofModel}
</if>
<if
test=
'sortMethod != ""'
>
<!-- 按角色ID和意图ID排序 -->
<if
test=
'sortMethod != ""'
>
<!-- 按角色ID和意图ID排序 -->
ORDER BY roles.id, intention.intention_id ${sortMethod}
ORDER BY roles.id, intention.intention_id ${sortMethod}
</if>
</if>
...
@@ -53,13 +97,18 @@
...
@@ -53,13 +97,18 @@
<select
id=
"getAuditDataTotal"
parameterType=
"AuditQueryDAO"
resultType=
"Integer"
>
<select
id=
"getAuditDataTotal"
parameterType=
"AuditQueryDAO"
resultType=
"Integer"
>
SELECT COUNT(*)
SELECT COUNT(*)
FROM intention JOIN roles ON intention.role_id = roles.id
FROM intention LEFT OUTER JOIN opt ON intention.intention_id = opt.intention_id
JOIN opt ON intention.intention_id = opt.intention_id
JOIN roles ON opt.role_id = roles.id
WHERE (intention.user_words LIKE '%${searchText}%'
WHERE (intention.user_words LIKE '%${searchText}%' OR roles.role_name = '${searchText}')
OR roles.role_name = '${searchText}')
<if
test=
'auditStatus != null'
>
<if
test=
'auditStatus != null'
>
AND opt.audit_status = #{auditStatus}
AND opt.audit_status = #{auditStatus}
</if>
</if>
<if
test=
'ofBot != ""'
>
AND roles.bot_account = #{ofBot}
</if>
<if
test=
'ofModel != ""'
>
AND opt.from_model = #{ofModel}
</if>
</select>
</select>
<update
id=
"putAuditData"
parameterType=
"AuditDataDAO"
>
<update
id=
"putAuditData"
parameterType=
"AuditDataDAO"
>
...
@@ -74,19 +123,10 @@
...
@@ -74,19 +123,10 @@
FROM roles
FROM roles
WHERE id = #{id}
WHERE id = #{id}
</select>
</select>
<!-- <!– –>-->
<!-- <update id="updateProjectInfoByPrimaryKey" parameterType="ProjectEntity">-->
<delete
id=
"deleteFromOpt"
parameterType=
"AuditDataDAO"
>
<!-- UPDATE project_info-->
DELETE FROM opt
<!-- SET project_name = #{projectName, jdbcType=VARCHAR},-->
WHERE id = #{optId}
<!-- project_content = #{projectContent, jdbcType=VARCHAR},-->
</delete>
<!-- last_updated_by = #{lastUpdatedBy, jdbcType=VARCHAR},-->
<!-- last_update_date = #{lastUpdateDate, jdbcType=TIMESTAMP}-->
<!-- WHERE id = #{id, jdbcType=VARCHAR}-->
<!-- </update>-->
<!-- <!– –>-->
<!-- <delete id="deleteProjectById" parameterType="ProjectEntity">-->
<!-- DELETE FROM project_info-->
<!-- WHERE id = #{id, jdbcType=VARCHAR}-->
<!-- </delete>-->
</mapper>
</mapper>
src/main/resources/mybatis-config.xml
View file @
df378329
...
@@ -12,14 +12,10 @@
...
@@ -12,14 +12,10 @@
<typeAlias
type=
"java.lang.Integer"
alias=
"Integer"
/>
<typeAlias
type=
"java.lang.Integer"
alias=
"Integer"
/>
<typeAlias
type=
"java.util.List"
alias=
"List"
/>
<typeAlias
type=
"java.util.List"
alias=
"List"
/>
<typeAlias
type=
"java.util.Date"
alias=
"Date"
/>
<typeAlias
type=
"java.util.Date"
alias=
"Date"
/>
<typeAlias
type=
"qiwu.xfllmdemo.pojo.IntentionDAO"
alias=
"IntentionDAO"
/>
<typeAlias
type=
"qiwu.xfllmdemo.pojo.OptDAO"
alias=
"OptDAO"
/>
<typeAlias
type=
"qiwu.xfllmdemo.pojo.RolesDAO"
alias=
"RolesDAO"
/>
<typeAlias
type=
"qiwu.xfllmdemo.pojo.AuditDataDAO"
alias=
"AuditDataDAO"
/>
<typeAlias
type=
"qiwu.xfllmdemo.pojo.AuditQueryDAO"
alias=
"AuditQueryDAO"
/>
<!-- 2.可以指定一个包名,MyBatis会在包名下搜索每一个 Java Bean -->
<!-- 2.可以指定一个包名,MyBatis会在包名下搜索每一个 Java Bean -->
<!-- 若 Bean 类名上有@Alias(value = "")注解,则使用注解参数作为别名 -->
<!-- 在没有注解的情况下,会使用 Bean 的首字母小写的非限定类名来作为它的别名 -->
<!-- 在没有注解的情况下,会使用 Bean 的首字母小写的非限定类名来作为它的别名 -->
<
!-- <package name="qiwu.xfllmdemo.pojo"/>--
>
<
package
name=
"qiwu.xfllmdemo.pojo"
/
>
<!-- The content of element type "typeAliases" must match "(typeAlias*,package*)". -->
<!-- The content of element type "typeAliases" must match "(typeAlias*,package*)". -->
</typeAliases>
</typeAliases>
<environments
default=
"development"
>
<environments
default=
"development"
>
...
@@ -30,12 +26,13 @@
...
@@ -30,12 +26,13 @@
<property
name=
"url"
<property
name=
"url"
value=
"jdbc:mysql://localhost:3306/chitchat?serverTimezone=Asia/Shanghai&characterEncoding=utf-8"
/>
value=
"jdbc:mysql://localhost:3306/chitchat?serverTimezone=Asia/Shanghai&characterEncoding=utf-8"
/>
<property
name=
"username"
value=
"chatter"
/>
<property
name=
"username"
value=
"chatter"
/>
<property
name=
"password"
value=
"
7890-=
"
/>
<property
name=
"password"
value=
"
dgKNTmt2iLHNjEQajkDEZkq8
"
/>
</dataSource>
</dataSource>
</environment>
</environment>
</environments>
</environments>
<mappers>
<mappers>
<!-- 每一个Mapper.xml都应在mybatis-config.xml中注册 -->
<!-- 每一个Mapper.xml都应在mybatis-config.xml中注册 -->
<!-- TODO 复制到别的项目记得改这里!!! -->
<mapper
resource=
"mapper/DBMapper.xml"
/>
<mapper
resource=
"mapper/DBMapper.xml"
/>
</mappers>
</mappers>
</configuration>
</configuration>
src/main/resources/static/pages/index/index.html
deleted
100644 → 0
View file @
4bbe7675
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
fdgfdgfdcvberrereg
<button
id=
"btn1"
type=
"button"
onclick=
"onbtn1Clicked()"
>
button1
</button>
</body>
<script>
function
onbtn1Clicked
()
{
alert
(
'Hello from jQuery'
);
$
(
"#btn1"
).
html
(
"dfsdf"
);
}
</script>
<script
src=
"/webjars/jquery/3.5.1/jquery.min.js"
></script>
</html>
\ No newline at end of file
src/main/resources/static/pages/index/index.js
deleted
100644 → 0
View file @
4bbe7675
src/main/resources/static/pre-generate.html
View file @
df378329
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
xmlns=
"http://www.w3.org/1999/html"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
...
@@ -10,20 +10,59 @@
...
@@ -10,20 +10,59 @@
</head>
</head>
<body>
<body>
<!-- <input type="file" id="videoUploader" accept="video/mp4, video/ogg">-->
<!-- <input type="file" id="videoUploader" accept="video/mp4, video/ogg">-->
<p
id=
"upload
Info
"
>
在此处上传预设用户话语txt(接受txt和csv格式)
</p>
<p
id=
"upload
Title
"
>
在此处上传预设用户话语txt(接受txt和csv格式)
</p>
<input
type=
"file"
id=
"fileUploadInput"
accept=
"text/csv, text/plain"
>
<input
type=
"file"
id=
"fileUploadInput"
accept=
"text/csv, text/plain"
>
<button
id=
"uploadButton"
>
上传
</button>
<button
type=
"button"
id=
"uploadButton"
>
上传
</button>
<progress
id=
"uploadProgressBar"
value=
"0"
max=
"100"
></progress>
<br>
<br>
<p
id=
"divider1"
>
------------------------------
</p>
<br>
<progress
id=
"uploadProgressBar"
value=
"0"
max=
"100"
></progress>
<textarea
id=
"requirementArea"
cols=
40
rows=
10
placeholder=
"在此输入生成要求,如人物设定等"
></textarea>
<label
id=
"uploadInfo"
></label>
<button
id=
"genButton"
>
生成
</button>
<br>
<p
id=
"divider1"
>
------------------------------
</p>
<p
id=
"genInfo"
></p>
<br>
<p
id=
"genTitle"
>
生成选项
</p>
<p
id=
"divider2"
>
------------------------------
</p>
<br>
<form>
<button
id=
"downloadButton"
>
下载导出文件
</button>
<br>
<label
id=
"roleIdLabel"
for=
"roleIdP"
>
角色ID:
</label>
<p
id=
"downloadInfo"
></p>
<label
id=
"roleIdP"
></label>
<br>
<label
id=
"roleNameLabel"
for=
"roleNameInput"
>
角色名称:
</label>
<input
id=
"roleNameInput"
type=
"text"
list=
"roleNameDatalist"
onchange=
"onRoleNameChange()"
>
<datalist
id=
"roleNameDatalist"
>
<!-- <option value=""> to be inserted by js -->
</datalist>
<!-- button的type有 button submit reset 三种,除IE外都默认为submit,在某些浏览器中点击submit的按钮会导致页面刷新 -->
<button
type=
"button"
onclick=
"onCreateRole()"
>
提交新建角色
</button>
<button
type=
"button"
onclick=
"onDeleteRole()"
>
删除当前角色
</button>
<br>
<label
id=
"roleInfoLabel"
for=
"roleInfoArea"
>
人物设定:
</label>
<textarea
id=
"roleInfoArea"
cols=
40
rows=
10
placeholder=
"在此输入人物设定,将作为提交给模型的prompt"
></textarea>
<br>
<label
id=
"botAccountLabel"
for=
"botAccountInput"
>
所属Bot:
</label>
<input
id=
"botAccountInput"
type=
"text"
list=
"botAccountDatalist"
style=
"width: 300px"
>
<datalist
id=
"botAccountDatalist"
>
<!-- <option value=""> to be inserted by js -->
</datalist>
<br>
<button
type=
"button"
onclick=
"onUpdateRole()"
>
提交角色信息修改
</button>
<label
id=
"roleOptInfo"
></label>
</form>
<br>
<label
id=
"usingModelLabel"
for=
"usingModelInput"
>
模型选择:
</label>
<input
id=
"usingModelInput"
type=
"text"
list=
"usingModelDatalist"
>
<datalist
id=
"usingModelDatalist"
>
<option
value=
"讯飞星火"
>
<option
value=
"MiniMax"
>
<option
value=
"文心一言"
>
</datalist>
<button
type=
"button"
id=
"genButton"
onclick=
"startGen()"
>
生成
</button>
<label
id=
"genInfo"
></label>
<!-- 生成选项 信息提示 -->
<p
id=
"divider2"
>
------------------------------
</p>
<!-- TODO 提供下载、调整文件存储路径等 -->
<button
type=
"button"
id=
"downloadButton"
>
下载导出文件
</button>
<label
id=
"downloadInfo"
></label>
<!-- 下载 信息提示 -->
<script
src=
"./pre-generate.js"
type=
"module"
></script>
</body>
</body>
<!-- 如果定义 type="module" 属性,这会将导入的js作为ESM模块,其中定义的变量和函数将具有模块作用域而不是全局作用域,
默认对全局不可见,需要export import或者手动添加引用到window对象中才能在HTML中访问 -->
<script
src=
"./pre-generate.js"
type=
"module"
></script>
</html>
</html>
\ No newline at end of file
src/main/resources/static/pre-generate.js
View file @
df378329
This diff is collapsed.
Click to expand it.
src/test/getAuditDataTest.http
View file @
df378329
GET https://localhost:8081/api/chat/audit/info?searchText=null&auditStatus=null&pageSize=1&pageNum=10&sortMethod=true HTTP/1.1
GET http://localhost:47001/api/chat/audit/info?searchText=null&auditStatus=null&pageSize=1&pageNum=10&sortMethod=true HTTP/1.1
\ No newline at end of file
\ No newline at end of file
src/test/java/qiwu/xfllmdemo/XfLLMDemoApplicationTests.java
View file @
df378329
...
@@ -3,12 +3,10 @@ package qiwu.xfllmdemo;
...
@@ -3,12 +3,10 @@ package qiwu.xfllmdemo;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
qiwu.xfllmdemo.mapper.DBMapper
;
import
qiwu.xfllmdemo.mapper.DBMapper
;
import
qiwu.xfllmdemo.pojo.AuditDataDAO
;
import
qiwu.xfllmdemo.pojo.*
;
import
qiwu.xfllmdemo.pojo.AuditQueryDAO
;
import
qiwu.xfllmdemo.pojo.LLMAnswerVO
;
import
qiwu.xfllmdemo.pojo.LLMQueryVO
;
import
qiwu.xfllmdemo.service.LLMService
;
import
qiwu.xfllmdemo.service.LLMService
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -27,15 +25,16 @@ class XfLLMDemoApplicationTests {
...
@@ -27,15 +25,16 @@ class XfLLMDemoApplicationTests {
LLMService
ls
=
new
LLMService
();
LLMService
ls
=
new
LLMService
();
String
question
=
"你今日饮咗未?"
;
String
question
=
"你今日饮咗未?"
;
LLMQueryVO
req
=
new
LLMQueryVO
(
UUID
.
fromString
(
"6d7f4741-3bdb-40c8-a2d8-55b505fe6e2a"
),
question
);
LLMQueryVO
req
=
new
LLMQueryVO
(
UUID
.
fromString
(
"6d7f4741-3bdb-40c8-a2d8-55b505fe6e2a"
),
question
);
LLMAnswerVO
res
=
ls
.
query
(
req
,
1
,
true
);
HashMap
<
UUID
,
List
<
LLMRequestVO
.
Payload
.
Message
.
Text
>>
chatHistory
=
new
HashMap
<>();
LLMAnswerVO
res
=
ls
.
query
(
chatHistory
,
req
,
1
,
true
);
System
.
out
.
println
(
"------- query() ends -------"
);
System
.
out
.
println
(
"------- query() ends -------"
);
System
.
out
.
println
(
"
QueryResponse
VO: "
+
res
/*.toString()*/
);
System
.
out
.
println
(
"
LLMAnswer
VO: "
+
res
/*.toString()*/
);
System
.
out
.
println
(
res
.
answer
);
System
.
out
.
println
(
res
.
answer
);
}
}
// @Test
// @Test
void
getAuditDataTest
()
{
void
getAuditDataTest
()
{
AuditQueryDAO
aq
=
new
AuditQueryDAO
(
"什"
,
(
short
)
0
,
0
,
60
,
"true"
);
AuditQueryDAO
aq
=
new
AuditQueryDAO
(
"什"
,
(
short
)
0
,
0
,
60
,
"true"
,
""
,
"讯飞星火"
);
List
<
AuditDataDAO
>
al
=
dbMapper
.
getAuditData
(
aq
);
List
<
AuditDataDAO
>
al
=
dbMapper
.
getAuditData
(
aq
);
System
.
out
.
println
(
"al.size(): "
+
al
.
size
());
System
.
out
.
println
(
"al.size(): "
+
al
.
size
());
int
t
=
0
;
int
t
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment