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
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
poc
poc-api
Commits
fc5cac7c
Commit
fc5cac7c
authored
Oct 17, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: 优化function call 逻辑
parent
c8c7e4e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
201 additions
and
328 deletions
+201
-328
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+3
-2
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+82
-80
AgentApplicationInfoConvert.java
...gent_application/convert/AgentApplicationInfoConvert.java
+5
-22
BizAgentApplicationPublishConvert.java
...pplication/convert/BizAgentApplicationPublishConvert.java
+10
-21
AgentApplicationCommConfig.java
.../agent_application/domain/AgentApplicationCommConfig.java
+10
-35
BizAgentApplicationInfoEntity.java
...ent_application/entity/BizAgentApplicationInfoEntity.java
+0
-26
BizAgentApplicationPublishEntity.java
..._application/entity/BizAgentApplicationPublishEntity.java
+0
-25
BizAgentApplicationInfoModel.java
...agent_application/model/BizAgentApplicationInfoModel.java
+0
-32
BizAgentApplicationPublishModel.java
...nt_application/model/BizAgentApplicationPublishModel.java
+0
-34
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+22
-9
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+21
-9
AbstractLargeModelFunction.java
...source/demand/ai/function/AbstractLargeModelFunction.java
+4
-10
SearchMemoryContentByNameFunction.java
...demand/ai/function/SearchMemoryContentByNameFunction.java
+5
-0
SearchMemoryContentFunction.java
...ource/demand/ai/function/SearchMemoryContentFunction.java
+5
-0
SetLongMemoryFunction.java
...ty/resource/demand/ai/function/SetLongMemoryFunction.java
+26
-21
SetValueMemoryFunction.java
...y/resource/demand/ai/function/SetValueMemoryFunction.java
+8
-2
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
fc5cac7c
...
...
@@ -3,6 +3,7 @@ package cn.com.poc.agent_application.aggregate;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Tool
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -17,9 +18,9 @@ public interface AgentApplicationInfoService {
/**
* 应用预览
*/
String
callAgentApplication
(
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
String
callAgentApplication
(
String
identifier
,
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
Integer
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
List
<
Message
>
messages
,
Boolean
isLongMemory
,
String
[]
variableStructure
,
boolean
isFunction
,
String
[]
functionName
,
List
<
String
>
functionConfig
,
String
useStatu
s
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
List
<
Message
>
messages
,
List
<
Tool
>
tool
s
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
...
...
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
fc5cac7c
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/poc/agent_application/convert/AgentApplicationInfoConvert.java
View file @
fc5cac7c
...
...
@@ -4,9 +4,9 @@ import cn.com.poc.agent_application.domain.AgentApplicationBaseInfo;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
import
cn.com.poc.agent_application.model.BizAgentApplicationInfoModel
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.dto.AgentApplicationInfoDto
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.model.BizAgentApplicationInfoModel
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryItem
;
import
cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem
;
import
cn.com.poc.common.utils.JsonUtils
;
...
...
@@ -43,11 +43,7 @@ public class AgentApplicationInfoConvert {
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPublishTime
(
model
.
getPublishTime
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setIsFunction
(
model
.
getIsFunction
());
if
(
StringUtils
.
isNotBlank
(
model
.
getFunctionName
()))
{
entity
.
setFunctionName
(
JsonUtils
.
deSerialize
(
model
.
getFunctionName
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
...
...
@@ -87,10 +83,6 @@ public class AgentApplicationInfoConvert {
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsFunction
(
entity
.
getIsFunction
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getFunctionName
()))
{
model
.
setFunctionName
(
JsonUtils
.
serialize
(
entity
.
getFunctionName
()));
}
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
...
...
@@ -137,8 +129,7 @@ public class AgentApplicationInfoConvert {
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setFunctionName
(
entity
.
getFunctionName
());
commConfig
.
setIsFunction
(
entity
.
getIsFunction
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
...
@@ -184,10 +175,6 @@ public class AgentApplicationInfoConvert {
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
}
entity
.
setIsLongMemory
(
dto
.
getCommConfig
().
getIsLongMemory
());
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getFunctionName
()))
{
entity
.
setFunctionName
(
dto
.
getCommConfig
().
getFunctionName
());
}
entity
.
setIsFunction
(
dto
.
getCommConfig
().
getIsFunction
());
}
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
...
...
@@ -221,12 +208,8 @@ public class AgentApplicationInfoConvert {
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setIsLongMemory
(
infoQueryItem
.
getIsLongMemory
());
entity
.
setIsFunction
(
infoQueryItem
.
getIsFunction
());
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getFunctionName
()))
{
entity
.
setFunctionName
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getFunctionName
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getVariableStructure
(),
String
[].
class
));
}
...
...
src/main/java/cn/com/poc/agent_application/convert/BizAgentApplicationPublishConvert.java
View file @
fc5cac7c
package
cn
.
com
.
poc
.
agent_application
.
convert
;
package
cn
.
com
.
poc
.
agent_application
.
convert
;
import
cn.com.poc.agent_application.domain.AgentApplicationBaseInfo
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
import
cn.com.poc.agent_application.model.BizAgentApplicationPublishModel
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.model.BizAgentApplicationPublishModel
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.tencent.core.utils.JsonUtil
;
...
...
@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
public
class
BizAgentApplicationPublishConvert
{
public
static
BizAgentApplicationPublishEntity
modelToEntity
(
BizAgentApplicationPublishModel
model
){
public
static
BizAgentApplicationPublishEntity
modelToEntity
(
BizAgentApplicationPublishModel
model
)
{
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setMemberId
(
model
.
getMemberId
());
...
...
@@ -27,12 +27,11 @@ public class BizAgentApplicationPublishConvert {
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setIsFunction
(
model
.
getIsFunction
());
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
...
...
@@ -59,7 +58,7 @@ public class BizAgentApplicationPublishConvert {
return
entity
;
}
public
static
BizAgentApplicationPublishModel
entityToModel
(
BizAgentApplicationPublishEntity
entity
){
public
static
BizAgentApplicationPublishModel
entityToModel
(
BizAgentApplicationPublishEntity
entity
)
{
BizAgentApplicationPublishModel
model
=
new
BizAgentApplicationPublishModel
();
model
.
setId
(
entity
.
getId
());
model
.
setMemberId
(
entity
.
getMemberId
());
...
...
@@ -70,10 +69,6 @@ public class BizAgentApplicationPublishConvert {
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsFunction
(
entity
.
getIsFunction
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getFunctionName
()))
{
model
.
setFunctionName
(
JsonUtils
.
serialize
(
entity
.
getFunctionName
()));
}
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
...
...
@@ -100,8 +95,8 @@ public class BizAgentApplicationPublishConvert {
model
.
setSysVersion
(
entity
.
getSysVersion
());
return
model
;
}
public
static
BizAgentApplicationPublishDto
entityToDto
(
BizAgentApplicationPublishEntity
entity
){
public
static
BizAgentApplicationPublishDto
entityToDto
(
BizAgentApplicationPublishEntity
entity
)
{
BizAgentApplicationPublishDto
dto
=
new
BizAgentApplicationPublishDto
();
AgentApplicationBaseInfo
baseInfo
=
new
AgentApplicationBaseInfo
();
baseInfo
.
setMemberId
(
entity
.
getMemberId
());
...
...
@@ -121,8 +116,6 @@ public class BizAgentApplicationPublishConvert {
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setIsFunction
(
entity
.
getIsFunction
());
commConfig
.
setFunctionName
(
entity
.
getFunctionName
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
...
@@ -143,7 +136,7 @@ public class BizAgentApplicationPublishConvert {
return
dto
;
}
public
static
BizAgentApplicationPublishEntity
dtoToEntity
(
BizAgentApplicationPublishDto
dto
){
public
static
BizAgentApplicationPublishEntity
dtoToEntity
(
BizAgentApplicationPublishDto
dto
)
{
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getBaseInfo
()))
{
entity
.
setAgentId
(
dto
.
getBaseInfo
().
getAgentId
());
...
...
@@ -165,10 +158,6 @@ public class BizAgentApplicationPublishConvert {
entity
.
setContinuousQuestionSystem
(
dto
.
getCommConfig
().
getContinuousQuestionSystem
());
entity
.
setContinuousQuestionTurn
(
dto
.
getCommConfig
().
getContinuousQuestionTurn
());
entity
.
setIsLongMemory
(
dto
.
getCommConfig
().
getIsLongMemory
());
entity
.
setIsFunction
(
dto
.
getCommConfig
().
getIsFunction
());
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getFunctionName
()))
{
entity
.
setFunctionName
(
dto
.
getCommConfig
().
getFunctionName
());
}
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getVariableStructure
()))
{
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
}
...
...
src/main/java/cn/com/poc/agent_application/domain/AgentApplicationCommConfig.java
View file @
fc5cac7c
...
...
@@ -75,57 +75,32 @@ public class AgentApplicationCommConfig {
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
}
/** variable_structure
*变量结构
/**
* variable_structure
* 变量结构
*/
private
java
.
lang
.
String
[]
variableStructure
;
public
java
.
lang
.
String
[]
getVariableStructure
(){
public
java
.
lang
.
String
[]
getVariableStructure
()
{
return
this
.
variableStructure
;
}
public
void
setVariableStructure
(
java
.
lang
.
String
[]
variableStructure
){
public
void
setVariableStructure
(
java
.
lang
.
String
[]
variableStructure
)
{
this
.
variableStructure
=
variableStructure
;
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
/**
* is_long_memory
* 是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
public
java
.
lang
.
String
getIsLongMemory
()
{
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
)
{
this
.
isLongMemory
=
isLongMemory
;
}
/** function_name
*方法名
*/
private
java
.
lang
.
String
[]
functionName
;
public
java
.
lang
.
String
[]
getFunctionName
(){
return
this
.
functionName
;
}
public
void
setFunctionName
(
java
.
lang
.
String
[]
functionName
){
this
.
functionName
=
functionName
;
}
/** is_function
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isFunction
;
public
java
.
lang
.
String
getIsFunction
(){
return
this
.
isFunction
;
}
public
void
setIsFunction
(
java
.
lang
.
String
isFunction
){
this
.
isFunction
=
isFunction
;
}
}
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationInfoEntity.java
View file @
fc5cac7c
...
...
@@ -261,32 +261,6 @@ public class BizAgentApplicationInfoEntity {
this
.
isLongMemory
=
isLongMemory
;
}
/** function_name
*方法名
*/
private
java
.
lang
.
String
[]
functionName
;
public
java
.
lang
.
String
[]
getFunctionName
(){
return
this
.
functionName
;
}
public
void
setFunctionName
(
java
.
lang
.
String
[]
functionName
){
this
.
functionName
=
functionName
;
}
/** is_function
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isFunction
;
public
java
.
lang
.
String
getIsFunction
(){
return
this
.
isFunction
;
}
public
void
setIsFunction
(
java
.
lang
.
String
isFunction
){
this
.
isFunction
=
isFunction
;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
...
...
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationPublishEntity.java
View file @
fc5cac7c
...
...
@@ -260,32 +260,7 @@ public class BizAgentApplicationPublishEntity {
this
.
isLongMemory
=
isLongMemory
;
}
/** function_name
*方法名
*/
private
java
.
lang
.
String
[]
functionName
;
public
java
.
lang
.
String
[]
getFunctionName
(){
return
this
.
functionName
;
}
public
void
setFunctionName
(
java
.
lang
.
String
[]
functionName
){
this
.
functionName
=
functionName
;
}
/** is_function
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isFunction
;
public
java
.
lang
.
String
getIsFunction
(){
return
this
.
isFunction
;
}
public
void
setIsFunction
(
java
.
lang
.
String
isFunction
){
this
.
isFunction
=
isFunction
;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
...
...
src/main/java/cn/com/poc/agent_application/model/BizAgentApplicationInfoModel.java
View file @
fc5cac7c
...
...
@@ -358,38 +358,6 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"isLongMemory"
);
}
/** function_name
* 方法名
*/
private
java
.
lang
.
String
functionName
;
@Column
(
name
=
"function_name"
,
length
=
2147483647
)
public
java
.
lang
.
String
getFunctionName
(){
return
this
.
functionName
;
}
public
void
setFunctionName
(
java
.
lang
.
String
functionName
){
this
.
functionName
=
functionName
;
super
.
addValidField
(
"functionName"
);
}
/** is_function
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isFunction
;
@Column
(
name
=
"is_function"
,
length
=
1
)
public
java
.
lang
.
String
getIsFunction
(){
return
this
.
isFunction
;
}
public
void
setIsFunction
(
java
.
lang
.
String
isFunction
){
this
.
isFunction
=
isFunction
;
super
.
addValidField
(
"isFunction"
);
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
...
...
src/main/java/cn/com/poc/agent_application/model/BizAgentApplicationPublishModel.java
View file @
fc5cac7c
...
...
@@ -327,40 +327,6 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
super
.
addValidField
(
"isLongMemory"
);
}
/** function_name
* 方法名
*/
private
java
.
lang
.
String
functionName
;
@Column
(
name
=
"function_name"
,
length
=
2147483647
)
public
java
.
lang
.
String
getFunctionName
(){
return
this
.
functionName
;
}
public
void
setFunctionName
(
java
.
lang
.
String
functionName
){
this
.
functionName
=
functionName
;
super
.
addValidField
(
"functionName"
);
}
/** is_function
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isFunction
;
@Column
(
name
=
"is_function"
,
length
=
1
)
public
java
.
lang
.
String
getIsFunction
(){
return
this
.
isFunction
;
}
public
void
setIsFunction
(
java
.
lang
.
String
isFunction
){
this
.
isFunction
=
isFunction
;
super
.
addValidField
(
"isFunction"
);
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
...
...
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
fc5cac7c
package
cn
.
com
.
poc
.
agent_application
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.dto.*
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
...
...
@@ -15,15 +14,13 @@ import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.ListUtils
;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.knowledge.entity.BizKnowledgeInfoEntity
;
import
cn.com.poc.knowledge.service.BizKnowledgeInfoService
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.hutool.core.collection.ListUtil
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -32,7 +29,6 @@ import org.springframework.util.Assert;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.swing.plaf.ListUI
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
...
...
@@ -146,10 +142,27 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
//获取知识库配置
List
<
Integer
>
kdIds
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
//配置对话function
List
<
Tool
>
tools
=
new
ArrayList
<>();
//开启对话变量
if
(
ArrayUtils
.
isNotEmpty
(
infoEntity
.
getVariableStructure
()))
{
String
functionName
=
"set_value_memory"
;
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getVariableStructureLLMConfig
(
infoEntity
.
getVariableStructure
()).
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//开启长期记忆
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
infoEntity
.
getIsLongMemory
()))
{
String
functionName
=
"set_long_memory"
;
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//调用应用服务
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
kdIds
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
dto
.
getMessages
(),
infoEntity
.
getIsLongMemory
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsFunction
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getFunctionName
(),
null
,
AgentApplicationConstants
.
USE_AGENT_STATUS
.
PREVIEW
,
httpServletResponse
);
agentApplicationInfoService
.
callAgentApplication
(
agentId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
kdIds
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
dto
.
getMessages
(),
tools
,
httpServletResponse
);
}
catch
(
Exception
e
)
{
httpServletResponse
.
setContentType
(
"text/event-stream"
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
fc5cac7c
package
cn
.
com
.
poc
.
expose
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
...
...
@@ -14,16 +13,14 @@ import cn.com.poc.common.constant.CommonConstant;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.dto.AgentApplicationDto
;
import
cn.com.poc.expose.rest.AgentApplicationRest
;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.knowledge.entity.BizKnowledgeInfoEntity
;
import
cn.com.poc.knowledge.service.BizKnowledgeInfoService
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.MultiContent
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
...
@@ -36,7 +33,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -88,10 +84,26 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
List
<
Message
>
messages
=
new
ArrayList
<>();
buildMessages
(
dialogsId
,
agentId
,
userBaseEntity
.
getUserId
(),
messages
,
input
);
//配置对话function
List
<
Tool
>
tools
=
new
ArrayList
<>();
//开启对话变量
if
(
ArrayUtils
.
isNotEmpty
(
infoEntity
.
getVariableStructure
()))
{
String
functionName
=
"set_value_memory"
;
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getVariableStructureLLMConfig
(
infoEntity
.
getVariableStructure
()).
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//开启长期记忆
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
infoEntity
.
getIsLongMemory
()))
{
String
functionName
=
"set_long_memory"
;
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
messages
,
infoEntity
.
getIsLongMemory
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsFunction
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getFunctionName
(),
null
,
AgentApplicationConstants
.
USE_AGENT_STATUS
.
PUBLISH
,
httpServletResponse
);
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
dialogsId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
(),
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
(),
messages
,
tools
,
httpServletResponse
);
//保存对话记录
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/AbstractLargeModelFunction.java
View file @
fc5cac7c
...
...
@@ -3,24 +3,18 @@ package cn.com.poc.thirdparty.resource.demand.ai.function;
import
java.util.List
;
public
class
AbstractLargeModelFunction
{
public
abstract
class
AbstractLargeModelFunction
{
public
String
doFunction
(
String
content
,
String
key
){
return
null
;
}
public
abstract
String
doFunction
(
String
content
,
String
key
);
/**
* 获取配置
*/
public
List
<
String
>
getLLMConfig
(){
return
null
;
}
public
abstract
List
<
String
>
getLLMConfig
();
/**
* 获取有关变量的配置
*/
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
return
null
;
}
public
abstract
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
);
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SearchMemoryContentByNameFunction.java
View file @
fc5cac7c
...
...
@@ -35,6 +35,11 @@ public class SearchMemoryContentByNameFunction extends AbstractLargeModelFunctio
return
result
.
toString
();
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
null
;
}
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SearchMemoryContentFunction.java
View file @
fc5cac7c
...
...
@@ -62,4 +62,9 @@ public class SearchMemoryContentFunction extends AbstractLargeModelFunction {
resultList
.
add
(
jsonString
);
return
resultList
;
}
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
return
null
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SetLongMemoryFunction.java
View file @
fc5cac7c
...
...
@@ -23,25 +23,25 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
@Override
public
String
doFunction
(
String
content
,
String
key
)
{
// todo 执行保存长期记忆的操作
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 content
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contentKey
=
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
contentKey
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
hmget
.
entrySet
())
{
if
(
entry
.
getKey
()
instanceof
String
)
{
// 将 Object 强制转换为 String
String
tempKey
=
(
String
)
entry
.
getKey
();
result
.
put
(
tempKey
,
entry
.
getValue
());
}
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 content
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contentKey
=
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
key
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
hmget
.
entrySet
())
{
if
(
entry
.
getKey
()
instanceof
String
)
{
// 将 Object 强制转换为 String
String
tempKey
=
(
String
)
entry
.
getKey
();
result
.
put
(
tempKey
,
entry
.
getValue
());
}
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"timestamp:"
+
DateUtils
.
getCurrTime
());
list
.
add
(
"content:"
+
contents
);
result
.
put
(
Integer
.
toString
(
hmget
.
size
()),
list
);
redisService
.
hmset
(
contentKey
,
result
);
}
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"timestamp:"
+
DateUtils
.
getCurrTime
());
list
.
add
(
"content:"
+
contents
);
result
.
put
(
Integer
.
toString
(
hmget
.
size
()),
list
);
redisService
.
hmset
(
contentKey
,
result
);
return
"SUCCESS"
;
}
...
...
@@ -52,14 +52,14 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
"string"
);
content
.
put
(
"description"
,
"内容的详细说明"
);
content
.
put
(
"description"
,
"内容的详细说明"
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"content"
,
content
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"properties"
,
properties
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
...
...
@@ -79,6 +79,11 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
List
<
String
>
resultList
=
new
ArrayList
<>();
resultList
.
add
(
jsonString
);
return
resultList
;
return
resultList
;
}
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
return
null
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SetValueMemoryFunction.java
View file @
fc5cac7c
...
...
@@ -18,6 +18,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
private
RedisService
redisService
;
@Override
//todo 保存【变量】方法重构
public
String
doFunction
(
String
content
,
String
key
)
{
// todo 执行保存变量的操作
// 创建 JSONObject 对象
...
...
@@ -30,6 +31,11 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
return
"SUCCESS"
;
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
null
;
}
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
...
...
@@ -53,7 +59,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
properties
.
put
(
"contentName"
,
contentName
);
properties
.
put
(
"contentValue"
,
contentValue
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"type"
,
"object"
);
function
.
put
(
"name"
,
"set_value_memory"
);
function
.
put
(
"description"
,
"用enum给定的内容名来保存用户想记录的内容值"
);
...
...
@@ -68,6 +74,6 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
List
<
String
>
resultList
=
new
ArrayList
<>();
resultList
.
add
(
jsonString
);
return
resultList
;
return
resultList
;
}
}
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