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
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;
...
@@ -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.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity
;
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.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.Tool
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.List
;
...
@@ -17,9 +18,9 @@ public interface AgentApplicationInfoService {
...
@@ -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
,
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
...
@@ -40,10 +40,8 @@ import java.io.BufferedReader;
...
@@ -40,10 +40,8 @@ import java.io.BufferedReader;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Component
@Component
public
class
AgentApplicationInfoServiceImpl
implements
AgentApplicationInfoService
{
public
class
AgentApplicationInfoServiceImpl
implements
AgentApplicationInfoService
{
...
@@ -99,65 +97,22 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -99,65 +97,22 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
@Override
@Override
public
String
callAgentApplication
(
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
Integer
[]
kdIds
,
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
{
public
String
callAgentApplication
(
String
identifier
,
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
Integer
[]
kdIds
,
Integer
communicationTurn
,
Float
topP
,
List
<
Message
>
messages
,
List
<
Tool
>
tool
s
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
logger
.
info
(
"--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}"
+
" communicationTurn:{},topP:{},messages:{}--------------"
,
largeModel
,
unitIds
,
agentSystem
,
kdIds
,
communicationTurn
,
topP
,
messages
);
logger
.
info
(
"--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}"
+
" communicationTurn:{},topP:{},messages:{}--------------"
,
largeModel
,
unitIds
,
agentSystem
,
kdIds
,
communicationTurn
,
topP
,
messages
);
String
model
=
modelConvert
(
largeModel
);
String
model
=
modelConvert
(
largeModel
);
String
promptTemplate
=
buildDialogsPrompt
(
messages
,
agentSystem
,
kdIds
);
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
String
promptTemplate
=
buildDialogsPrompt
(
messages
,
agentSystem
,
kdIds
,
toolArray
,
identifier
);
BufferedReader
bufferedReader
;
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
List
<
String
>
toolsConfig
=
null
;
BufferedReader
bufferedReader
=
invokeLLM
(
model
,
messageArray
,
topP
,
toolArray
,
identifier
);
// 判断是否开启了function开关
if
(
isFunction
){
// 判断传的是不是完整配置
if
(
functionConfig
!=
null
&&
!
functionConfig
.
isEmpty
()){
toolsConfig
=
functionConfig
;
}
else
{
//使用变量名的方法
toolsConfig
=
toolsConfig
(
functionName
,
variableStructure
,
isLongMemory
);
}
}
// 解析toolConfig,转变成tools
if
(
toolsConfig
!=
null
&&
!
toolsConfig
.
isEmpty
()){
Tool
[]
tools
=
new
Tool
[
toolsConfig
.
size
()];
int
i
=
0
;
for
(;
i
<
toolsConfig
.
size
();
i
++)
{
Gson
gson
=
new
Gson
();
Tool
toolConfig
=
gson
.
fromJson
(
toolsConfig
.
get
(
i
),
Tool
.
class
);
tools
[
i
]
=
new
Tool
();
tools
[
i
]
=
toolConfig
;
}
bufferedReader
=
invokeLLM
(
model
,
messageArray
,
topP
,
tools
,
useStatus
);
}
else
{
bufferedReader
=
invokeLLM
(
model
,
messageArray
,
topP
,
null
,
useStatus
);
}
return
textOutput
(
httpServletResponse
,
bufferedReader
);
return
textOutput
(
httpServletResponse
,
bufferedReader
);
}
}
private
List
<
String
>
toolsConfig
(
String
[]
functionName
,
String
[]
variableStructure
,
boolean
isLongMemory
){
List
<
String
>
resultConfig
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
functionName
.
length
;
i
++)
{
LargeModelFunctionEnum
function
=
LargeModelFunctionEnum
.
valueOf
(
functionName
[
i
]);
List
<
String
>
llmConfig
=
function
.
getFunction
().
getLLMConfig
();
if
(
llmConfig
!=
null
&&
!
llmConfig
.
isEmpty
()){
resultConfig
.
add
(
llmConfig
.
get
(
0
));
}
}
if
(
isLongMemory
){
resultConfig
.
add
(
LargeModelFunctionEnum
.
valueOf
(
"set_long_memory"
).
getFunction
().
getLLMConfig
().
get
(
0
));
resultConfig
.
add
(
LargeModelFunctionEnum
.
valueOf
(
"search_memory_content"
).
getFunction
().
getLLMConfig
().
get
(
0
));
}
if
(
ArrayUtils
.
isNotEmpty
(
variableStructure
)){
resultConfig
.
add
(
LargeModelFunctionEnum
.
valueOf
(
"set_value_memory"
).
getFunction
().
getVariableStructureLLMConfig
(
variableStructure
).
get
(
0
));
resultConfig
.
add
(
LargeModelFunctionEnum
.
valueOf
(
"search_memory_content_by_enum"
).
getFunction
().
getVariableStructureLLMConfig
(
variableStructure
).
get
(
0
));
}
return
resultConfig
;
}
@Override
@Override
public
void
createAgentSystem
(
String
input
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
public
void
createAgentSystem
(
String
input
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
...
@@ -227,24 +182,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -227,24 +182,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
largeModelDemandResult
.
getMessage
();
return
largeModelDemandResult
.
getMessage
();
}
}
private
static
String
buildPreambleConfigSystem
(
String
configSystem
,
String
agentTitle
,
String
agentDesc
,
String
agentSystem
)
{
//若 name desc prompt 都为空,传入默认参数 name 入参 智能问答机器人 desc 随时为你解答问题
if
(
StringUtils
.
isBlank
(
agentSystem
)
&&
StringUtils
.
isBlank
(
agentTitle
)
&&
StringUtils
.
isBlank
(
agentDesc
))
{
return
configSystem
.
replace
(
"${agent_title}"
,
"智能问答机器人"
).
replace
(
"${agent_desc}"
,
" 随时为你解答问题"
);
}
//若 name desc 其中一项不为空则入参 不传入prompt
if
(
StringUtils
.
isNotBlank
(
agentTitle
)
||
(
StringUtils
.
isNotBlank
(
agentDesc
)))
{
return
configSystem
.
replace
(
"${agent_title}"
,
StringUtils
.
isNotBlank
(
agentTitle
)
?
agentTitle
:
StringUtils
.
EMPTY
)
.
replace
(
"${agent_desc}"
,
StringUtils
.
isNotBlank
(
agentDesc
)
?
agentDesc
:
StringUtils
.
EMPTY
);
}
// 若 name desc 都空 prompt 有内容,则把prompt 传入desc
if
(
StringUtils
.
isNotBlank
(
agentSystem
))
{
return
configSystem
.
replace
(
"${agent_desc}"
,
agentSystem
).
replace
(
"${agent_title}"
,
"智能问答机器人"
);
}
return
configSystem
;
}
@Override
@Override
public
List
<
String
>
createFeaturedQuestions
(
String
agentTitle
,
String
agentDesc
)
{
public
List
<
String
>
createFeaturedQuestions
(
String
agentTitle
,
String
agentDesc
)
{
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_FEATURED_QUESTIONS
);
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_FEATURED_QUESTIONS
);
...
@@ -381,7 +318,44 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -381,7 +318,44 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
JsonUtils
.
deSerialize
(
res
.
substring
(
start
,
end
+
1
),
CreateAgentTitleAndDescEntity
.
class
);
return
JsonUtils
.
deSerialize
(
res
.
substring
(
start
,
end
+
1
),
CreateAgentTitleAndDescEntity
.
class
);
}
}
private
String
buildDialogsPrompt
(
List
<
Message
>
messages
,
String
agentSystem
,
Integer
[]
kdIds
)
{
/**
* 构建应用信息提示词
*
* @param configSystem
* @param agentTitle
* @param agentDesc
* @param agentSystem
* @return
*/
private
String
buildPreambleConfigSystem
(
String
configSystem
,
String
agentTitle
,
String
agentDesc
,
String
agentSystem
)
{
//若 name desc prompt 都为空,传入默认参数 name 入参 智能问答机器人 desc 随时为你解答问题
if
(
StringUtils
.
isBlank
(
agentSystem
)
&&
StringUtils
.
isBlank
(
agentTitle
)
&&
StringUtils
.
isBlank
(
agentDesc
))
{
return
configSystem
.
replace
(
"${agent_title}"
,
"智能问答机器人"
).
replace
(
"${agent_desc}"
,
" 随时为你解答问题"
);
}
//若 name desc 其中一项不为空则入参 不传入prompt
if
(
StringUtils
.
isNotBlank
(
agentTitle
)
||
(
StringUtils
.
isNotBlank
(
agentDesc
)))
{
return
configSystem
.
replace
(
"${agent_title}"
,
StringUtils
.
isNotBlank
(
agentTitle
)
?
agentTitle
:
StringUtils
.
EMPTY
)
.
replace
(
"${agent_desc}"
,
StringUtils
.
isNotBlank
(
agentDesc
)
?
agentDesc
:
StringUtils
.
EMPTY
);
}
// 若 name desc 都空 prompt 有内容,则把prompt 传入desc
if
(
StringUtils
.
isNotBlank
(
agentSystem
))
{
return
configSystem
.
replace
(
"${agent_desc}"
,
agentSystem
).
replace
(
"${agent_title}"
,
"智能问答机器人"
);
}
return
configSystem
;
}
/**
* 构建对话提示词
*
* @param messages
* @param agentSystem
* @param kdIds
* @return
*/
private
String
buildDialogsPrompt
(
List
<
Message
>
messages
,
String
agentSystem
,
Integer
[]
kdIds
,
Tool
[]
tools
,
String
identifier
)
{
String
promptTemplate
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_BASE_SYSTEM
).
getConfigSystem
();
String
promptTemplate
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_BASE_SYSTEM
).
getConfigSystem
();
promptTemplate
=
promptTemplate
.
replace
(
"${agentSystem}"
,
StringUtils
.
isNotBlank
(
agentSystem
)
?
agentSystem
:
StringUtils
.
EMPTY
);
promptTemplate
=
promptTemplate
.
replace
(
"${agentSystem}"
,
StringUtils
.
isNotBlank
(
agentSystem
)
?
agentSystem
:
StringUtils
.
EMPTY
);
// 调用知识库
// 调用知识库
...
@@ -397,6 +371,21 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -397,6 +371,21 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
List
<
String
>
knowledgeResults
=
demandKnowledgeService
.
searchKnowledge
(
messages
.
get
(
messages
.
size
()
-
1
).
getContent
().
get
(
0
).
getText
(),
knowledgeIds
,
3
);
List
<
String
>
knowledgeResults
=
demandKnowledgeService
.
searchKnowledge
(
messages
.
get
(
messages
.
size
()
-
1
).
getContent
().
get
(
0
).
getText
(),
knowledgeIds
,
3
);
promptTemplate
=
promptTemplate
.
replace
(
"${knowledgeResults}"
,
knowledgeResults
.
toString
());
promptTemplate
=
promptTemplate
.
replace
(
"${knowledgeResults}"
,
knowledgeResults
.
toString
());
}
}
// todo 获取记忆
if
(
ArrayUtils
.
isNotEmpty
(
tools
))
{
for
(
Tool
tool
:
tools
)
{
String
name
=
tool
.
getFunction
().
getName
();
if
(
"set_long_memory"
.
equals
(
name
))
{
String
searchMemoryContent
=
LargeModelFunctionEnum
.
valueOf
(
"search_memory_content"
).
getFunction
().
doFunction
(
null
,
identifier
);
promptTemplate
=
promptTemplate
.
replace
(
"${longMemory}"
,
searchMemoryContent
);
}
if
(
"set_value_memory"
.
equals
(
name
))
{
// String searchMemoryContent = LargeModelFunctionEnum.valueOf("search_memory_content").getFunction().doFunction(null, identifier);
}
}
}
return
promptTemplate
;
return
promptTemplate
;
}
}
...
@@ -409,26 +398,30 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -409,26 +398,30 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
private
BufferedReader
invokeLLM
(
String
largeModel
,
Message
[]
messageArray
,
Float
topP
,
Tool
[]
tools
,
String
useStatus
)
throws
Exception
{
private
BufferedReader
invokeLLM
(
String
largeModel
,
Message
[]
messageArray
,
Float
topP
,
Tool
[]
tools
,
String
identifier
)
throws
Exception
{
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
largeModel
);
largeModelResponse
.
setModel
(
largeModel
);
largeModelResponse
.
setMessages
(
messageArray
);
largeModelResponse
.
setMessages
(
messageArray
);
largeModelResponse
.
setTopP
(
topP
);
largeModelResponse
.
setTopP
(
topP
);
largeModelResponse
.
setStream
(
true
);
largeModelResponse
.
setStream
(
true
);
largeModelResponse
.
setUser
(
"POE"
);
largeModelResponse
.
setUser
(
"POE"
);
largeModelResponse
.
setTools
(
tools
);
largeModelResponse
.
setTool_choice
(
"auto"
);
if
(
ArrayUtils
.
isNotEmpty
(
tools
))
{
largeModelResponse
.
setTools
(
tools
);
largeModelResponse
.
setTool_choice
(
"auto"
);
}
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
String
res
=
""
;
bufferedReader
.
mark
(
200
);
bufferedReader
.
mark
(
200
);
String
res
=
""
;
boolean
isFunctionCall
=
false
;
String
functionResult
=
null
;
String
functionResult
=
null
;
StringBuffer
finishReason
=
new
StringBuffer
();
StringBuffer
finishReason
=
new
StringBuffer
();
StringBuffer
functionName
=
new
StringBuffer
();
StringBuffer
functionName
=
new
StringBuffer
();
StringBuffer
functionArguments
=
new
StringBuffer
();
StringBuffer
functionArguments
=
new
StringBuffer
();
boolean
isFunctionCall
=
false
;
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
if
(
StringUtils
.
isBlank
(
res
))
{
if
(
StringUtils
.
isBlank
(
res
))
{
continue
;
continue
;
...
@@ -464,7 +457,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -464,7 +457,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
if
(!
functionName
.
toString
().
isEmpty
()
&&
!
functionArguments
.
toString
().
isEmpty
())
{
if
(!
functionName
.
toString
().
isEmpty
()
&&
!
functionArguments
.
toString
().
isEmpty
())
{
// 执行函数返回结果
// 执行函数返回结果
LargeModelFunctionEnum
functionEnum
=
LargeModelFunctionEnum
.
valueOf
(
functionName
.
toString
());
LargeModelFunctionEnum
functionEnum
=
LargeModelFunctionEnum
.
valueOf
(
functionName
.
toString
());
functionResult
=
functionEnum
.
getFunction
().
doFunction
(
functionArguments
.
toString
(),
useStatus
);
functionResult
=
functionEnum
.
getFunction
().
doFunction
(
functionArguments
.
toString
(),
identifier
);
}
}
if
(
functionResult
!=
null
)
{
if
(
functionResult
!=
null
)
{
...
@@ -480,7 +473,16 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -480,7 +473,16 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
private
Message
[]
buildFunctionMessage
(
Message
[]
messageArray
,
String
functionName
,
String
functionArguments
,
String
functionResult
){
/**
* 构建function_call消息体
*
* @param messageArray
* @param functionName
* @param functionArguments
* @param functionResult
* @return
*/
private
Message
[]
buildFunctionMessage
(
Message
[]
messageArray
,
String
functionName
,
String
functionArguments
,
String
functionResult
)
{
Message
assistantMessage
=
new
Message
();
Message
assistantMessage
=
new
Message
();
assistantMessage
.
setRole
(
"assistant"
);
assistantMessage
.
setRole
(
"assistant"
);
assistantMessage
.
setContent
(
null
);
assistantMessage
.
setContent
(
null
);
...
@@ -508,7 +510,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -508,7 +510,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
functionMessage
.
setContent
(
content
);
functionMessage
.
setContent
(
content
);
sendMessage
[
messageArray
.
length
+
1
]
=
functionMessage
;
sendMessage
[
messageArray
.
length
+
1
]
=
functionMessage
;
return
sendMessage
;
return
sendMessage
;
}
}
...
@@ -556,8 +558,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -556,8 +558,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param promptTemplate
* @param promptTemplate
* @return
* @return
*/
*/
private
static
Message
[]
buildMessages
(
List
<
Message
>
messages
,
Integer
communicationTurn
,
String
private
static
Message
[]
buildMessages
(
List
<
Message
>
messages
,
Integer
communicationTurn
,
String
promptTemplate
)
{
promptTemplate
)
{
int
messLength
=
messages
.
size
()
-
1
;
int
messLength
=
messages
.
size
()
-
1
;
int
skip
=
communicationTurn
*
2
;
int
skip
=
communicationTurn
*
2
;
if
(
skip
<
messLength
)
{
if
(
skip
<
messLength
)
{
...
@@ -592,4 +593,5 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -592,4 +593,5 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
return
largeModelEntity
.
getModelName
();
return
largeModelEntity
.
getModelName
();
}
}
}
}
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;
...
@@ -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.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
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.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.AgentApplicationInfoQueryItem
;
import
cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem
;
import
cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
...
@@ -43,11 +43,7 @@ public class AgentApplicationInfoConvert {
...
@@ -43,11 +43,7 @@ public class AgentApplicationInfoConvert {
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPublishTime
(
model
.
getPublishTime
());
entity
.
setPublishTime
(
model
.
getPublishTime
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setIsFunction
(
model
.
getIsFunction
());
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getFunctionName
()))
{
entity
.
setFunctionName
(
JsonUtils
.
deSerialize
(
model
.
getFunctionName
(),
String
[].
class
));
}
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
}
}
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
...
@@ -87,10 +83,6 @@ public class AgentApplicationInfoConvert {
...
@@ -87,10 +83,6 @@ public class AgentApplicationInfoConvert {
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsFunction
(
entity
.
getIsFunction
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getFunctionName
()))
{
model
.
setFunctionName
(
JsonUtils
.
serialize
(
entity
.
getFunctionName
()));
}
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -137,8 +129,7 @@ public class AgentApplicationInfoConvert {
...
@@ -137,8 +129,7 @@ public class AgentApplicationInfoConvert {
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setFunctionName
(
entity
.
getFunctionName
());
commConfig
.
setIsFunction
(
entity
.
getIsFunction
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
@@ -184,10 +175,6 @@ public class AgentApplicationInfoConvert {
...
@@ -184,10 +175,6 @@ public class AgentApplicationInfoConvert {
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
}
}
entity
.
setIsLongMemory
(
dto
.
getCommConfig
().
getIsLongMemory
());
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
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
...
@@ -221,12 +208,8 @@ public class AgentApplicationInfoConvert {
...
@@ -221,12 +208,8 @@ public class AgentApplicationInfoConvert {
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setIsLongMemory
(
infoQueryItem
.
getIsLongMemory
());
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
));
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.AgentApplicationBaseInfo
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
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.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.com.poc.common.utils.JsonUtils
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.tencent.core.utils.JsonUtil
;
import
com.tencent.core.utils.JsonUtil
;
...
@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
public
class
BizAgentApplicationPublishConvert
{
public
class
BizAgentApplicationPublishConvert
{
public
static
BizAgentApplicationPublishEntity
modelToEntity
(
BizAgentApplicationPublishModel
model
){
public
static
BizAgentApplicationPublishEntity
modelToEntity
(
BizAgentApplicationPublishModel
model
)
{
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setId
(
model
.
getId
());
entity
.
setMemberId
(
model
.
getMemberId
());
entity
.
setMemberId
(
model
.
getMemberId
());
...
@@ -27,12 +27,11 @@ public class BizAgentApplicationPublishConvert {
...
@@ -27,12 +27,11 @@ public class BizAgentApplicationPublishConvert {
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
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
));
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
));
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
String
[].
class
));
}
}
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getFeaturedQuestions
()))
{
...
@@ -59,7 +58,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -59,7 +58,7 @@ public class BizAgentApplicationPublishConvert {
return
entity
;
return
entity
;
}
}
public
static
BizAgentApplicationPublishModel
entityToModel
(
BizAgentApplicationPublishEntity
entity
){
public
static
BizAgentApplicationPublishModel
entityToModel
(
BizAgentApplicationPublishEntity
entity
)
{
BizAgentApplicationPublishModel
model
=
new
BizAgentApplicationPublishModel
();
BizAgentApplicationPublishModel
model
=
new
BizAgentApplicationPublishModel
();
model
.
setId
(
entity
.
getId
());
model
.
setId
(
entity
.
getId
());
model
.
setMemberId
(
entity
.
getMemberId
());
model
.
setMemberId
(
entity
.
getMemberId
());
...
@@ -70,10 +69,6 @@ public class BizAgentApplicationPublishConvert {
...
@@ -70,10 +69,6 @@ public class BizAgentApplicationPublishConvert {
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsFunction
(
entity
.
getIsFunction
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getFunctionName
()))
{
model
.
setFunctionName
(
JsonUtils
.
serialize
(
entity
.
getFunctionName
()));
}
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -100,8 +95,8 @@ public class BizAgentApplicationPublishConvert {
...
@@ -100,8 +95,8 @@ public class BizAgentApplicationPublishConvert {
model
.
setSysVersion
(
entity
.
getSysVersion
());
model
.
setSysVersion
(
entity
.
getSysVersion
());
return
model
;
return
model
;
}
}
public
static
BizAgentApplicationPublishDto
entityToDto
(
BizAgentApplicationPublishEntity
entity
){
public
static
BizAgentApplicationPublishDto
entityToDto
(
BizAgentApplicationPublishEntity
entity
)
{
BizAgentApplicationPublishDto
dto
=
new
BizAgentApplicationPublishDto
();
BizAgentApplicationPublishDto
dto
=
new
BizAgentApplicationPublishDto
();
AgentApplicationBaseInfo
baseInfo
=
new
AgentApplicationBaseInfo
();
AgentApplicationBaseInfo
baseInfo
=
new
AgentApplicationBaseInfo
();
baseInfo
.
setMemberId
(
entity
.
getMemberId
());
baseInfo
.
setMemberId
(
entity
.
getMemberId
());
...
@@ -121,8 +116,6 @@ public class BizAgentApplicationPublishConvert {
...
@@ -121,8 +116,6 @@ public class BizAgentApplicationPublishConvert {
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
commConfig
.
setIsFunction
(
entity
.
getIsFunction
());
commConfig
.
setFunctionName
(
entity
.
getFunctionName
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
@@ -143,7 +136,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -143,7 +136,7 @@ public class BizAgentApplicationPublishConvert {
return
dto
;
return
dto
;
}
}
public
static
BizAgentApplicationPublishEntity
dtoToEntity
(
BizAgentApplicationPublishDto
dto
){
public
static
BizAgentApplicationPublishEntity
dtoToEntity
(
BizAgentApplicationPublishDto
dto
)
{
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
BizAgentApplicationPublishEntity
entity
=
new
BizAgentApplicationPublishEntity
();
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getBaseInfo
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getBaseInfo
()))
{
entity
.
setAgentId
(
dto
.
getBaseInfo
().
getAgentId
());
entity
.
setAgentId
(
dto
.
getBaseInfo
().
getAgentId
());
...
@@ -165,10 +158,6 @@ public class BizAgentApplicationPublishConvert {
...
@@ -165,10 +158,6 @@ public class BizAgentApplicationPublishConvert {
entity
.
setContinuousQuestionSystem
(
dto
.
getCommConfig
().
getContinuousQuestionSystem
());
entity
.
setContinuousQuestionSystem
(
dto
.
getCommConfig
().
getContinuousQuestionSystem
());
entity
.
setContinuousQuestionTurn
(
dto
.
getCommConfig
().
getContinuousQuestionTurn
());
entity
.
setContinuousQuestionTurn
(
dto
.
getCommConfig
().
getContinuousQuestionTurn
());
entity
.
setIsLongMemory
(
dto
.
getCommConfig
().
getIsLongMemory
());
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
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getVariableStructure
()))
{
entity
.
setVariableStructure
(
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 {
...
@@ -75,57 +75,32 @@ public class AgentApplicationCommConfig {
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
}
}
/** variable_structure
/**
*变量结构
* variable_structure
* 变量结构
*/
*/
private
java
.
lang
.
String
[]
variableStructure
;
private
java
.
lang
.
String
[]
variableStructure
;
public
java
.
lang
.
String
[]
getVariableStructure
(){
public
java
.
lang
.
String
[]
getVariableStructure
()
{
return
this
.
variableStructure
;
return
this
.
variableStructure
;
}
}
public
void
setVariableStructure
(
java
.
lang
.
String
[]
variableStructure
){
public
void
setVariableStructure
(
java
.
lang
.
String
[]
variableStructure
)
{
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
}
}
/** is_long_memory
/**
*是否开启长期记忆 1、Y 是 2、N 否
* is_long_memory
* 是否开启长期记忆 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isLongMemory
;
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
public
java
.
lang
.
String
getIsLongMemory
()
{
return
this
.
isLongMemory
;
return
this
.
isLongMemory
;
}
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
)
{
this
.
isLongMemory
=
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 {
...
@@ -261,32 +261,6 @@ public class BizAgentApplicationInfoEntity {
this
.
isLongMemory
=
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
;
}
/** is_deleted
/** is_deleted
*是否删除 1、Y 是 2、N 否
*是否删除 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 {
...
@@ -260,32 +260,7 @@ public class BizAgentApplicationPublishEntity {
this
.
isLongMemory
=
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
;
}
/** is_deleted
/** is_deleted
*是否删除 1、Y 是 2、N 否
*是否删除 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
...
@@ -358,38 +358,6 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"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
/** is_deleted
*是否删除 1、Y 是 2、N 否
*是否删除 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
...
@@ -327,40 +327,6 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
super
.
addValidField
(
"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
/** is_deleted
*是否删除 1、Y 是 2、N 否
*是否删除 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
;
package
cn
.
com
.
poc
.
agent_application
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
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.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.dto.*
;
import
cn.com.poc.agent_application.dto.*
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
...
@@ -15,15 +14,13 @@ import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
...
@@ -15,15 +14,13 @@ import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
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.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.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.core.exception.BusinessException
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -32,7 +29,6 @@ import org.springframework.util.Assert;
...
@@ -32,7 +29,6 @@ import org.springframework.util.Assert;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.swing.plaf.ListUI
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -146,10 +142,27 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -146,10 +142,27 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
//获取知识库配置
//获取知识库配置
List
<
Integer
>
kdIds
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
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
()
agentApplicationInfoService
.
callAgentApplication
(
agentId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
kdIds
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
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
);
,
dto
.
getMessages
(),
tools
,
httpServletResponse
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
httpServletResponse
.
setContentType
(
"text/event-stream"
);
httpServletResponse
.
setContentType
(
"text/event-stream"
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
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
;
package
cn
.
com
.
poc
.
expose
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
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.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
...
@@ -14,16 +13,14 @@ import cn.com.poc.common.constant.CommonConstant;
...
@@ -14,16 +13,14 @@ import cn.com.poc.common.constant.CommonConstant;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
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.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.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.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.MultiContent
;
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.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
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.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
@@ -36,7 +33,6 @@ import org.springframework.stereotype.Service;
...
@@ -36,7 +33,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -88,10 +84,26 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -88,10 +84,26 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
List
<
Message
>
messages
=
new
ArrayList
<>();
List
<
Message
>
messages
=
new
ArrayList
<>();
buildMessages
(
dialogsId
,
agentId
,
userBaseEntity
.
getUserId
(),
messages
,
input
);
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
()
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
dialogsId
,
infoEntity
.
getLargeModel
(),
,
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
infoEntity
.
getUnitIds
(),
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
,
messages
,
infoEntity
.
getIsLongMemory
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsFunction
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getFunctionName
(),
null
,
AgentApplicationConstants
.
USE_AGENT_STATUS
.
PUBLISH
,
httpServletResponse
);
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;
...
@@ -3,24 +3,18 @@ package cn.com.poc.thirdparty.resource.demand.ai.function;
import
java.util.List
;
import
java.util.List
;
public
class
AbstractLargeModelFunction
{
public
abstract
class
AbstractLargeModelFunction
{
public
String
doFunction
(
String
content
,
String
key
){
public
abstract
String
doFunction
(
String
content
,
String
key
);
return
null
;
}
/**
/**
* 获取配置
* 获取配置
*/
*/
public
List
<
String
>
getLLMConfig
(){
public
abstract
List
<
String
>
getLLMConfig
();
return
null
;
}
/**
/**
* 获取有关变量的配置
* 获取有关变量的配置
*/
*/
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
public
abstract
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
);
return
null
;
}
}
}
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
...
@@ -35,6 +35,11 @@ public class SearchMemoryContentByNameFunction extends AbstractLargeModelFunctio
return
result
.
toString
();
return
result
.
toString
();
}
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
null
;
}
@Override
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
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 {
...
@@ -62,4 +62,9 @@ public class SearchMemoryContentFunction extends AbstractLargeModelFunction {
resultList
.
add
(
jsonString
);
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/SetLongMemoryFunction.java
View file @
fc5cac7c
...
@@ -23,25 +23,25 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
...
@@ -23,25 +23,25 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
@Override
@Override
public
String
doFunction
(
String
content
,
String
key
)
{
public
String
doFunction
(
String
content
,
String
key
)
{
// todo 执行保存长期记忆的操作
// todo 执行保存长期记忆的操作
// 创建 JSONObject 对象
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 content
// 提取 content
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contentKey
=
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
String
contentKey
=
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
contentKey
);
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
key
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
hmget
.
entrySet
())
{
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
hmget
.
entrySet
())
{
if
(
entry
.
getKey
()
instanceof
String
)
{
if
(
entry
.
getKey
()
instanceof
String
)
{
// 将 Object 强制转换为 String
// 将 Object 强制转换为 String
String
tempKey
=
(
String
)
entry
.
getKey
();
String
tempKey
=
(
String
)
entry
.
getKey
();
result
.
put
(
tempKey
,
entry
.
getValue
());
result
.
put
(
tempKey
,
entry
.
getValue
());
}
}
}
List
<
String
>
list
=
new
ArrayList
<>();
}
list
.
add
(
"timestamp:"
+
DateUtils
.
getCurrTime
());
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"content:"
+
contents
);
list
.
add
(
"timestamp:"
+
DateUtils
.
getCurrTime
());
result
.
put
(
Integer
.
toString
(
hmget
.
size
()),
list
);
list
.
add
(
"content:"
+
contents
);
redisService
.
hmset
(
contentKey
,
result
);
result
.
put
(
Integer
.
toString
(
hmget
.
size
()),
list
);
redisService
.
hmset
(
contentKey
,
result
);
return
"SUCCESS"
;
return
"SUCCESS"
;
}
}
...
@@ -52,14 +52,14 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
...
@@ -52,14 +52,14 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
"string"
);
content
.
put
(
"type"
,
"string"
);
content
.
put
(
"description"
,
"内容的详细说明"
);
content
.
put
(
"description"
,
"内容的详细说明"
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"content"
,
content
);
properties
.
put
(
"content"
,
content
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"properties"
,
properties
);
List
<
String
>
required
=
new
ArrayList
<>();
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
required
.
add
(
"content"
);
...
@@ -79,6 +79,11 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
...
@@ -79,6 +79,11 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
List
<
String
>
resultList
=
new
ArrayList
<>();
List
<
String
>
resultList
=
new
ArrayList
<>();
resultList
.
add
(
jsonString
);
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 {
...
@@ -18,6 +18,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
private
RedisService
redisService
;
private
RedisService
redisService
;
@Override
@Override
//todo 保存【变量】方法重构
public
String
doFunction
(
String
content
,
String
key
)
{
public
String
doFunction
(
String
content
,
String
key
)
{
// todo 执行保存变量的操作
// todo 执行保存变量的操作
// 创建 JSONObject 对象
// 创建 JSONObject 对象
...
@@ -30,6 +31,11 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
...
@@ -30,6 +31,11 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
return
"SUCCESS"
;
return
"SUCCESS"
;
}
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
null
;
}
@Override
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
public
List
<
String
>
getVariableStructureLLMConfig
(
String
[]
variableStructure
)
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
...
@@ -53,7 +59,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
...
@@ -53,7 +59,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
properties
.
put
(
"contentName"
,
contentName
);
properties
.
put
(
"contentName"
,
contentName
);
properties
.
put
(
"contentValue"
,
contentValue
);
properties
.
put
(
"contentValue"
,
contentValue
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"type"
,
"object"
);
function
.
put
(
"name"
,
"set_value_memory"
);
function
.
put
(
"name"
,
"set_value_memory"
);
function
.
put
(
"description"
,
"用enum给定的内容名来保存用户想记录的内容值"
);
function
.
put
(
"description"
,
"用enum给定的内容名来保存用户想记录的内容值"
);
...
@@ -68,6 +74,6 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
...
@@ -68,6 +74,6 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
List
<
String
>
resultList
=
new
ArrayList
<>();
List
<
String
>
resultList
=
new
ArrayList
<>();
resultList
.
add
(
jsonString
);
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