Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
poc
poc-api
Commits
c44e3884
Commit
c44e3884
authored
Sep 10, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:车辆保险对话智能体
parent
5dd0542f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
3269 additions
and
8 deletions
+3269
-8
pom.xml
pom.xml
+6
-0
AiDialoguesService.java
...cn/com/poc/ai_dialogues/aggregate/AiDialoguesService.java
+10
-1
AiDialoguesServiceImpl.java
...c/ai_dialogues/aggregate/impl/AiDialoguesServiceImpl.java
+141
-6
AiDialoguesTypeEnum.java
...cn/com/poc/ai_dialogues/constant/AiDialoguesTypeEnum.java
+2
-0
DialoguesPlatformEnum.java
.../com/poc/ai_dialogues/constant/DialoguesPlatformEnum.java
+24
-0
BizAiDialogues3rdRelationConvert.java
...i_dialogues/convert/BizAiDialogues3rdRelationConvert.java
+69
-0
AiDialoguesCallDto.java
.../java/cn/com/poc/ai_dialogues/dto/AiDialoguesCallDto.java
+40
-0
BizAiDialogues3rdRelationDto.java
...om/poc/ai_dialogues/dto/BizAiDialogues3rdRelationDto.java
+127
-0
AiDialoguesOptions.java
...va/cn/com/poc/ai_dialogues/entity/AiDialoguesOptions.java
+124
-0
BizAiDialogues3rdRelationEntity.java
.../ai_dialogues/entity/BizAiDialogues3rdRelationEntity.java
+127
-0
BizAiDialogues3rdRelationModel.java
...oc/ai_dialogues/model/BizAiDialogues3rdRelationModel.java
+190
-0
BizAiDialogues3rdRelationRepository.java
...ogues/repository/BizAiDialogues3rdRelationRepository.java
+6
-0
AiDialoguesRest.java
...in/java/cn/com/poc/ai_dialogues/rest/AiDialoguesRest.java
+7
-0
AiDialoguesRestImpl.java
...n/com/poc/ai_dialogues/rest/impl/AiDialoguesRestImpl.java
+11
-1
BizAiDialogues3rdRelationService.java
...i_dialogues/service/BizAiDialogues3rdRelationService.java
+21
-0
BizAiDialogues3rdRelationServiceImpl.java
...es/service/impl/BizAiDialogues3rdRelationServiceImpl.java
+109
-0
AppBuilderService.java
.../cn/com/poc/appbuilder/aggregation/AppBuilderService.java
+46
-0
AppBuilderServiceImpl.java
...oc/appbuilder/aggregation/impl/AppBuilderServiceImpl.java
+158
-0
BaiduAppBuilderApi.java
...in/java/cn/com/poc/appbuilder/api/BaiduAppBuilderApi.java
+73
-0
AppBuilderBaseApi.java
...ava/cn/com/poc/appbuilder/api/base/AppBuilderBaseApi.java
+31
-0
AppBuilderDescribeListRequest.java
.../appbuilder/api/entity/AppBuilderDescribeListRequest.java
+43
-0
AppBuilderDescribeRequest.java
.../poc/appbuilder/api/entity/AppBuilderDescribeRequest.java
+29
-0
BaiduAppBuilderCommonErrorResult.java
...pbuilder/api/entity/BaiduAppBuilderCommonErrorResult.java
+36
-0
BaiduAppBuilderDescribeAppListResult.java
...lder/api/entity/BaiduAppBuilderDescribeAppListResult.java
+96
-0
BaiduAppBuilderDescribeAppResult.java
...pbuilder/api/entity/BaiduAppBuilderDescribeAppResult.java
+157
-0
ChatConfig.java
...ain/java/cn/com/poc/appbuilder/api/entity/ChatConfig.java
+67
-0
Component.java
...main/java/cn/com/poc/appbuilder/api/entity/Component.java
+55
-0
FollowUpQuery.java
.../java/cn/com/poc/appbuilder/api/entity/FollowUpQuery.java
+55
-0
KnowledgeBase.java
.../java/cn/com/poc/appbuilder/api/entity/KnowledgeBase.java
+55
-0
KnowledgeBaseConfig.java
...cn/com/poc/appbuilder/api/entity/KnowledgeBaseConfig.java
+43
-0
ModelConfig.java
...in/java/cn/com/poc/appbuilder/api/entity/ModelConfig.java
+42
-0
PlanConfig.java
...ain/java/cn/com/poc/appbuilder/api/entity/PlanConfig.java
+79
-0
RagModelConfig.java
...java/cn/com/poc/appbuilder/api/entity/RagModelConfig.java
+38
-0
RetrievalConfig.java
...ava/cn/com/poc/appbuilder/api/entity/RetrievalConfig.java
+83
-0
AppBuilderCommunicationDto.java
...cn/com/poc/appbuilder/dto/AppBuilderCommunicationDto.java
+69
-0
AppBuilderTTSConfigDto.java
...ava/cn/com/poc/appbuilder/dto/AppBuilderTTSConfigDto.java
+35
-0
BizAppbuilderConversationModel.java
.../poc/appbuilder/model/BizAppbuilderConversationModel.java
+169
-0
BizAppbuilderConversationRecordModel.java
...ppbuilder/model/BizAppbuilderConversationRecordModel.java
+169
-0
BizAppbuilderInfoModel.java
...a/cn/com/poc/appbuilder/model/BizAppbuilderInfoModel.java
+155
-0
BizAppbuilderConversationRecordRepository.java
...repository/BizAppbuilderConversationRecordRepository.java
+7
-0
BizAppbuilderConversationRepository.java
...ilder/repository/BizAppbuilderConversationRepository.java
+6
-0
BizAppbuilderInfoRepository.java
...oc/appbuilder/repository/BizAppbuilderInfoRepository.java
+7
-0
AppBuilderDescribeAppRest.java
...cn/com/poc/appbuilder/rest/AppBuilderDescribeAppRest.java
+29
-0
AppBuilderRest.java
src/main/java/cn/com/poc/appbuilder/rest/AppBuilderRest.java
+54
-0
AppBuilderDescribeAppRestImpl.java
...c/appbuilder/rest/impl/AppBuilderDescribeAppRestImpl.java
+60
-0
AppBuilderRestImpl.java
...a/cn/com/poc/appbuilder/rest/impl/AppBuilderRestImpl.java
+103
-0
BizAppbuilderConversationRecordService.java
...ilder/service/BizAppbuilderConversationRecordService.java
+26
-0
BizAppbuilderConversationService.java
.../appbuilder/service/BizAppbuilderConversationService.java
+26
-0
BizAppbuilderInfoService.java
.../com/poc/appbuilder/service/BizAppbuilderInfoService.java
+15
-0
BizAppbuilderConversationRecordServiceImpl.java
...vice/impl/BizAppbuilderConversationRecordServiceImpl.java
+51
-0
BizAppbuilderConversationServiceImpl.java
...er/service/impl/BizAppbuilderConversationServiceImpl.java
+51
-0
BizAppbuilderInfoServiceImpl.java
...appbuilder/service/impl/BizAppbuilderInfoServiceImpl.java
+37
-0
No files found.
pom.xml
View file @
c44e3884
...
...
@@ -322,6 +322,12 @@
<version>
0.10.328
</version>
</dependency>
<dependency>
<groupId>
com.baidubce
</groupId>
<artifactId>
appbuilder
</artifactId>
<version>
0.9.4
</version>
</dependency>
<dependency>
<groupId>
io.github.furstenheim
</groupId>
<artifactId>
copy_down
</artifactId>
...
...
src/main/java/cn/com/poc/ai_dialogues/aggregate/AiDialoguesService.java
View file @
c44e3884
...
...
@@ -2,8 +2,8 @@ package cn.com.poc.ai_dialogues.aggregate;
import
cn.com.poc.ai_dialogues.constant.AiDialoguesTypeEnum
;
import
cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto
;
import
cn.com.poc.ai_dialogues.entity.AiDialoguesOptions
;
import
cn.com.poc.expose.dto.DialoguesContextDto
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
...
...
@@ -84,4 +84,13 @@ public interface AiDialoguesService {
*/
List
<
String
>
guessYouAsk
(
String
type
)
throws
Exception
;
/**
* 对话
*
* @param dialoguesId 对话id
* @param input 对话内容
* @param options 对话配置
*/
String
call
(
String
dialoguesId
,
String
input
,
Long
userId
,
AiDialoguesOptions
options
)
throws
Exception
;
}
src/main/java/cn/com/poc/ai_dialogues/aggregate/impl/AiDialoguesServiceImpl.java
View file @
c44e3884
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/poc/ai_dialogues/constant/AiDialoguesTypeEnum.java
View file @
c44e3884
...
...
@@ -30,6 +30,8 @@ public enum AiDialoguesTypeEnum {
LEGISLATIVE_DOCUMENT_WRITING
(
"legislative_document_writing"
,
"立案调查"
),
CAR_INSURANCE
(
"car_insurance"
,
"车辆保险"
),
;
private
final
String
type
;
...
...
src/main/java/cn/com/poc/ai_dialogues/constant/DialoguesPlatformEnum.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
constant
;
/**
* @author alex.yao
* @date 2025/9/10
*/
public
enum
DialoguesPlatformEnum
{
AppBuilder
(
"appbuilder"
),
ModelLink
(
"modelLink"
),
Dify
(
"dify"
),
Custom
(
"custom"
),
;
private
String
platform
;
DialoguesPlatformEnum
(
String
platform
)
{
this
.
platform
=
platform
;
}
public
String
getPlatform
()
{
return
platform
;
}
}
src/main/java/cn/com/poc/ai_dialogues/convert/BizAiDialogues3rdRelationConvert.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
convert
;
import
cn.com.poc.ai_dialogues.model.BizAiDialogues3rdRelationModel
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialogues3rdRelationEntity
;
import
cn.com.poc.ai_dialogues.dto.BizAiDialogues3rdRelationDto
;
public
class
BizAiDialogues3rdRelationConvert
{
public
static
BizAiDialogues3rdRelationEntity
modelToEntity
(
BizAiDialogues3rdRelationModel
model
){
BizAiDialogues3rdRelationEntity
entity
=
new
BizAiDialogues3rdRelationEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setDialoguesId
(
model
.
getDialoguesId
());
entity
.
setPlatform
(
model
.
getPlatform
());
entity
.
setRelationId
(
model
.
getRelationId
());
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setModifier
(
model
.
getModifier
());
entity
.
setModifiedTime
(
model
.
getModifiedTime
());
entity
.
setSysVersion
(
model
.
getSysVersion
());
return
entity
;
}
public
static
BizAiDialogues3rdRelationModel
entityToModel
(
BizAiDialogues3rdRelationEntity
entity
){
BizAiDialogues3rdRelationModel
model
=
new
BizAiDialogues3rdRelationModel
();
model
.
setId
(
entity
.
getId
());
model
.
setDialoguesId
(
entity
.
getDialoguesId
());
model
.
setPlatform
(
entity
.
getPlatform
());
model
.
setRelationId
(
entity
.
getRelationId
());
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setModifier
(
entity
.
getModifier
());
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
model
.
setSysVersion
(
entity
.
getSysVersion
());
return
model
;
}
public
static
BizAiDialogues3rdRelationDto
entityToDto
(
BizAiDialogues3rdRelationEntity
entity
){
BizAiDialogues3rdRelationDto
dto
=
new
BizAiDialogues3rdRelationDto
();
dto
.
setId
(
entity
.
getId
());
dto
.
setDialoguesId
(
entity
.
getDialoguesId
());
dto
.
setPlatform
(
entity
.
getPlatform
());
dto
.
setRelationId
(
entity
.
getRelationId
());
dto
.
setIsDeleted
(
entity
.
getIsDeleted
());
dto
.
setCreator
(
entity
.
getCreator
());
dto
.
setCreatedTime
(
entity
.
getCreatedTime
());
dto
.
setModifier
(
entity
.
getModifier
());
dto
.
setModifiedTime
(
entity
.
getModifiedTime
());
dto
.
setSysVersion
(
entity
.
getSysVersion
());
return
dto
;
}
public
static
BizAiDialogues3rdRelationEntity
dtoToEntity
(
BizAiDialogues3rdRelationDto
dto
){
BizAiDialogues3rdRelationEntity
entity
=
new
BizAiDialogues3rdRelationEntity
();
entity
.
setId
(
dto
.
getId
());
entity
.
setDialoguesId
(
dto
.
getDialoguesId
());
entity
.
setPlatform
(
dto
.
getPlatform
());
entity
.
setRelationId
(
dto
.
getRelationId
());
entity
.
setIsDeleted
(
dto
.
getIsDeleted
());
entity
.
setCreator
(
dto
.
getCreator
());
entity
.
setCreatedTime
(
dto
.
getCreatedTime
());
entity
.
setModifier
(
dto
.
getModifier
());
entity
.
setModifiedTime
(
dto
.
getModifiedTime
());
entity
.
setSysVersion
(
dto
.
getSysVersion
());
return
entity
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/dto/AiDialoguesCallDto.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
dto
;
import
cn.com.poc.ai_dialogues.entity.AiDialoguesOptions
;
/**
* @author alex.yao
* @date 2025/9/10
*/
public
class
AiDialoguesCallDto
{
private
String
dialoguesId
;
private
String
input
;
private
AiDialoguesOptions
options
;
public
String
getDialoguesId
()
{
return
dialoguesId
;
}
public
void
setDialoguesId
(
String
dialoguesId
)
{
this
.
dialoguesId
=
dialoguesId
;
}
public
String
getInput
()
{
return
input
;
}
public
void
setInput
(
String
input
)
{
this
.
input
=
input
;
}
public
AiDialoguesOptions
getOptions
()
{
return
options
;
}
public
void
setOptions
(
AiDialoguesOptions
options
)
{
this
.
options
=
options
;
}
}
src/main/java/cn/com/poc/ai_dialogues/dto/BizAiDialogues3rdRelationDto.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
dto
;
public
class
BizAiDialogues3rdRelationDto
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Long
id
;
public
java
.
lang
.
Long
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Long
id
){
this
.
id
=
id
;
}
/** dialogues_id
*会话id
*/
private
java
.
lang
.
String
dialoguesId
;
public
java
.
lang
.
String
getDialoguesId
(){
return
this
.
dialoguesId
;
}
public
void
setDialoguesId
(
java
.
lang
.
String
dialoguesId
){
this
.
dialoguesId
=
dialoguesId
;
}
/** platform
*关联平台
*/
private
java
.
lang
.
String
platform
;
public
java
.
lang
.
String
getPlatform
(){
return
this
.
platform
;
}
public
void
setPlatform
(
java
.
lang
.
String
platform
){
this
.
platform
=
platform
;
}
/** relation_id
*关联平台 对话id
*/
private
java
.
lang
.
String
relationId
;
public
java
.
lang
.
String
getRelationId
(){
return
this
.
relationId
;
}
public
void
setRelationId
(
java
.
lang
.
String
relationId
){
this
.
relationId
=
relationId
;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDeleted
;
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
}
/** CREATOR
*创建人
*/
private
java
.
lang
.
String
creator
;
public
java
.
lang
.
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
this
.
creator
=
creator
;
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
}
/** MODIFIER
*修改人
*/
private
java
.
lang
.
String
modifier
;
public
java
.
lang
.
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
this
.
modifier
=
modifier
;
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/entity/AiDialoguesOptions.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
entity
;
import
cn.com.poc.agent_application.entity.KnowledgeSuperclassProblemConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
java.util.List
;
/**
* @author alex.yao
* @date 2025/9/9
*/
public
class
AiDialoguesOptions
{
Integer
[]
knowledgeIds
;
Integer
[]
databaseIds
;
Integer
communicationTurn
;
Float
topP
;
Float
temperature
;
List
<
Tool
>
tools
;
FunctionCallResult
functionCallResult
;
boolean
stream
;
Double
score
;
Integer
topK
;
KnowledgeSearchTypeEnum
knowledgeSearchType
;
KnowledgeSuperclassProblemConfig
superclassProblemConfig
;
public
Integer
[]
getKnowledgeIds
()
{
return
knowledgeIds
;
}
public
void
setKnowledgeIds
(
Integer
[]
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
}
public
Integer
[]
getDatabaseIds
()
{
return
databaseIds
;
}
public
void
setDatabaseIds
(
Integer
[]
databaseIds
)
{
this
.
databaseIds
=
databaseIds
;
}
public
Integer
getCommunicationTurn
()
{
return
communicationTurn
;
}
public
void
setCommunicationTurn
(
Integer
communicationTurn
)
{
this
.
communicationTurn
=
communicationTurn
;
}
public
Float
getTopP
()
{
return
topP
;
}
public
void
setTopP
(
Float
topP
)
{
this
.
topP
=
topP
;
}
public
Float
getTemperature
()
{
return
temperature
;
}
public
void
setTemperature
(
Float
temperature
)
{
this
.
temperature
=
temperature
;
}
public
List
<
Tool
>
getTools
()
{
return
tools
;
}
public
void
setTools
(
List
<
Tool
>
tools
)
{
this
.
tools
=
tools
;
}
public
FunctionCallResult
getFunctionCallResult
()
{
return
functionCallResult
;
}
public
void
setFunctionCallResult
(
FunctionCallResult
functionCallResult
)
{
this
.
functionCallResult
=
functionCallResult
;
}
public
boolean
isStream
()
{
return
stream
;
}
public
void
setStream
(
boolean
stream
)
{
this
.
stream
=
stream
;
}
public
Double
getScore
()
{
return
score
;
}
public
void
setScore
(
Double
score
)
{
this
.
score
=
score
;
}
public
Integer
getTopK
()
{
return
topK
;
}
public
void
setTopK
(
Integer
topK
)
{
this
.
topK
=
topK
;
}
public
KnowledgeSearchTypeEnum
getKnowledgeSearchType
()
{
return
knowledgeSearchType
;
}
public
void
setKnowledgeSearchType
(
KnowledgeSearchTypeEnum
knowledgeSearchType
)
{
this
.
knowledgeSearchType
=
knowledgeSearchType
;
}
public
KnowledgeSuperclassProblemConfig
getSuperclassProblemConfig
()
{
return
superclassProblemConfig
;
}
public
void
setSuperclassProblemConfig
(
KnowledgeSuperclassProblemConfig
superclassProblemConfig
)
{
this
.
superclassProblemConfig
=
superclassProblemConfig
;
}
}
src/main/java/cn/com/poc/ai_dialogues/entity/BizAiDialogues3rdRelationEntity.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
entity
;
public
class
BizAiDialogues3rdRelationEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Long
id
;
public
java
.
lang
.
Long
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Long
id
){
this
.
id
=
id
;
}
/** dialogues_id
*会话id
*/
private
java
.
lang
.
String
dialoguesId
;
public
java
.
lang
.
String
getDialoguesId
(){
return
this
.
dialoguesId
;
}
public
void
setDialoguesId
(
java
.
lang
.
String
dialoguesId
){
this
.
dialoguesId
=
dialoguesId
;
}
/** platform
*关联平台
*/
private
java
.
lang
.
String
platform
;
public
java
.
lang
.
String
getPlatform
(){
return
this
.
platform
;
}
public
void
setPlatform
(
java
.
lang
.
String
platform
){
this
.
platform
=
platform
;
}
/** relation_id
*关联平台 对话id
*/
private
java
.
lang
.
String
relationId
;
public
java
.
lang
.
String
getRelationId
(){
return
this
.
relationId
;
}
public
void
setRelationId
(
java
.
lang
.
String
relationId
){
this
.
relationId
=
relationId
;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDeleted
;
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
}
/** CREATOR
*创建人
*/
private
java
.
lang
.
String
creator
;
public
java
.
lang
.
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
this
.
creator
=
creator
;
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
}
/** MODIFIER
*修改人
*/
private
java
.
lang
.
String
modifier
;
public
java
.
lang
.
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
this
.
modifier
=
modifier
;
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/model/BizAiDialogues3rdRelationModel.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
model
;
import
java.io.Serializable
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Id
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.Version
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
/**
* Model class for biz_ai_dialogues_3rd_relation
* AI对话-第三方关联
*/
@Entity
@Table
(
name
=
"biz_ai_dialogues_3rd_relation"
)
@DynamicInsert
@DynamicUpdate
public
class
BizAiDialogues3rdRelationModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Long
id
;
@Column
(
name
=
"id"
,
length
=
19
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
java
.
lang
.
Long
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Long
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** dialogues_id
*会话id
*/
private
java
.
lang
.
String
dialoguesId
;
@Column
(
name
=
"dialogues_id"
,
length
=
120
)
public
java
.
lang
.
String
getDialoguesId
(){
return
this
.
dialoguesId
;
}
public
void
setDialoguesId
(
java
.
lang
.
String
dialoguesId
){
this
.
dialoguesId
=
dialoguesId
;
super
.
addValidField
(
"dialoguesId"
);
}
/** platform
*关联平台
*/
private
java
.
lang
.
String
platform
;
@Column
(
name
=
"platform"
,
length
=
100
)
public
java
.
lang
.
String
getPlatform
(){
return
this
.
platform
;
}
public
void
setPlatform
(
java
.
lang
.
String
platform
){
this
.
platform
=
platform
;
super
.
addValidField
(
"platform"
);
}
/** relation_id
*关联平台 对话id
*/
private
java
.
lang
.
String
relationId
;
@Column
(
name
=
"relation_id"
,
length
=
150
)
public
java
.
lang
.
String
getRelationId
(){
return
this
.
relationId
;
}
public
void
setRelationId
(
java
.
lang
.
String
relationId
){
this
.
relationId
=
relationId
;
super
.
addValidField
(
"relationId"
);
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDeleted
;
@Column
(
name
=
"is_deleted"
,
length
=
1
)
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
super
.
addValidField
(
"isDeleted"
);
}
/** CREATOR
*创建人
*/
private
java
.
lang
.
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
225
)
public
java
.
lang
.
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
}
/** MODIFIER
*修改人
*/
private
java
.
lang
.
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
public
java
.
lang
.
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/repository/BizAiDialogues3rdRelationRepository.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
repository
;
import
cn.com.yict.framemax.data.repository.Repository
;
import
cn.com.poc.ai_dialogues.model.BizAiDialogues3rdRelationModel
;
public
interface
BizAiDialogues3rdRelationRepository
extends
Repository
<
BizAiDialogues3rdRelationModel
,
java
.
lang
.
Long
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/rest/AiDialoguesRest.java
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
rest
;
import
cn.com.poc.ai_dialogues.dto.AiDialoguesCallDto
;
import
cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto
;
import
cn.com.poc.ai_dialogues.dto.BatchDelAiDialoguesDto
;
import
cn.com.poc.expose.dto.DialoguesContextDto
;
...
...
@@ -67,4 +68,10 @@ public interface AiDialoguesRest extends BaseRest {
*/
List
<
String
>
guessYouAsk
(
@RequestParam
(
required
=
false
)
String
type
)
throws
Exception
;
/**
* AI对话
*
* @param aiDialoguesCallDto
*/
void
call
(
@RequestBody
AiDialoguesCallDto
aiDialoguesCallDto
)
throws
Exception
;
}
src/main/java/cn/com/poc/ai_dialogues/rest/impl/AiDialoguesRestImpl.java
View file @
c44e3884
...
...
@@ -2,6 +2,7 @@ package cn.com.poc.ai_dialogues.rest.impl;
import
cn.com.poc.ai_dialogues.aggregate.AiDialoguesService
;
import
cn.com.poc.ai_dialogues.constant.AiDialoguesTypeEnum
;
import
cn.com.poc.ai_dialogues.dto.AiDialoguesCallDto
;
import
cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto
;
import
cn.com.poc.ai_dialogues.dto.BatchDelAiDialoguesDto
;
import
cn.com.poc.ai_dialogues.rest.AiDialoguesRest
;
...
...
@@ -52,7 +53,7 @@ public class AiDialoguesRestImpl implements AiDialoguesRest {
List
<
AiDialoguesTypeEnum
>
typeEnumList
=
new
ArrayList
<>();
for
(
String
type
:
typeList
)
{
typeEnumList
.
add
(
AiDialoguesTypeEnum
.
getByType
(
type
));
typeEnumList
.
add
(
AiDialoguesTypeEnum
.
getByType
(
type
));
}
return
aiDialoguesService
.
getList
(
typeEnumList
,
userBaseEntity
.
getUserId
());
...
...
@@ -93,4 +94,13 @@ public class AiDialoguesRestImpl implements AiDialoguesRest {
public
List
<
String
>
guessYouAsk
(
String
type
)
throws
Exception
{
return
aiDialoguesService
.
guessYouAsk
(
type
);
}
@Override
public
void
call
(
AiDialoguesCallDto
aiDialoguesCallDto
)
throws
Exception
{
Assert
.
notNull
(
aiDialoguesCallDto
);
Assert
.
notBlank
(
aiDialoguesCallDto
.
getDialoguesId
());
Assert
.
notBlank
(
aiDialoguesCallDto
.
getInput
());
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
aiDialoguesService
.
call
(
aiDialoguesCallDto
.
getDialoguesId
(),
aiDialoguesCallDto
.
getInput
(),
currentUser
.
getUserId
(),
aiDialoguesCallDto
.
getOptions
());
}
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/service/BizAiDialogues3rdRelationService.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
service
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialogues3rdRelationEntity
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.List
;
public
interface
BizAiDialogues3rdRelationService
extends
BaseService
{
BizAiDialogues3rdRelationEntity
get
(
java
.
lang
.
Long
id
)
throws
Exception
;
List
<
BizAiDialogues3rdRelationEntity
>
findByExample
(
BizAiDialogues3rdRelationEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
BizAiDialogues3rdRelationEntity
save
(
BizAiDialogues3rdRelationEntity
entity
)
throws
Exception
;
BizAiDialogues3rdRelationEntity
update
(
BizAiDialogues3rdRelationEntity
entity
)
throws
Exception
;
void
deletedById
(
java
.
lang
.
Long
id
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/ai_dialogues/service/impl/BizAiDialogues3rdRelationServiceImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
ai_dialogues
.
service
.
impl
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.poc.ai_dialogues.service.BizAiDialogues3rdRelationService
;
import
cn.com.poc.ai_dialogues.model.BizAiDialogues3rdRelationModel
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialogues3rdRelationEntity
;
import
cn.com.poc.ai_dialogues.convert.BizAiDialogues3rdRelationConvert
;
import
cn.com.poc.ai_dialogues.repository.BizAiDialogues3rdRelationRepository
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Service
;
import
org.apache.commons.collections4.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
org.springframework.util.Assert
;
@Service
public
class
BizAiDialogues3rdRelationServiceImpl
extends
BaseServiceImpl
implements
BizAiDialogues3rdRelationService
{
@Resource
private
BizAiDialogues3rdRelationRepository
repository
;
public
BizAiDialogues3rdRelationEntity
get
(
java
.
lang
.
Long
id
)
throws
Exception
{
Assert
.
notNull
(
id
);
BizAiDialogues3rdRelationModel
model
=
this
.
repository
.
get
(
id
);
if
(
model
==
null
){
return
null
;
}
if
(
"Y"
.
equals
(
model
.
getIsDeleted
())){
return
null
;
}
return
BizAiDialogues3rdRelationConvert
.
modelToEntity
(
model
);
}
public
List
<
BizAiDialogues3rdRelationEntity
>
findByExample
(
BizAiDialogues3rdRelationEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
List
<
BizAiDialogues3rdRelationEntity
>
result
=
new
ArrayList
<
BizAiDialogues3rdRelationEntity
>();
BizAiDialogues3rdRelationModel
model
=
new
BizAiDialogues3rdRelationModel
();
if
(
example
!=
null
){
model
=
BizAiDialogues3rdRelationConvert
.
entityToModel
(
example
);
}
model
.
setIsDeleted
(
"N"
);
List
<
BizAiDialogues3rdRelationModel
>
models
=
this
.
repository
.
findByExample
(
model
,
pagingInfo
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
result
=
models
.
stream
().
map
(
BizAiDialogues3rdRelationConvert:
:
modelToEntity
).
collect
(
Collectors
.
toList
());
}
return
result
;
}
public
BizAiDialogues3rdRelationEntity
save
(
BizAiDialogues3rdRelationEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
entity
.
setId
(
null
);
entity
.
setIsDeleted
(
"N"
);
BizAiDialogues3rdRelationModel
model
=
BizAiDialogues3rdRelationConvert
.
entityToModel
(
entity
);
BizAiDialogues3rdRelationModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizAiDialogues3rdRelationConvert
.
modelToEntity
(
saveModel
);
}
public
BizAiDialogues3rdRelationEntity
update
(
BizAiDialogues3rdRelationEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
Assert
.
notNull
(
entity
.
getId
(),
"update pk can not be null"
);
BizAiDialogues3rdRelationModel
model
=
this
.
repository
.
get
(
entity
.
getId
());
if
(
entity
.
getDialoguesId
()
!=
null
){
model
.
setDialoguesId
(
entity
.
getDialoguesId
());
}
if
(
entity
.
getPlatform
()
!=
null
){
model
.
setPlatform
(
entity
.
getPlatform
());
}
if
(
entity
.
getRelationId
()
!=
null
){
model
.
setRelationId
(
entity
.
getRelationId
());
}
if
(
entity
.
getIsDeleted
()
!=
null
){
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
}
if
(
entity
.
getCreator
()
!=
null
){
model
.
setCreator
(
entity
.
getCreator
());
}
if
(
entity
.
getCreatedTime
()
!=
null
){
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
}
if
(
entity
.
getModifier
()
!=
null
){
model
.
setModifier
(
entity
.
getModifier
());
}
if
(
entity
.
getModifiedTime
()
!=
null
){
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
}
if
(
entity
.
getSysVersion
()
!=
null
){
model
.
setSysVersion
(
entity
.
getSysVersion
());
}
BizAiDialogues3rdRelationModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizAiDialogues3rdRelationConvert
.
modelToEntity
(
saveModel
);
}
public
void
deletedById
(
java
.
lang
.
Long
id
)
throws
Exception
{
Assert
.
notNull
(
id
);
BizAiDialogues3rdRelationModel
model
=
this
.
repository
.
get
(
id
);
if
(
model
!=
null
){
if
(
"N"
.
equals
(
model
.
getIsDeleted
())){
model
.
setIsDeleted
(
"Y"
);
this
.
repository
.
save
(
model
);
}
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/aggregation/AppBuilderService.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
aggregation
;
import
com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator
;
import
org.springframework.retry.annotation.Retryable
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
public
interface
AppBuilderService
{
/**
* 新建对话-【有效期7天】
*
* @param appId 应用的ID - app_id
* @return 返回新建对话的ID - conversation_id
*/
@Retryable
(
maxAttempts
=
2
)
String
conversation
(
String
appId
);
/**
* 文件上传
*
* @param appId 应用的ID - app_id
* @param conversationId 对话的ID - conversation_id
* @param file 文件
* @return 返回文件ID - file_id
*/
@Retryable
(
maxAttempts
=
2
)
String
upload
(
String
appId
,
String
conversationId
,
MultipartFile
file
);
/**
* 获取用户对话列表-【未过期】
*
* @return 返回用户对话列表 - conversation_id
*/
List
<
String
>
getCurrentUserConversationIds
();
/**
* 大模型对话
*
* @param conversationId 对话的ID - conversation_id
* @param query 查询语句
* @param fileIds 文件ID列表 - file_id
* @param stream true: 流式返回,false: 一次性返回
*/
AppBuilderClientIterator
communication
(
String
conversationId
,
String
query
,
List
<
String
>
fileIds
,
Boolean
stream
)
throws
Exception
;
}
src/main/java/cn/com/poc/appbuilder/aggregation/impl/AppBuilderServiceImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
aggregation
.
impl
;
import
cn.com.poc.appbuilder.aggregation.AppBuilderService
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationModel
;
import
cn.com.poc.appbuilder.service.BizAppbuilderConversationService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
cn.hutool.core.io.FileUtil
;
import
com.baidubce.appbuilder.console.appbuilderclient.AppBuilderClient
;
import
com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.*
;
@Service
public
class
AppBuilderServiceImpl
implements
AppBuilderService
{
@Resource
private
FmxParamConfigService
fmxParamConfigService
;
@Resource
private
RedisService
redisService
;
@Resource
private
BizAppbuilderConversationService
bizAppbuilderConversationService
;
private
final
String
APPBUILDER_CONVERSATION_PREFIX
=
"APPBUILDER_CONVERSATION_"
;
@Override
public
String
conversation
(
String
appId
)
{
AppBuilderClient
builder
=
getClient
(
appId
);
String
conversationId
=
null
;
UserBaseEntity
currentMember
=
null
;
try
{
// 获取用户信息
currentMember
=
BlContext
.
getCurrentUserNotException
();
conversationId
=
builder
.
createConversation
();
// 新建对话
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
e
.
getLocalizedMessage
());
}
return
conversationId
;
}
@Override
public
String
upload
(
String
appId
,
String
conversationId
,
MultipartFile
file
)
{
// UserBaseEntity currentMember = null;
try
{
// currentMember = BlContext.getCurrentUserNotException();
// Integer memberId = Math.toIntExact(currentMember.getUserId());
String
key
=
APPBUILDER_CONVERSATION_PREFIX
+
":"
+
conversationId
;
//判断会话有没有过期
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
key
);
if
(
hmget
==
null
)
{
throw
new
BusinessException
(
"会话已过期"
);
}
//获取fileId
AppBuilderClient
builder
=
getClient
(
appId
);
// 上传临时文件
// 获取文件名
UUID
uuid
=
UUID
.
randomUUID
();
File
tempFile
=
null
;
String
suffix
=
"."
+
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
()).
toString
();
//创建临时文件
tempFile
=
File
.
createTempFile
(
uuid
.
toString
(),
suffix
);
FileOutputStream
fos
=
new
FileOutputStream
(
tempFile
);
try
{
// 写入数据到临时文件
byte
[]
bytes
=
file
.
getBytes
();
fos
.
write
(
bytes
);
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"写入临时文件失败"
);
}
finally
{
//关闭临时文件
fos
.
flush
();
fos
.
close
();
}
String
fileId
=
null
;
fileId
=
builder
.
uploadLocalFile
(
conversationId
,
tempFile
.
getAbsolutePath
());
//删除临时文件
tempFile
.
delete
();
//更新redis,把fileId存入redis中
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"app_id"
,
appId
);
map
.
put
(
"file_id"
,
fileId
);
redisService
.
hmset
(
key
,
map
,
redisService
.
getExpire
(
key
));
return
fileId
;
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"抛出异常"
);
}
}
@Override
public
List
<
String
>
getCurrentUserConversationIds
()
{
UserBaseEntity
currentMember
=
null
;
try
{
currentMember
=
BlContext
.
getCurrentUserNotException
();
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"获取用户信息失败"
);
}
Integer
memberId
=
Math
.
toIntExact
(
currentMember
.
getUserId
());
String
key
=
APPBUILDER_CONVERSATION_PREFIX
+
memberId
;
//模糊查询获取键的集合
Map
<
String
,
Map
<
String
,
Object
>>
hmDimMultiGet
=
redisService
.
hmDimMultiGet
(
key
);
List
<
String
>
conversationIds
=
new
ArrayList
<>();
for
(
String
outerKey
:
hmDimMultiGet
.
keySet
())
{
// Split the outerKey using ":" as delimiter
String
[]
parts
=
outerKey
.
split
(
":"
);
if
(
parts
.
length
==
2
)
{
// parts[0] will be "APPBUILDER_CONVERSATION_memberId"
// parts[1] will be the actual conversation_id
String
conversationId
=
parts
[
1
];
conversationIds
.
add
(
conversationId
);
}
}
return
conversationIds
;
}
@Override
public
AppBuilderClientIterator
communication
(
String
conversationId
,
String
query
,
List
<
String
>
fileIds
,
Boolean
stream
)
throws
Exception
{
BizAppbuilderConversationModel
model
=
new
BizAppbuilderConversationModel
();
model
.
setConversationId
(
conversationId
);
model
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizAppbuilderConversationModel
>
models
=
bizAppbuilderConversationService
.
findByExample
(
model
,
null
);
if
(
CollectionUtils
.
isEmpty
(
fileIds
)){
fileIds
=
new
ArrayList
<
String
>();
}
return
getClient
(
models
.
get
(
0
).
getAppId
()).
run
(
query
,
conversationId
,
fileIds
.
toArray
(
new
String
[
fileIds
.
size
()]),
stream
);
}
private
AppBuilderClient
getClient
(
String
appId
)
{
String
token
=
fmxParamConfigService
.
getParam
(
"baidu.appbuilder.token"
);
return
new
AppBuilderClient
(
appId
,
token
);
}
}
src/main/java/cn/com/poc/appbuilder/api/BaiduAppBuilderApi.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
;
import
cn.com.poc.appbuilder.api.base.AppBuilderBaseApi
;
import
cn.com.poc.appbuilder.api.entity.AppBuilderDescribeListRequest
;
import
cn.com.poc.appbuilder.api.entity.AppBuilderDescribeRequest
;
import
cn.com.poc.appbuilder.api.entity.BaiduAppBuilderDescribeAppListResult
;
import
cn.com.poc.common.utils.http.LocalHttpClient
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.client.methods.RequestBuilder
;
import
org.apache.http.entity.StringEntity
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.nio.charset.StandardCharsets
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 11:57
*/
@Component
public
class
BaiduAppBuilderApi
implements
AppBuilderBaseApi
{
@Resource
private
FmxParamConfigService
paramConfigService
;
/**
* 查询用户应用详情
*/
public
String
getDescribeApp
(
AppBuilderDescribeRequest
appBuilderDescribeRequest
)
{
String
token
=
paramConfigService
.
getParam
(
TOKEN_SITE
);
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
.
setUri
(
AppBuilderBaseApi
.
APP_DESCRIBE_URL
)
.
addHeader
(
AppBuilderBaseApi
.
jsonHeader
)
.
addHeader
(
HEADER_AUTHORIZATION
,
"Bearer "
+
token
)
.
setEntity
(
new
StringEntity
(
JSON
.
toJSONString
(
appBuilderDescribeRequest
),
StandardCharsets
.
UTF_8
))
.
build
();
return
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
String
.
class
);
// if (result == null) {
// throw new BusinessException("获取用户应用详情失败");
// }
// if (result.getCode() != null) {
// throw new BusinessException("获取用户应用详情异常:" + result.getCode() + ":" + result.getMessage());
// }
// return result;
}
/**
* 查询用户应用列表
*/
public
BaiduAppBuilderDescribeAppListResult
getDescribeAppList
(
AppBuilderDescribeListRequest
appBuilderDescribeListRequest
)
{
String
token
=
paramConfigService
.
getParam
(
TOKEN_SITE
);
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
.
setHeader
(
AppBuilderBaseApi
.
jsonHeader
)
.
setUri
(
AppBuilderBaseApi
.
APP_DESCRIBE_LIST_URL
)
.
setHeader
(
HEADER_AUTHORIZATION
,
"Bearer "
+
token
)
.
setEntity
(
new
StringEntity
(
JSON
.
toJSONString
(
appBuilderDescribeListRequest
),
StandardCharsets
.
UTF_8
))
.
build
();
BaiduAppBuilderDescribeAppListResult
result
=
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
BaiduAppBuilderDescribeAppListResult
.
class
);
if
(
result
==
null
)
{
throw
new
BusinessException
(
"获取用户应用列表失败"
);
}
if
(
result
.
getCode
()
!=
null
)
{
throw
new
BusinessException
(
"获取用户应用详情异常:"
+
result
.
getCode
()
+
":"
+
result
.
getMessage
());
}
return
result
;
}
}
src/main/java/cn/com/poc/appbuilder/api/base/AppBuilderBaseApi.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
base
;
import
org.apache.http.Header
;
import
org.apache.http.HttpHeaders
;
import
org.apache.http.entity.ContentType
;
import
org.apache.http.message.BasicHeader
;
public
interface
AppBuilderBaseApi
{
/**
* 查询用户应用详情
*/
String
APP_DESCRIBE_URL
=
"https://qianfan.baidubce.com/v2/app?Action=DescribeApp"
;
/**
* 查询用户应用列表
*/
String
APP_DESCRIBE_LIST_URL
=
"https://qianfan.baidubce.com/v2/app?Action=DescribeApps"
;
/**
* 请求头令牌
*/
String
HEADER_AUTHORIZATION
=
"Authorization"
;
/**
* token地址
*/
String
TOKEN_SITE
=
"baidu.appbuilder.token"
;
Header
jsonHeader
=
new
BasicHeader
(
HttpHeaders
.
CONTENT_TYPE
,
ContentType
.
APPLICATION_JSON
.
toString
());
}
src/main/java/cn/com/poc/appbuilder/api/entity/AppBuilderDescribeListRequest.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
java.io.Serializable
;
/**
* @author Jennie 查询用户下状态为已发布的应用列表请求体
* @create 2022-08-10 11:21
*/
public
class
AppBuilderDescribeListRequest
implements
Serializable
{
/**
* 起始位置
* **/
private
String
marker
;
/**
* 数据大小,默认10,最大值100
* **/
private
Integer
maxKeys
;
public
AppBuilderDescribeListRequest
()
{
}
public
AppBuilderDescribeListRequest
(
String
marker
,
Integer
maxKeys
)
{
this
.
marker
=
marker
;
this
.
maxKeys
=
maxKeys
;
}
public
String
getMarker
()
{
return
marker
;
}
public
void
setMarker
(
String
marker
)
{
this
.
marker
=
marker
;
}
public
Integer
getMaxKeys
()
{
return
maxKeys
;
}
public
void
setMaxKeys
(
Integer
maxKeys
)
{
this
.
maxKeys
=
maxKeys
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/AppBuilderDescribeRequest.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
java.io.Serializable
;
/**
* @author Jennie 查询用户下状态为已发布的应用详情请求体
* @create 2022-08-10 11:21
*/
public
class
AppBuilderDescribeRequest
implements
Serializable
{
/**
* 应用id
* **/
private
String
id
;
public
AppBuilderDescribeRequest
()
{
}
public
AppBuilderDescribeRequest
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/BaiduAppBuilderCommonErrorResult.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 11:57
*/
public
class
BaiduAppBuilderCommonErrorResult
{
/**
* 错误码
*/
private
Integer
code
;
/**
* 错误描述
*/
private
String
message
;
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/BaiduAppBuilderDescribeAppListResult.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @Author: Jennie
* @Description: 千帆AppBuilder 查询用户应用详情响应实体
* @Date: 2024/8/7 12:00
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
BaiduAppBuilderDescribeAppListResult
extends
BaiduAppBuilderCommonErrorResult
implements
Serializable
{
/**
* 请求的id
*/
private
String
requestId
;
/**
* 起始位置
*/
private
String
marker
;
/**
* true表示后面还有数据,false表示已经是最后一页
*/
private
boolean
isTruncated
;
/**
* nextMarker下次查询的起始位置
*/
private
String
nextMarker
;
/**
* 本次查询包含的最大结果集数量
*/
private
int
maxKeys
;
public
String
getRequestId
()
{
return
requestId
;
}
public
void
setRequestId
(
String
requestId
)
{
this
.
requestId
=
requestId
;
}
public
String
getMarker
()
{
return
marker
;
}
public
void
setMarker
(
String
marker
)
{
this
.
marker
=
marker
;
}
public
boolean
isTruncated
()
{
return
isTruncated
;
}
public
void
setTruncated
(
boolean
truncated
)
{
isTruncated
=
truncated
;
}
public
String
getNextMarker
()
{
return
nextMarker
;
}
public
void
setNextMarker
(
String
nextMarker
)
{
this
.
nextMarker
=
nextMarker
;
}
public
int
getMaxKeys
()
{
return
maxKeys
;
}
public
void
setMaxKeys
(
int
maxKeys
)
{
this
.
maxKeys
=
maxKeys
;
}
public
List
<
Object
>
getData
()
{
return
data
;
}
public
void
setData
(
List
<
Object
>
data
)
{
this
.
data
=
data
;
}
/**
* 应用对象列表
*/
private
List
<
Object
>
data
;
}
src/main/java/cn/com/poc/appbuilder/api/entity/BaiduAppBuilderDescribeAppResult.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @Author: Jennie
* @Description: 千帆AppBuilder 查询用户应用详情响应实体
* @Date: 2024/8/7 12:00
*/
//@JsonInclude(JsonInclude.Include.NON_NULL)
//@JsonIgnoreProperties(ignoreUnknown = true)
public
class
BaiduAppBuilderDescribeAppResult
extends
BaiduAppBuilderCommonErrorResult
implements
Serializable
{
/**
* 请求的id
*/
private
String
requestId
;
/**
* 应用id
*/
private
String
id
;
/**
* 应用名称
*/
private
String
name
;
/**
* 应用描述
*/
private
String
description
;
/**
* 用户指令
*/
private
String
instruction
;
/**
* 开场白
*/
private
String
prologue
;
/**
* 推荐问题
*/
private
List
<
String
>
exampleQueries
;
//
// /**
// * 追问
// */
// private Map<String, FollowUpQuery> followUpQueries;
//
// /**
// * 引用组件列表
// */
// private List<Component> components;
//
// /**
// * 知识库配置
// */
// private KnowledgeBaseConfig knowledgeBaseConfig;
//
// /**
// * 模型配置
// */
// private ModelConfig modelConfig;
public
String
getRequestId
()
{
return
requestId
;
}
public
void
setRequestId
(
String
requestId
)
{
this
.
requestId
=
requestId
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getInstruction
()
{
return
instruction
;
}
public
void
setInstruction
(
String
instruction
)
{
this
.
instruction
=
instruction
;
}
public
String
getPrologue
()
{
return
prologue
;
}
public
void
setPrologue
(
String
prologue
)
{
this
.
prologue
=
prologue
;
}
public
List
<
String
>
getExampleQueries
()
{
return
exampleQueries
;
}
public
void
setExampleQueries
(
List
<
String
>
exampleQueries
)
{
this
.
exampleQueries
=
exampleQueries
;
}
//
// public Map<String, FollowUpQuery> getFollowUpQueries() {
// return followUpQueries;
// }
//
// public void setFollowUpQueries(Map<String, FollowUpQuery> followUpQueries) {
// this.followUpQueries = followUpQueries;
// }
//
// public List<Component> getComponents() {
// return components;
// }
//
// public void setComponents(List<Component> components) {
// this.components = components;
// }
//
// public KnowledgeBaseConfig getKnowledgeBaseConfig() {
// return knowledgeBaseConfig;
// }
//
// public void setKnowledgeBaseConfig(KnowledgeBaseConfig knowledgeBaseConfig) {
// this.knowledgeBaseConfig = knowledgeBaseConfig;
// }
//
// public ModelConfig getModelConfig() {
// return modelConfig;
// }
//
// public void setModelConfig(ModelConfig modelConfig) {
// this.modelConfig = modelConfig;
// }
}
src/main/java/cn/com/poc/appbuilder/api/entity/ChatConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
ChatConfig
implements
Serializable
{
/**
* 模型id
*/
private
String
modelId
;
/**
* 模型名称
*/
private
String
model
;
/**
* 历史对话参考轮数
*/
private
int
historyChatRounds
;
/**
* rag模型配置
*/
private
RagModelConfig
config
;
public
String
getModelId
()
{
return
modelId
;
}
public
void
setModelId
(
String
modelId
)
{
this
.
modelId
=
modelId
;
}
public
String
getModel
()
{
return
model
;
}
public
void
setModel
(
String
model
)
{
this
.
model
=
model
;
}
public
int
getHistoryChatRounds
()
{
return
historyChatRounds
;
}
public
void
setHistoryChatRounds
(
int
historyChatRounds
)
{
this
.
historyChatRounds
=
historyChatRounds
;
}
public
RagModelConfig
getConfig
()
{
return
config
;
}
public
void
setConfig
(
RagModelConfig
config
)
{
this
.
config
=
config
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/Component.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
Component
implements
Serializable
{
/**
* 组件名称
*/
private
String
name
;
/**
* 组件描述
*/
private
String
description
;
/**
* 组件自定义描述
*/
private
String
customDesc
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getCustomDesc
()
{
return
customDesc
;
}
public
void
setCustomDesc
(
String
customDesc
)
{
this
.
customDesc
=
customDesc
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/FollowUpQuery.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
FollowUpQuery
implements
Serializable
{
/**
* 追问类型 (default | custom)
*/
private
String
type
;
/**
* 追问问题生成prompt
*/
private
String
prompt
;
/**
* 追问问题生成轮数
*/
private
String
round
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getPrompt
()
{
return
prompt
;
}
public
void
setPrompt
(
String
prompt
)
{
this
.
prompt
=
prompt
;
}
public
String
getRound
()
{
return
round
;
}
public
void
setRound
(
String
round
)
{
this
.
round
=
round
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/KnowledgeBase.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
KnowledgeBase
implements
Serializable
{
/**
* 知识库id
*/
private
String
id
;
/**
* 知识库名称
*/
private
String
name
;
/**
* 知识库描述
*/
private
String
description
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/KnowledgeBaseConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
KnowledgeBaseConfig
implements
Serializable
{
/**
* 知识库列表
*/
private
List
<
KnowledgeBase
>
knowledgeBases
;
/**
* 检索配置
*/
private
RetrievalConfig
retrieval
;
public
List
<
KnowledgeBase
>
getKnowledgeBases
()
{
return
knowledgeBases
;
}
public
void
setKnowledgeBases
(
List
<
KnowledgeBase
>
knowledgeBases
)
{
this
.
knowledgeBases
=
knowledgeBases
;
}
public
RetrievalConfig
getRetrieval
()
{
return
retrieval
;
}
public
void
setRetrieval
(
RetrievalConfig
retrieval
)
{
this
.
retrieval
=
retrieval
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/ModelConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
ModelConfig
implements
Serializable
{
/**
* 思考模型配置
*/
private
PlanConfig
plan
;
/**
* 模型配置
*/
private
ChatConfig
chat
;
public
PlanConfig
getPlan
()
{
return
plan
;
}
public
void
setPlan
(
PlanConfig
plan
)
{
this
.
plan
=
plan
;
}
public
ChatConfig
getChat
()
{
return
chat
;
}
public
void
setChat
(
ChatConfig
chat
)
{
this
.
chat
=
chat
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/PlanConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PlanConfig
implements
Serializable
{
/**
* 模型id
*
*
*/
private
String
modelId
;
/**
* 模型名称
*
*
*/
private
String
model
;
/**
* 最大思考轮数
*
*
*/
private
int
maxRounds
;
/**
* rag模型配置
*
*
*/
private
RagModelConfig
config
;
public
String
getModelId
()
{
return
modelId
;
}
public
void
setModelId
(
String
modelId
)
{
this
.
modelId
=
modelId
;
}
public
String
getModel
()
{
return
model
;
}
public
void
setModel
(
String
model
)
{
this
.
model
=
model
;
}
public
int
getMaxRounds
()
{
return
maxRounds
;
}
public
void
setMaxRounds
(
int
maxRounds
)
{
this
.
maxRounds
=
maxRounds
;
}
public
RagModelConfig
getConfig
()
{
return
config
;
}
public
void
setConfig
(
RagModelConfig
config
)
{
this
.
config
=
config
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/RagModelConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
RagModelConfig
implements
Serializable
{
private
float
temperature
;
private
float
topP
;
public
float
getTemperature
()
{
return
temperature
;
}
public
void
setTemperature
(
float
temperature
)
{
this
.
temperature
=
temperature
;
}
public
float
getTopP
()
{
return
topP
;
}
public
void
setTopP
(
float
topP
)
{
this
.
topP
=
topP
;
}
}
src/main/java/cn/com/poc/appbuilder/api/entity/RetrievalConfig.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
api
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
/**
* @Author: Jennie
* @Description:
* @Date: 2024/8/7 12:11
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
RetrievalConfig
implements
Serializable
{
/**
* 是否开启百度搜索
*/
private
boolean
enableWebSearch
;
/**
* 排序策略(Combined | RagFirst | WebSearchFirst), enableWebSearch 等于true时生效
*/
private
String
order
;
/**
* 检索策略(Advanced | Fulltext | Semantic)
*/
private
String
strategy
;
/**
* 召回数量
*/
private
int
topK
;
/**
* 阈值
*/
private
float
threshold
;
public
boolean
isEnableWebSearch
()
{
return
enableWebSearch
;
}
public
void
setEnableWebSearch
(
boolean
enableWebSearch
)
{
this
.
enableWebSearch
=
enableWebSearch
;
}
public
String
getOrder
()
{
return
order
;
}
public
void
setOrder
(
String
order
)
{
this
.
order
=
order
;
}
public
String
getStrategy
()
{
return
strategy
;
}
public
void
setStrategy
(
String
strategy
)
{
this
.
strategy
=
strategy
;
}
public
int
getTopK
()
{
return
topK
;
}
public
void
setTopK
(
int
topK
)
{
this
.
topK
=
topK
;
}
public
float
getThreshold
()
{
return
threshold
;
}
public
void
setThreshold
(
float
threshold
)
{
this
.
threshold
=
threshold
;
}
}
src/main/java/cn/com/poc/appbuilder/dto/AppBuilderCommunicationDto.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
dto
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
AppBuilderCommunicationDto
extends
AppBuilderTTSConfigDto
implements
Serializable
{
/**
* 对话ID
*/
private
String
conversationId
;
/**
* 对话内容
*/
private
String
query
;
/**
* 文档ID列表
*/
private
List
<
String
>
fileIds
;
/**
* 为true时则流式返回,为false时则一次性返回所有内容
*/
private
Boolean
stream
;
public
String
getConversationId
()
{
return
conversationId
;
}
public
void
setConversationId
(
String
conversationId
)
{
this
.
conversationId
=
conversationId
;
}
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
public
List
<
String
>
getFileIds
()
{
return
fileIds
;
}
public
void
setFileIds
(
List
<
String
>
fileIds
)
{
this
.
fileIds
=
fileIds
;
}
public
Boolean
getStream
()
{
return
stream
;
}
public
void
setStream
(
Boolean
stream
)
{
this
.
stream
=
stream
;
}
@Override
public
String
toString
()
{
return
"AppBuilderCommunicationDto{"
+
"conversationId='"
+
conversationId
+
'\''
+
", query='"
+
query
+
'\''
+
", fileIds="
+
fileIds
+
", stream="
+
stream
+
'}'
;
}
}
src/main/java/cn/com/poc/appbuilder/dto/AppBuilderTTSConfigDto.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
dto
;
public
class
AppBuilderTTSConfigDto
{
private
Double
speed
;
//速度
private
Integer
volume
;
//音量
private
Integer
voiceType
;
public
Double
getSpeed
()
{
return
speed
;
}
public
void
setSpeed
(
Double
speed
)
{
this
.
speed
=
speed
;
}
public
Integer
getVolume
()
{
return
volume
;
}
public
void
setVolume
(
Integer
volume
)
{
this
.
volume
=
volume
;
}
public
Integer
getVoiceType
()
{
return
voiceType
;
}
public
void
setVoiceType
(
Integer
voiceType
)
{
this
.
voiceType
=
voiceType
;
}
}
src/main/java/cn/com/poc/appbuilder/model/BizAppbuilderConversationModel.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
model
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.*
;
import
java.io.Serializable
;
/**
* Model class for biz_appbuilder_conversation
* appbuilder 对话
*/
@Entity
@Table
(
name
=
"biz_appbuilder_conversation"
)
@DynamicInsert
@DynamicUpdate
public
class
BizAppbuilderConversationModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*
*/
private
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
Integer
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** appId
*
*/
private
String
appId
;
@Column
(
name
=
"appId"
,
length
=
200
)
public
String
getAppId
(){
return
this
.
appId
;
}
public
void
setAppId
(
String
appId
){
this
.
appId
=
appId
;
super
.
addValidField
(
"appId"
);
}
/** conversationId
*
*/
private
String
conversationId
;
@Column
(
name
=
"conversationId"
,
length
=
200
)
public
String
getConversationId
(){
return
this
.
conversationId
;
}
public
void
setConversationId
(
String
conversationId
){
this
.
conversationId
=
conversationId
;
super
.
addValidField
(
"conversationId"
);
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private
String
isDeleted
;
@Column
(
name
=
"is_deleted"
,
length
=
1
)
public
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
super
.
addValidField
(
"isDeleted"
);
}
/** CREATOR
*创建人
*/
private
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
225
)
public
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
String
creator
){
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
}
/** MODIFIER
*修改人
*/
private
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
public
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
String
modifier
){
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
public
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/model/BizAppbuilderConversationRecordModel.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
model
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.*
;
import
java.io.Serializable
;
/**
* Model class for biz_appbuilder_conversation_record
*
*/
@Entity
@Table
(
name
=
"biz_appbuilder_conversation_record"
)
@DynamicInsert
@DynamicUpdate
public
class
BizAppbuilderConversationRecordModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*
*/
private
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
Integer
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** conversationId
*
*/
private
String
conversationId
;
@Column
(
name
=
"conversationId"
,
length
=
200
)
public
String
getConversationId
(){
return
this
.
conversationId
;
}
public
void
setConversationId
(
String
conversationId
){
this
.
conversationId
=
conversationId
;
super
.
addValidField
(
"conversationId"
);
}
/** response
*
*/
private
String
response
;
@Column
(
name
=
"response"
,
length
=
1073741824
)
public
String
getResponse
(){
return
this
.
response
;
}
public
void
setResponse
(
String
response
){
this
.
response
=
response
;
super
.
addValidField
(
"response"
);
}
/** result
*
*/
private
String
result
;
@Column
(
name
=
"result"
,
length
=
2147483647
)
public
String
getResult
(){
return
this
.
result
;
}
public
void
setResult
(
String
result
){
this
.
result
=
result
;
super
.
addValidField
(
"result"
);
}
/** CREATOR
*创建人
*/
private
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
225
)
public
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
String
creator
){
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
}
/** MODIFIER
*修改人
*/
private
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
public
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
String
modifier
){
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
public
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/model/BizAppbuilderInfoModel.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
model
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
/**
* Model class for biz_appbuilder_info
* 应用匹配
*/
@Entity
@Table
(
name
=
"biz_appbuilder_info"
)
@DynamicInsert
@DynamicUpdate
public
class
BizAppbuilderInfoModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** appId
*
*/
private
Integer
appId
;
@Column
(
name
=
"appId"
,
length
=
20
)
@Id
public
Integer
getAppId
(){
return
this
.
appId
;
}
public
void
setAppId
(
Integer
appId
){
this
.
appId
=
appId
;
super
.
addValidField
(
"appId"
);
}
/** id
*
*/
private
String
id
;
@Column
(
name
=
"id"
,
length
=
100
)
public
String
getId
(){
return
this
.
id
;
}
public
void
setId
(
String
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** requestId
*
*/
private
String
requestId
;
@Column
(
name
=
"requestId"
,
length
=
100
)
public
String
getRequestId
(){
return
this
.
requestId
;
}
public
void
setRequestId
(
String
requestId
){
this
.
requestId
=
requestId
;
super
.
addValidField
(
"requestId"
);
}
/** name
*
*/
private
String
name
;
@Column
(
name
=
"name"
,
length
=
100
)
public
String
getName
(){
return
this
.
name
;
}
public
void
setName
(
String
name
){
this
.
name
=
name
;
super
.
addValidField
(
"name"
);
}
/** description
*
*/
private
String
description
;
@Column
(
name
=
"description"
,
length
=
2147483647
)
public
String
getDescription
(){
return
this
.
description
;
}
public
void
setDescription
(
String
description
){
this
.
description
=
description
;
super
.
addValidField
(
"description"
);
}
/** instruction
*
*/
private
String
instruction
;
@Column
(
name
=
"instruction"
,
length
=
2147483647
)
public
String
getInstruction
(){
return
this
.
instruction
;
}
public
void
setInstruction
(
String
instruction
){
this
.
instruction
=
instruction
;
super
.
addValidField
(
"instruction"
);
}
/** prologue
*
*/
private
String
prologue
;
@Column
(
name
=
"prologue"
,
length
=
2147483647
)
public
String
getPrologue
(){
return
this
.
prologue
;
}
public
void
setPrologue
(
String
prologue
){
this
.
prologue
=
prologue
;
super
.
addValidField
(
"prologue"
);
}
/** exampleQueries
*
*/
private
String
exampleQueries
;
@Column
(
name
=
"exampleQueries"
,
length
=
1073741824
)
public
String
getExampleQueries
(){
return
this
.
exampleQueries
;
}
public
void
setExampleQueries
(
String
exampleQueries
){
this
.
exampleQueries
=
exampleQueries
;
super
.
addValidField
(
"exampleQueries"
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/repository/BizAppbuilderConversationRecordRepository.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
repository
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationRecordModel
;
import
cn.com.yict.framemax.data.repository.Repository
;
public
interface
BizAppbuilderConversationRecordRepository
extends
Repository
<
BizAppbuilderConversationRecordModel
,
Integer
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/repository/BizAppbuilderConversationRepository.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
repository
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationModel
;
import
cn.com.yict.framemax.data.repository.Repository
;
public
interface
BizAppbuilderConversationRepository
extends
Repository
<
BizAppbuilderConversationModel
,
Integer
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/repository/BizAppbuilderInfoRepository.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
repository
;
import
cn.com.poc.appbuilder.model.BizAppbuilderInfoModel
;
import
cn.com.yict.framemax.data.repository.Repository
;
public
interface
BizAppbuilderInfoRepository
extends
Repository
<
BizAppbuilderInfoModel
,
Integer
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/rest/AppBuilderDescribeAppRest.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
rest
;
import
cn.com.poc.appbuilder.api.entity.BaiduAppBuilderDescribeAppListResult
;
import
cn.com.poc.appbuilder.api.entity.BaiduAppBuilderDescribeAppResult
;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Permission
(
Access
.
Anonymous
)
public
interface
AppBuilderDescribeAppRest
extends
BaseRest
{
/**
* 查询用户应用详情
*
* @param appId 应用的ID - app_id
* @return 返回用户应用详情
*/
BaiduAppBuilderDescribeAppResult
getDescribeApp
(
@RequestParam
String
appId
)
throws
Exception
;
/**
* 查询用户应用详情
*
* @param marker 起始位置
* @param maxKeys 数据大小,默认10,最大值100
* @return 返回用户应用列表
*/
BaiduAppBuilderDescribeAppListResult
getDescribeAppList
(
@RequestParam
String
marker
,
@RequestParam
Integer
maxKeys
)
throws
Exception
;
}
src/main/java/cn/com/poc/appbuilder/rest/AppBuilderRest.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
rest
;
import
cn.com.poc.appbuilder.dto.AppBuilderCommunicationDto
;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
@Permission
(
Access
.
Safety
)
public
interface
AppBuilderRest
extends
BaseRest
{
/**
* 新建对话-【有效期7天】
*
* @param appId 应用的ID - app_id
* @return 返回新建对话的ID - conversation_id
*/
String
conversation
(
@RequestParam
String
appId
)
throws
Exception
;
/**
* 文件上传
*
* @param appId 应用的ID - app_id
* @param conversationId 对话的ID - conversation_id
* @param file 文件
* @return 返回文件ID - file_id
*/
String
upload
(
@RequestParam
String
appId
,
@RequestParam
String
conversationId
,
@RequestParam
MultipartFile
file
)
throws
Exception
;
/**
* 获取用户对话列表-【未过期】
*
* @return 返回用户对话列表 - conversation_id
*/
List
<
String
>
getCurrentUserConversationIds
()
throws
Exception
;
/**
* 大模型对话
*
* @param dto
* @param httpServletResponse
*/
void
communication
(
@RequestBody
AppBuilderCommunicationDto
dto
,
HttpServletResponse
httpServletResponse
)
throws
IOException
;
}
src/main/java/cn/com/poc/appbuilder/rest/impl/AppBuilderDescribeAppRestImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
rest
.
impl
;
import
cn.com.poc.appbuilder.api.BaiduAppBuilderApi
;
import
cn.com.poc.appbuilder.api.entity.AppBuilderDescribeListRequest
;
import
cn.com.poc.appbuilder.api.entity.AppBuilderDescribeRequest
;
import
cn.com.poc.appbuilder.api.entity.BaiduAppBuilderDescribeAppListResult
;
import
cn.com.poc.appbuilder.api.entity.BaiduAppBuilderDescribeAppResult
;
import
cn.com.poc.appbuilder.model.BizAppbuilderInfoModel
;
import
cn.com.poc.appbuilder.rest.AppBuilderDescribeAppRest
;
import
cn.com.poc.appbuilder.service.BizAppbuilderInfoService
;
import
cn.com.poc.common.utils.Assert
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.yict.framemax.core.utils.BeanUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Component
public
class
AppBuilderDescribeAppRestImpl
implements
AppBuilderDescribeAppRest
{
@Resource
private
BaiduAppBuilderApi
baiduAppBuilderApi
;
@Resource
private
BizAppbuilderInfoService
bizAppbuilderInfoService
;
@Override
public
BaiduAppBuilderDescribeAppResult
getDescribeApp
(
String
appId
)
throws
Exception
{
Assert
.
notNull
(
appId
,
"参数不能为空"
);
BaiduAppBuilderDescribeAppResult
baiduAppBuilderDescribeAppResult
=
new
BaiduAppBuilderDescribeAppResult
();
BizAppbuilderInfoModel
model
=
new
BizAppbuilderInfoModel
();
model
.
setId
(
appId
);
List
<
BizAppbuilderInfoModel
>
models
=
bizAppbuilderInfoService
.
findByExample
(
model
,
null
);
if
(
CollectionUtils
.
isEmpty
(
models
))
{
AppBuilderDescribeRequest
appBuilderDescribeRequest
=
new
AppBuilderDescribeRequest
(
appId
);
String
str
=
baiduAppBuilderApi
.
getDescribeApp
(
appBuilderDescribeRequest
);
baiduAppBuilderDescribeAppResult
=
JSONObject
.
parseObject
(
str
,
BaiduAppBuilderDescribeAppResult
.
class
);
}
else
{
BeanUtils
.
copy
(
models
.
get
(
0
),
baiduAppBuilderDescribeAppResult
);
String
exampleQueries
=
models
.
get
(
0
).
getExampleQueries
();
List
<
String
>
queriesList
=
(
List
<
String
>)
JsonUtils
.
deSerialize
(
exampleQueries
,
new
TypeReference
<
List
<
String
>>()
{
}.
getType
());
baiduAppBuilderDescribeAppResult
.
setExampleQueries
(
queriesList
);
}
return
baiduAppBuilderDescribeAppResult
;
}
@Override
public
BaiduAppBuilderDescribeAppListResult
getDescribeAppList
(
String
marker
,
Integer
maxKeys
)
throws
Exception
{
Assert
.
notNull
(
marker
,
"参数不能为空"
);
Assert
.
notNull
(
maxKeys
,
"参数不能为空"
);
AppBuilderDescribeListRequest
appBuilderDescribeListRequest
=
new
AppBuilderDescribeListRequest
(
marker
,
maxKeys
);
return
baiduAppBuilderApi
.
getDescribeAppList
(
appBuilderDescribeListRequest
);
}
}
src/main/java/cn/com/poc/appbuilder/rest/impl/AppBuilderRestImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
rest
.
impl
;
import
cn.com.poc.appbuilder.aggregation.AppBuilderService
;
import
cn.com.poc.appbuilder.dto.AppBuilderCommunicationDto
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationModel
;
import
cn.com.poc.appbuilder.rest.AppBuilderRest
;
import
cn.com.poc.appbuilder.service.BizAppbuilderConversationService
;
import
cn.com.poc.common.utils.Assert
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.SSEUtil
;
import
cn.com.poc.common.utils.StringUtils
;
import
com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator
;
import
com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientResult
;
import
com.baidubce.appbuilder.model.appbuilderclient.Event
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
AppBuilderRestImpl
implements
AppBuilderRest
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AppBuilderRest
.
class
);
@Resource
private
AppBuilderService
appBuilderService
;
@Resource
private
BizAppbuilderConversationService
bizAppbuilderConversationService
;
@Override
public
String
conversation
(
String
appId
)
throws
Exception
{
Assert
.
notNull
(
appId
,
"参数不能为空"
);
String
conversationId
=
appBuilderService
.
conversation
(
appId
);
//持久化
BizAppbuilderConversationModel
model
=
new
BizAppbuilderConversationModel
();
model
.
setAppId
(
appId
);
model
.
setConversationId
(
conversationId
);
bizAppbuilderConversationService
.
save
(
model
);
return
conversationId
;
}
@Override
public
String
upload
(
String
appId
,
String
conversationId
,
MultipartFile
file
)
throws
Exception
{
Assert
.
notNull
(
appId
,
"参数不能为空"
);
Assert
.
notNull
(
conversationId
,
"参数不能为空"
);
return
appBuilderService
.
upload
(
appId
,
conversationId
,
file
);
}
@Override
public
List
<
String
>
getCurrentUserConversationIds
()
{
return
appBuilderService
.
getCurrentUserConversationIds
();
}
@Override
public
void
communication
(
AppBuilderCommunicationDto
dto
,
HttpServletResponse
httpServletResponse
)
throws
IOException
{
Assert
.
notNull
(
dto
,
"参数不能为空"
);
Assert
.
notBlank
(
dto
.
getQuery
(),
"对话内容不能为空"
);
Assert
.
notBlank
(
dto
.
getConversationId
(),
"对话ID不能为空"
);
SSEUtil
sseUtil
=
new
SSEUtil
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
try
{
String
conversationId
=
dto
.
getConversationId
();
String
query
=
dto
.
getQuery
();
List
<
String
>
fileIds
=
CollectionUtils
.
isEmpty
(
dto
.
getFileIds
())
?
new
ArrayList
<
String
>(
0
)
:
dto
.
getFileIds
();
AppBuilderClientIterator
iterator
=
appBuilderService
.
communication
(
conversationId
,
query
,
fileIds
,
dto
.
getStream
());
while
(
iterator
.
hasNext
())
{
AppBuilderClientResult
res
=
iterator
.
next
();
sseUtil
.
send
(
JsonUtils
.
serialize
(
res
));
if
(
ArrayUtils
.
isNotEmpty
(
res
.
getEvents
()))
{
Event
event
=
res
.
getEvents
()[
0
];
String
eventType
=
event
.
getEventType
();
if
(
"chatflow"
.
equals
(
eventType
))
{
Map
<
String
,
Object
>
detail
=
event
.
getDetail
();
if
(
detail
.
containsKey
(
"message"
))
{
String
mess
=
detail
.
get
(
"message"
).
toString
();
stringBuilder
.
append
(
mess
);
}
}
}
else
if
(
StringUtils
.
isNotEmpty
(
res
.
getAnswer
()))
{
stringBuilder
.
append
(
res
.
getAnswer
());
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"appBuilder#communication对话失败,错误信息:{},入参:{}"
,
e
.
getLocalizedMessage
(),
dto
);
sseUtil
.
completeByError
(
"对话失败: "
+
e
.
getMessage
());
}
finally
{
}
}
}
src/main/java/cn/com/poc/appbuilder/service/BizAppbuilderConversationRecordService.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationRecordModel
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.Collection
;
import
java.util.List
;
public
interface
BizAppbuilderConversationRecordService
extends
BaseService
{
BizAppbuilderConversationRecordModel
get
(
Integer
id
)
throws
Exception
;
List
<
BizAppbuilderConversationRecordModel
>
findByExample
(
BizAppbuilderConversationRecordModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
void
delete
(
BizAppbuilderConversationRecordModel
model
)
throws
Exception
;
void
deleteById
(
Integer
id
)
throws
Exception
;
void
deleteAll
(
Collection
<
Integer
>
ids
)
throws
Exception
;
BizAppbuilderConversationRecordModel
save
(
BizAppbuilderConversationRecordModel
model
)
throws
Exception
;
Collection
<
BizAppbuilderConversationRecordModel
>
saveAll
(
Collection
<
BizAppbuilderConversationRecordModel
>
models
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/service/BizAppbuilderConversationService.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationModel
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.Collection
;
import
java.util.List
;
public
interface
BizAppbuilderConversationService
extends
BaseService
{
BizAppbuilderConversationModel
get
(
Integer
id
)
throws
Exception
;
List
<
BizAppbuilderConversationModel
>
findByExample
(
BizAppbuilderConversationModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
void
delete
(
BizAppbuilderConversationModel
model
)
throws
Exception
;
void
deleteById
(
Integer
id
)
throws
Exception
;
void
deleteAll
(
Collection
<
Integer
>
ids
)
throws
Exception
;
BizAppbuilderConversationModel
save
(
BizAppbuilderConversationModel
model
)
throws
Exception
;
Collection
<
BizAppbuilderConversationModel
>
saveAll
(
Collection
<
BizAppbuilderConversationModel
>
models
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/service/BizAppbuilderInfoService.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
;
import
cn.com.poc.appbuilder.model.BizAppbuilderInfoModel
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.List
;
public
interface
BizAppbuilderInfoService
extends
BaseService
{
BizAppbuilderInfoModel
get
(
Integer
id
)
throws
Exception
;
List
<
BizAppbuilderInfoModel
>
findByExample
(
BizAppbuilderInfoModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/service/impl/BizAppbuilderConversationRecordServiceImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
.
impl
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationRecordModel
;
import
cn.com.poc.appbuilder.repository.BizAppbuilderConversationRecordRepository
;
import
cn.com.poc.appbuilder.service.BizAppbuilderConversationRecordService
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Collection
;
import
java.util.List
;
@Service
public
class
BizAppbuilderConversationRecordServiceImpl
extends
BaseServiceImpl
implements
BizAppbuilderConversationRecordService
{
@Resource
private
BizAppbuilderConversationRecordRepository
repository
;
public
BizAppbuilderConversationRecordModel
get
(
Integer
id
)
throws
Exception
{
return
this
.
repository
.
get
(
id
);
}
public
List
<
BizAppbuilderConversationRecordModel
>
findByExample
(
BizAppbuilderConversationRecordModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
if
(
example
==
null
){
example
=
new
BizAppbuilderConversationRecordModel
();
}
return
this
.
repository
.
findByExample
(
example
,
pagingInfo
);
}
public
void
delete
(
BizAppbuilderConversationRecordModel
model
)
throws
Exception
{
this
.
repository
.
remove
(
model
);
}
public
void
deleteById
(
Integer
id
)
throws
Exception
{
this
.
repository
.
removeByPk
(
id
);
}
public
void
deleteAll
(
Collection
<
Integer
>
ids
)
throws
Exception
{
this
.
repository
.
removeAllByPk
(
ids
);
}
public
BizAppbuilderConversationRecordModel
save
(
BizAppbuilderConversationRecordModel
model
)
throws
Exception
{
return
this
.
repository
.
save
(
model
);
}
public
Collection
<
BizAppbuilderConversationRecordModel
>
saveAll
(
Collection
<
BizAppbuilderConversationRecordModel
>
models
)
throws
Exception
{
return
this
.
repository
.
saveAll
(
models
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/service/impl/BizAppbuilderConversationServiceImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
.
impl
;
import
cn.com.poc.appbuilder.model.BizAppbuilderConversationModel
;
import
cn.com.poc.appbuilder.repository.BizAppbuilderConversationRepository
;
import
cn.com.poc.appbuilder.service.BizAppbuilderConversationService
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Collection
;
import
java.util.List
;
@Service
public
class
BizAppbuilderConversationServiceImpl
extends
BaseServiceImpl
implements
BizAppbuilderConversationService
{
@Resource
private
BizAppbuilderConversationRepository
repository
;
public
BizAppbuilderConversationModel
get
(
Integer
id
)
throws
Exception
{
return
this
.
repository
.
get
(
id
);
}
public
List
<
BizAppbuilderConversationModel
>
findByExample
(
BizAppbuilderConversationModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
if
(
example
==
null
){
example
=
new
BizAppbuilderConversationModel
();
}
return
this
.
repository
.
findByExample
(
example
,
pagingInfo
);
}
public
void
delete
(
BizAppbuilderConversationModel
model
)
throws
Exception
{
this
.
repository
.
remove
(
model
);
}
public
void
deleteById
(
Integer
id
)
throws
Exception
{
this
.
repository
.
removeByPk
(
id
);
}
public
void
deleteAll
(
Collection
<
Integer
>
ids
)
throws
Exception
{
this
.
repository
.
removeAllByPk
(
ids
);
}
public
BizAppbuilderConversationModel
save
(
BizAppbuilderConversationModel
model
)
throws
Exception
{
return
this
.
repository
.
save
(
model
);
}
public
Collection
<
BizAppbuilderConversationModel
>
saveAll
(
Collection
<
BizAppbuilderConversationModel
>
models
)
throws
Exception
{
return
this
.
repository
.
saveAll
(
models
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/appbuilder/service/impl/BizAppbuilderInfoServiceImpl.java
0 → 100644
View file @
c44e3884
package
cn
.
com
.
poc
.
appbuilder
.
service
.
impl
;
import
cn.com.poc.appbuilder.model.BizAppbuilderInfoModel
;
import
cn.com.poc.appbuilder.repository.BizAppbuilderInfoRepository
;
import
cn.com.poc.appbuilder.service.BizAppbuilderInfoService
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author 52747
*/
@Service
public
class
BizAppbuilderInfoServiceImpl
extends
BaseServiceImpl
implements
BizAppbuilderInfoService
{
@Resource
private
BizAppbuilderInfoRepository
repository
;
@Override
public
BizAppbuilderInfoModel
get
(
Integer
id
)
throws
Exception
{
return
this
.
repository
.
get
(
id
);
}
@Override
public
List
<
BizAppbuilderInfoModel
>
findByExample
(
BizAppbuilderInfoModel
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
if
(
example
==
null
)
{
example
=
new
BizAppbuilderInfoModel
();
}
return
this
.
repository
.
findByExample
(
example
,
pagingInfo
);
}
}
\ No newline at end of file
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