Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elleai
Project
Project
Details
Activity
Releases
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
ai-tech
E
ellehuis-group
backend
elleai
Commits
9abdedb3
Commit
9abdedb3
authored
Oct 23, 2024
by
陈立彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.ai问答增加助手ID参数 2.修复重复答题
parent
0b9e293f
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
69 additions
and
30 deletions
+69
-30
ExamineCloseRequestDto.java
...lleai/application/dto/request/ExamineCloseRequestDto.java
+19
-0
UserQaMobileRequestDto.java
...lleai/application/dto/request/UserQaMobileRequestDto.java
+4
-0
AppChatCompletionService.java
.../elleai/application/service/AppChatCompletionService.java
+5
-4
AppExamineService.java
.../breeze/elleai/application/service/AppExamineService.java
+21
-23
ExamineMobileController.java
...eeze/elleai/controller/front/ExamineMobileController.java
+1
-1
ChatCompletionService.java
...elleai/domain/sparring/service/ChatCompletionService.java
+1
-1
ChatCompletionServiceImpl.java
...ai/domain/sparring/service/ChatCompletionServiceImpl.java
+2
-1
ExamineService.java
...breeze/elleai/domain/sparring/service/ExamineService.java
+3
-0
ExamineServiceImpl.java
...ze/elleai/domain/sparring/service/ExamineServiceImpl.java
+8
-0
UserChatCompletionHistoryEntity.java
.../elleai/infra/entity/UserChatCompletionHistoryEntity.java
+5
-0
No files found.
src/main/java/cn/breeze/elleai/application/dto/request/ExamineCloseRequestDto.java
0 → 100644
View file @
9abdedb3
package
cn
.
breeze
.
elleai
.
application
.
dto
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
ExamineCloseRequestDto
implements
Serializable
{
@Schema
(
description
=
"对练ID"
)
@JsonProperty
(
"examaine_id"
)
private
Integer
examineId
;
@Schema
(
description
=
"考试流水号"
)
@JsonProperty
(
"business_no"
)
private
String
businessNo
;
}
src/main/java/cn/breeze/elleai/application/dto/request/UserQaMobileRequestDto.java
View file @
9abdedb3
...
@@ -16,4 +16,8 @@ public class UserQaMobileRequestDto implements Serializable {
...
@@ -16,4 +16,8 @@ public class UserQaMobileRequestDto implements Serializable {
@Schema
(
description
=
"提问内容"
)
@Schema
(
description
=
"提问内容"
)
@JsonProperty
(
"content"
)
@JsonProperty
(
"content"
)
private
String
content
;
private
String
content
;
@Schema
(
description
=
"助手ID"
)
@JsonProperty
(
"assistant_id"
)
private
Integer
assistantId
;
}
}
src/main/java/cn/breeze/elleai/application/service/AppChatCompletionService.java
View file @
9abdedb3
...
@@ -328,10 +328,10 @@ public class AppChatCompletionService {
...
@@ -328,10 +328,10 @@ public class AppChatCompletionService {
Integer
recordId
=
chatCompletionService
.
saveUserQaSession
(
saveModel
);
Integer
recordId
=
chatCompletionService
.
saveUserQaSession
(
saveModel
);
// 保存问答详情
// 保存问答详情
chatCompletionService
.
saveUserQaRecord
(
recordId
,
0
,
request
.
getContent
());
chatCompletionService
.
saveUserQaRecord
(
recordId
,
0
,
request
.
getContent
()
,
request
.
getAssistantId
()
);
// 问一下AI
// 问一下AI
AiChatComplateResultDto
complateResultDto
=
ask4Knowledge
(
sessionId
,
userPrincipal
.
getUserId
(),
request
.
getContent
());
AiChatComplateResultDto
complateResultDto
=
ask4Knowledge
(
sessionId
,
userPrincipal
.
getUserId
(),
request
.
getContent
()
,
request
.
getAssistantId
()
);
if
(
Objects
.
nonNull
(
complateResultDto
))
{
if
(
Objects
.
nonNull
(
complateResultDto
))
{
String
replyContent
=
complateResultDto
.
getContent
();
String
replyContent
=
complateResultDto
.
getContent
();
...
@@ -344,7 +344,7 @@ public class AppChatCompletionService {
...
@@ -344,7 +344,7 @@ public class AppChatCompletionService {
}
}
// 保存AI问答详情
// 保存AI问答详情
chatCompletionService
.
saveUserQaRecord
(
recordId
,
1
,
replyContent
);
chatCompletionService
.
saveUserQaRecord
(
recordId
,
1
,
replyContent
,
request
.
getAssistantId
()
);
result
.
setChatCompletionId
(
recordId
);
result
.
setChatCompletionId
(
recordId
);
result
.
setReplyContent
(
replyContent
);
result
.
setReplyContent
(
replyContent
);
...
@@ -374,9 +374,10 @@ public class AppChatCompletionService {
...
@@ -374,9 +374,10 @@ public class AppChatCompletionService {
}
}
public
AiChatComplateResultDto
ask4Knowledge
(
String
sessionId
,
String
userId
,
String
question
)
{
public
AiChatComplateResultDto
ask4Knowledge
(
String
sessionId
,
String
userId
,
String
question
,
Integer
assistantId
)
{
Map
<
String
,
String
>
inputs
=
new
HashMap
<>();
Map
<
String
,
String
>
inputs
=
new
HashMap
<>();
inputs
.
put
(
"context"
,
question
);
inputs
.
put
(
"context"
,
question
);
inputs
.
put
(
"assistant_id"
,
String
.
valueOf
(
assistantId
));
JSONObject
param
=
new
JSONObject
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"inputs"
,
inputs
);
param
.
put
(
"inputs"
,
inputs
);
param
.
put
(
"query"
,
question
);
param
.
put
(
"query"
,
question
);
...
...
src/main/java/cn/breeze/elleai/application/service/AppExamineService.java
View file @
9abdedb3
package
cn
.
breeze
.
elleai
.
application
.
service
;
package
cn
.
breeze
.
elleai
.
application
.
service
;
import
cn.breeze.elleai.application.dto.PageResult
;
import
cn.breeze.elleai.application.dto.PageResult
;
import
cn.breeze.elleai.application.dto.inner.AiSingleEvaluateResultDto
;
import
cn.breeze.elleai.application.dto.inner.ExamineBusinessCacheDto
;
import
cn.breeze.elleai.application.dto.inner.ExamineBusinessCacheDto
;
import
cn.breeze.elleai.application.dto.request.*
;
import
cn.breeze.elleai.application.dto.request.*
;
import
cn.breeze.elleai.application.dto.response.*
;
import
cn.breeze.elleai.application.dto.response.*
;
...
@@ -31,7 +30,7 @@ import java.util.function.Function;
...
@@ -31,7 +30,7 @@ import java.util.function.Function;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.IntStream
;
import
static
java
.
util
.
stream
.
Collectors
.
*
;
import
static
java
.
util
.
stream
.
Collectors
.
toMap
;
/**
/**
...
@@ -1146,11 +1145,8 @@ public class AppExamineService {
...
@@ -1146,11 +1145,8 @@ public class AppExamineService {
throw
new
InternalException
(-
1
,
"获取不到对练信息"
);
throw
new
InternalException
(-
1
,
"获取不到对练信息"
);
}
}
// 获取题目信息
ExamineQaDto
examineQaDto
=
qaDetail
(
questionId
);
// 获取数据库考试信息
// 获取数据库考试信息
Integer
recordId
=
null
;
Integer
recordId
;
ExamineRecordResponseModel
examineRecord
=
examineService
.
examineRecordDetail
(
businessNo
);
ExamineRecordResponseModel
examineRecord
=
examineService
.
examineRecordDetail
(
businessNo
);
if
(
Objects
.
isNull
(
examineRecord
))
{
if
(
Objects
.
isNull
(
examineRecord
))
{
// 第一次答题,保存考试信息
// 第一次答题,保存考试信息
...
@@ -1168,13 +1164,17 @@ public class AppExamineService {
...
@@ -1168,13 +1164,17 @@ public class AppExamineService {
recordId
=
saveModel
.
getId
();
recordId
=
saveModel
.
getId
();
}
else
{
}
else
{
recordId
=
examineRecord
.
getId
();
recordId
=
examineRecord
.
getId
();
}
// 获取有无答题记录
Integer
detailRecordId
;
ExamineRecordDetailResponseModel
examineRecordDetail
=
examineService
.
getExamineRecordDetail
(
businessCache
.
getRecordId
(),
questionId
);
if
(
Objects
.
isNull
(
examineRecordDetail
))
{
// 更新答题数量
// 更新答题数量
ExamineRecordSaveModel
saveModel
=
new
ExamineRecordSaveModel
();
ExamineRecordSaveModel
saveModel
=
new
ExamineRecordSaveModel
();
saveModel
.
setId
(
recordId
);
saveModel
.
setId
(
recordId
);
saveModel
.
setAnsweredNum
(
examineRecord
.
getAnsweredNum
()
+
1
);
saveModel
.
setAnsweredNum
(
examineRecord
.
getAnsweredNum
()
+
1
);
examineService
.
saveExamineRecord
(
saveModel
);
examineService
.
saveExamineRecord
(
saveModel
);
}
// 保存单题答题信息
// 保存单题答题信息
ExamineRecordDetailSaveModel
detailSaveModel
=
new
ExamineRecordDetailSaveModel
();
ExamineRecordDetailSaveModel
detailSaveModel
=
new
ExamineRecordDetailSaveModel
();
...
@@ -1182,20 +1182,18 @@ public class AppExamineService {
...
@@ -1182,20 +1182,18 @@ public class AppExamineService {
detailSaveModel
.
setQaId
(
questionId
);
detailSaveModel
.
setQaId
(
questionId
);
detailSaveModel
.
setCreateTime
(
new
Date
());
detailSaveModel
.
setCreateTime
(
new
Date
());
detailSaveModel
.
setAnswer
(
answer
);
detailSaveModel
.
setAnswer
(
answer
);
// AI 点评
// AiSingleEvaluateResultDto evaluateResultDto = extensionService.run4SingleEvaluate(businessNo, userId, examineQaDto.getQuestion(), examineQaDto.getAnswer(), answer);
// if(Objects.nonNull(evaluateResultDto)) {
// detailSaveModel.setScore(evaluateResultDto.getScore());
// detailSaveModel.setEvaluation(evaluateResultDto.getEvaluation());
// }
examineService
.
saveExamineRecordDetail
(
detailSaveModel
);
examineService
.
saveExamineRecordDetail
(
detailSaveModel
);
detailRecordId
=
detailSaveModel
.
getId
();
}
else
{
detailRecordId
=
examineRecordDetail
.
getId
();
}
// 定时任务
// 定时任务
ExamineEvaluateJobResponseModel
evaluateJob
=
commonService
.
getEvaluateJob
(
0
,
detail
SaveModel
.
getId
()
);
ExamineEvaluateJobResponseModel
evaluateJob
=
commonService
.
getEvaluateJob
(
0
,
detail
RecordId
);
if
(
Objects
.
isNull
(
evaluateJob
))
{
if
(
Objects
.
isNull
(
evaluateJob
))
{
ExamineEvaluateJobSaveModel
model
=
new
ExamineEvaluateJobSaveModel
();
ExamineEvaluateJobSaveModel
model
=
new
ExamineEvaluateJobSaveModel
();
model
.
setBusinessId
(
detail
SaveModel
.
getId
()
);
model
.
setBusinessId
(
detail
RecordId
);
model
.
setBusinessNo
(
businessNo
);
model
.
setBusinessNo
(
businessNo
);
model
.
setType
(
0
);
model
.
setType
(
0
);
model
.
setStatus
(
0
);
model
.
setStatus
(
0
);
...
...
src/main/java/cn/breeze/elleai/controller/front/ExamineMobileController.java
View file @
9abdedb3
...
@@ -149,7 +149,7 @@ public class ExamineMobileController {
...
@@ -149,7 +149,7 @@ public class ExamineMobileController {
@Schema
(
description
=
"对练ID"
)
@RequestParam
(
"examaine_id"
)
Integer
examineId
,
@Schema
(
description
=
"对练ID"
)
@RequestParam
(
"examaine_id"
)
Integer
examineId
,
@Schema
(
description
=
"考试流水号"
)
@RequestParam
(
"business_no"
)
String
businessNo
)
{
@Schema
(
description
=
"考试流水号"
)
@RequestParam
(
"business_no"
)
String
businessNo
)
{
examineService
.
exitExamine
(
userPrincipal
,
examineId
,
businessNo
);
//
examineService.exitExamine(userPrincipal, examineId, businessNo);
return
ApiResponse
.
ok
(
"SUCCESS"
);
return
ApiResponse
.
ok
(
"SUCCESS"
);
}
}
...
...
src/main/java/cn/breeze/elleai/domain/sparring/service/ChatCompletionService.java
View file @
9abdedb3
...
@@ -25,7 +25,7 @@ public interface ChatCompletionService {
...
@@ -25,7 +25,7 @@ public interface ChatCompletionService {
Integer
saveUserQaSession
(
UserChatCompletionSaveModel
dto
);
Integer
saveUserQaSession
(
UserChatCompletionSaveModel
dto
);
void
saveUserQaRecord
(
Integer
chatCompletionId
,
Integer
type
,
String
content
);
void
saveUserQaRecord
(
Integer
chatCompletionId
,
Integer
type
,
String
content
,
Integer
assistantId
);
/***************************************** AI助手 *****************************************/
/***************************************** AI助手 *****************************************/
Page
<
QaAssistantResponseModel
>
qaAssistantPaginQuery
(
QaAssistantRequestModel
request
);
Page
<
QaAssistantResponseModel
>
qaAssistantPaginQuery
(
QaAssistantRequestModel
request
);
...
...
src/main/java/cn/breeze/elleai/domain/sparring/service/ChatCompletionServiceImpl.java
View file @
9abdedb3
...
@@ -139,11 +139,12 @@ public class ChatCompletionServiceImpl implements ChatCompletionService{
...
@@ -139,11 +139,12 @@ public class ChatCompletionServiceImpl implements ChatCompletionService{
}
}
@Override
@Override
public
void
saveUserQaRecord
(
Integer
chatCompletionId
,
Integer
type
,
String
content
)
{
public
void
saveUserQaRecord
(
Integer
chatCompletionId
,
Integer
type
,
String
content
,
Integer
assistantId
)
{
UserChatCompletionHistoryEntity
entity
=
new
UserChatCompletionHistoryEntity
();
UserChatCompletionHistoryEntity
entity
=
new
UserChatCompletionHistoryEntity
();
entity
.
setChatCompletionId
(
chatCompletionId
);
entity
.
setChatCompletionId
(
chatCompletionId
);
entity
.
setType
(
type
);
entity
.
setType
(
type
);
entity
.
setContent
(
content
);
entity
.
setContent
(
content
);
entity
.
setAssistantId
(
assistantId
);
entity
.
setCreateTime
(
new
Date
());
entity
.
setCreateTime
(
new
Date
());
chatCompletionHistoryMapper
.
insertOrUpdateSelective
(
entity
);
chatCompletionHistoryMapper
.
insertOrUpdateSelective
(
entity
);
}
}
...
...
src/main/java/cn/breeze/elleai/domain/sparring/service/ExamineService.java
View file @
9abdedb3
...
@@ -104,6 +104,9 @@ public interface ExamineService {
...
@@ -104,6 +104,9 @@ public interface ExamineService {
void
saveExamineRecordDetail
(
ExamineRecordDetailSaveModel
dto
);
void
saveExamineRecordDetail
(
ExamineRecordDetailSaveModel
dto
);
ExamineRecordDetailResponseModel
getExamineRecordDetail
(
Integer
recordId
,
Integer
qaId
);
ExamineRecordDetailResponseModel
singleExamineQaDetail
(
Integer
id
);
ExamineRecordDetailResponseModel
singleExamineQaDetail
(
Integer
id
);
long
countUnfinishedExamineRecord
(
Integer
examineId
);
long
countUnfinishedExamineRecord
(
Integer
examineId
);
...
...
src/main/java/cn/breeze/elleai/domain/sparring/service/ExamineServiceImpl.java
View file @
9abdedb3
...
@@ -525,6 +525,14 @@ public class ExamineServiceImpl implements ExamineService {
...
@@ -525,6 +525,14 @@ public class ExamineServiceImpl implements ExamineService {
dto
.
setId
(
entity
.
getId
());
dto
.
setId
(
entity
.
getId
());
}
}
@Override
public
ExamineRecordDetailResponseModel
getExamineRecordDetail
(
Integer
recordId
,
Integer
qaId
)
{
QueryWrapper
queryWrapper
=
QueryWrapper
.
create
()
.
where
(
USER_EXAMINE_DETAIL_RECORD_ENTITY
.
RECORD_ID
.
eq
(
recordId
))
.
and
(
USER_EXAMINE_DETAIL_RECORD_ENTITY
.
QA_ID
.
eq
(
qaId
));
return
userExamineDetailRecordMapper
.
selectOneByQueryAs
(
queryWrapper
,
ExamineRecordDetailResponseModel
.
class
);
}
@Override
@Override
public
ExamineRecordDetailResponseModel
singleExamineQaDetail
(
Integer
id
)
{
public
ExamineRecordDetailResponseModel
singleExamineQaDetail
(
Integer
id
)
{
QueryWrapper
queryWrapper
=
QueryWrapper
.
create
()
QueryWrapper
queryWrapper
=
QueryWrapper
.
create
()
...
...
src/main/java/cn/breeze/elleai/infra/entity/UserChatCompletionHistoryEntity.java
View file @
9abdedb3
...
@@ -41,6 +41,11 @@ public class UserChatCompletionHistoryEntity implements Serializable {
...
@@ -41,6 +41,11 @@ public class UserChatCompletionHistoryEntity implements Serializable {
*/
*/
private
Integer
type
;
private
Integer
type
;
/**
* 问答助手ID
*/
private
Integer
assistantId
;
/**
/**
* 内容
* 内容
*/
*/
...
...
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