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
5e8e4b56
Commit
5e8e4b56
authored
Oct 16, 2024
by
jennie chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
变量记忆,长期记忆功能
parent
86b395ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
823 additions
and
43 deletions
+823
-43
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+1
-1
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+155
-17
AgentApplicationConstants.java
...agent_application/constant/AgentApplicationConstants.java
+10
-0
AgentApplicationInfoConvert.java
...gent_application/convert/AgentApplicationInfoConvert.java
+5
-0
BizAgentApplicationPublishConvert.java
...pplication/convert/BizAgentApplicationPublishConvert.java
+4
-0
AgentApplicationCommConfig.java
.../agent_application/domain/AgentApplicationCommConfig.java
+13
-0
BizAgentApplicationInfoDto.java
...poc/agent_application/dto/BizAgentApplicationInfoDto.java
+14
-0
BizAgentApplicationInfoEntity.java
...ent_application/entity/BizAgentApplicationInfoEntity.java
+13
-0
BizAgentApplicationPublishEntity.java
..._application/entity/BizAgentApplicationPublishEntity.java
+14
-0
BizAgentApplicationInfoModel.java
...agent_application/model/BizAgentApplicationInfoModel.java
+15
-0
BizAgentApplicationPublishModel.java
...nt_application/model/BizAgentApplicationPublishModel.java
+15
-0
AgentApplicationInfoQuery.sql
...poc/agent_application/query/AgentApplicationInfoQuery.sql
+1
-0
AgentApplicationInfoQueryItem.java
...gent_application/query/AgentApplicationInfoQueryItem.java
+15
-0
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+3
-3
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+2
-5
Function.java
...thirdparty/resource/demand/ai/common/domain/Function.java
+42
-0
FunctionCall.java
...dparty/resource/demand/ai/common/domain/FunctionCall.java
+23
-0
Message.java
.../thirdparty/resource/demand/ai/common/domain/Message.java
+22
-0
Tool.java
...poc/thirdparty/resource/demand/ai/common/domain/Tool.java
+36
-0
ToolChoice.java
...irdparty/resource/demand/ai/common/domain/ToolChoice.java
+29
-0
ToolFunction.java
...dparty/resource/demand/ai/common/domain/ToolFunction.java
+23
-0
LargeModelDemandResult.java
...e/demand/ai/entity/largemodel/LargeModelDemandResult.java
+23
-0
LargeModelResponse.java
...ource/demand/ai/entity/largemodel/LargeModelResponse.java
+19
-17
AbstractExecuteLargeModelFunction.java
...demand/ai/function/AbstractExecuteLargeModelFunction.java
+6
-0
AbstractLargeModelFunction.java
...source/demand/ai/function/AbstractLargeModelFunction.java
+33
-0
ExecuteLargeModelFunctionEnum.java
...rce/demand/ai/function/ExecuteLargeModelFunctionEnum.java
+24
-0
ExecuteSearchMemoryContentByEnumFunction.java
...ai/function/ExecuteSearchMemoryContentByEnumFunction.java
+38
-0
ExecuteSearchMemoryContentFunction.java
...emand/ai/function/ExecuteSearchMemoryContentFunction.java
+26
-0
ExecuteSetLongMemoryFunction.java
...urce/demand/ai/function/ExecuteSetLongMemoryFunction.java
+48
-0
ExecuteSetValueMemoryFunction.java
...rce/demand/ai/function/ExecuteSetValueMemoryFunction.java
+27
-0
LargeModelFunctionEnum.java
...y/resource/demand/ai/function/LargeModelFunctionEnum.java
+22
-0
SearchMemoryContentByEnumFunction.java
...demand/ai/function/SearchMemoryContentByEnumFunction.java
+21
-0
SearchMemoryContentFunction.java
...ource/demand/ai/function/SearchMemoryContentFunction.java
+29
-0
SetLongMemoryLargeModelFunction.java
...e/demand/ai/function/SetLongMemoryLargeModelFunction.java
+30
-0
SetValueMemoryLargeModelFunction.java
.../demand/ai/function/SetValueMemoryLargeModelFunction.java
+22
-0
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
5e8e4b56
...
@@ -19,7 +19,7 @@ public interface AgentApplicationInfoService {
...
@@ -19,7 +19,7 @@ public interface AgentApplicationInfoService {
*/
*/
String
callAgentApplication
(
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
String
callAgentApplication
(
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
String
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
String
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
List
<
Message
>
messages
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
List
<
Message
>
messages
,
Boolean
isLongMemory
,
String
[]
variableStructure
,
String
useStatus
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
/**
...
...
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
5e8e4b56
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/poc/agent_application/constant/AgentApplicationConstants.java
View file @
5e8e4b56
...
@@ -2,6 +2,16 @@ package cn.com.poc.agent_application.constant;
...
@@ -2,6 +2,16 @@ package cn.com.poc.agent_application.constant;
public
interface
AgentApplicationConstants
{
public
interface
AgentApplicationConstants
{
interface
USE_AGENT_STATUS
{
String
PREVIEW
=
"preview"
;
String
PUBLISH
=
"publish"
;
}
interface
TOOLS
{
int
FUNCTION_NUMBER
=
4
;
}
interface
AGENT_PUBLISH_STATUS
{
interface
AGENT_PUBLISH_STATUS
{
String
DRAFT
=
"draft"
;
// 草稿
String
DRAFT
=
"draft"
;
// 草稿
...
...
src/main/java/cn/com/poc/agent_application/convert/AgentApplicationInfoConvert.java
View file @
5e8e4b56
...
@@ -29,6 +29,7 @@ public class AgentApplicationInfoConvert {
...
@@ -29,6 +29,7 @@ public class AgentApplicationInfoConvert {
entity
.
setAgentPublishStatus
(
model
.
getAgentPublishStatus
());
entity
.
setAgentPublishStatus
(
model
.
getAgentPublishStatus
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPublishTime
(
model
.
getPublishTime
());
entity
.
setPublishTime
(
model
.
getPublishTime
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
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
));
}
}
...
@@ -68,6 +69,7 @@ public class AgentApplicationInfoConvert {
...
@@ -68,6 +69,7 @@ public class AgentApplicationInfoConvert {
model
.
setAgentPublishStatus
(
entity
.
getAgentPublishStatus
());
model
.
setAgentPublishStatus
(
entity
.
getAgentPublishStatus
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -114,6 +116,7 @@ public class AgentApplicationInfoConvert {
...
@@ -114,6 +116,7 @@ public class AgentApplicationInfoConvert {
commConfig
.
setContinuousQuestionSystem
(
entity
.
getContinuousQuestionSystem
());
commConfig
.
setContinuousQuestionSystem
(
entity
.
getContinuousQuestionSystem
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
@@ -158,6 +161,7 @@ public class AgentApplicationInfoConvert {
...
@@ -158,6 +161,7 @@ public class AgentApplicationInfoConvert {
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getVariableStructure
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommConfig
().
getVariableStructure
()))
{
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
entity
.
setVariableStructure
(
dto
.
getCommConfig
().
getVariableStructure
());
}
}
entity
.
setIsLongMemory
(
dto
.
getCommConfig
().
getIsLongMemory
());
}
}
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
...
@@ -190,6 +194,7 @@ public class AgentApplicationInfoConvert {
...
@@ -190,6 +194,7 @@ public class AgentApplicationInfoConvert {
entity
.
setAgentPublishStatus
(
infoQueryItem
.
getAgentPublishStatus
());
entity
.
setAgentPublishStatus
(
infoQueryItem
.
getAgentPublishStatus
());
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setIsLongMemory
(
infoQueryItem
.
getIsLongMemory
());
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 @
5e8e4b56
...
@@ -26,6 +26,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -26,6 +26,7 @@ public class BizAgentApplicationPublishConvert {
entity
.
setAgentDesc
(
model
.
getAgentDesc
());
entity
.
setAgentDesc
(
model
.
getAgentDesc
());
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
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
));
}
}
...
@@ -63,6 +64,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -63,6 +64,7 @@ public class BizAgentApplicationPublishConvert {
model
.
setAgentDesc
(
entity
.
getAgentDesc
());
model
.
setAgentDesc
(
entity
.
getAgentDesc
());
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -109,6 +111,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -109,6 +111,7 @@ public class BizAgentApplicationPublishConvert {
commConfig
.
setContinuousQuestionSystem
(
entity
.
getContinuousQuestionSystem
());
commConfig
.
setContinuousQuestionSystem
(
entity
.
getContinuousQuestionSystem
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setContinuousQuestionTurn
(
entity
.
getContinuousQuestionTurn
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setVariableStructure
(
entity
.
getVariableStructure
());
commConfig
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
...
@@ -150,6 +153,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -150,6 +153,7 @@ public class BizAgentApplicationPublishConvert {
entity
.
setContinuousQuestionStatus
(
dto
.
getCommConfig
().
getContinuousQuestionStatus
());
entity
.
setContinuousQuestionStatus
(
dto
.
getCommConfig
().
getContinuousQuestionStatus
());
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
());
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 @
5e8e4b56
...
@@ -88,4 +88,17 @@ public class AgentApplicationCommConfig {
...
@@ -88,4 +88,17 @@ public class AgentApplicationCommConfig {
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
}
}
}
src/main/java/cn/com/poc/agent_application/dto/BizAgentApplicationInfoDto.java
View file @
5e8e4b56
...
@@ -232,6 +232,20 @@ public class BizAgentApplicationInfoDto {
...
@@ -232,6 +232,20 @@ public class BizAgentApplicationInfoDto {
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
){
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
){
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
}
/** is_deleted
/** is_deleted
*是否删除 1、Y 是 2、N 否
*是否删除 1、Y 是 2、N 否
*/
*/
...
...
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationInfoEntity.java
View file @
5e8e4b56
...
@@ -247,6 +247,19 @@ public class BizAgentApplicationInfoEntity {
...
@@ -247,6 +247,19 @@ public class BizAgentApplicationInfoEntity {
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
}
/** 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 @
5e8e4b56
...
@@ -246,6 +246,20 @@ public class BizAgentApplicationPublishEntity {
...
@@ -246,6 +246,20 @@ public class BizAgentApplicationPublishEntity {
public
void
setUnitIds
(
java
.
lang
.
String
[]
unitIds
){
public
void
setUnitIds
(
java
.
lang
.
String
[]
unitIds
){
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
}
/** 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 @
5e8e4b56
...
@@ -344,6 +344,21 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
...
@@ -344,6 +344,21 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
super
.
addValidField
(
"variableStructure"
);
super
.
addValidField
(
"variableStructure"
);
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"isLongMemory"
);
}
/** 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 @
5e8e4b56
...
@@ -311,6 +311,21 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
...
@@ -311,6 +311,21 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
super
.
addValidField
(
"unitIds"
);
super
.
addValidField
(
"unitIds"
);
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"isLongMemory"
);
}
/** is_deleted
/** is_deleted
...
...
src/main/java/cn/com/poc/agent_application/query/AgentApplicationInfoQuery.sql
View file @
5e8e4b56
...
@@ -19,6 +19,7 @@ select distinct
...
@@ -19,6 +19,7 @@ select distinct
top_p
,
top_p
,
unit_ids
,
unit_ids
,
variable_structure
,
variable_structure
,
is_long_memory
,
is_deleted
,
is_deleted
,
CREATOR
,
CREATOR
,
CREATED_TIME
,
CREATED_TIME
,
...
...
src/main/java/cn/com/poc/agent_application/query/AgentApplicationInfoQueryItem.java
View file @
5e8e4b56
...
@@ -314,6 +314,21 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
...
@@ -314,6 +314,21 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
}
}
/** is_long_memory
*是否开启长期记忆 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isLongMemory
;
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
public
java
.
lang
.
String
getIsLongMemory
(){
return
this
.
isLongMemory
;
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
this
.
isLongMemory
=
isLongMemory
;
}
/**
/**
* is_deleted
* is_deleted
* is_deleted
* is_deleted
...
...
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
5e8e4b56
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.convert.BizAgentApplicationLargeModelListConvert
;
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
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationLargeModelListEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationLargeModelListEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity
;
import
cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryCondition
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryCondition
;
import
cn.com.poc.agent_application.rest.AgentApplicationInfoRest
;
import
cn.com.poc.agent_application.rest.AgentApplicationInfoRest
;
import
cn.com.poc.agent_application.service.BizAgentApplicationInfoService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationInfoService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationLargeModelListService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationLargeModelListService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
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.BlContext
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
...
@@ -133,7 +133,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -133,7 +133,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
}
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
infoEntity
.
getKnowledgeIds
(),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
infoEntity
.
getAgentSystem
(),
infoEntity
.
getKnowledgeIds
(),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
dto
.
getMessages
(),
httpServletResponse
);
,
dto
.
getMessages
(),
infoEntity
.
getIsLongMemory
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getVariableStructure
(),
AgentApplicationConstants
.
USE_AGENT_STATUS
.
PREVIEW
,
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 @
5e8e4b56
...
@@ -6,16 +6,14 @@ import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordCons
...
@@ -6,16 +6,14 @@ import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordCons
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
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
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.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.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
;
...
@@ -77,10 +75,9 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -77,10 +75,9 @@ 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
);
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getUnitIds
()
,
infoEntity
.
getAgentSystem
(),
infoEntity
.
getKnowledgeIds
(),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
infoEntity
.
getAgentSystem
(),
infoEntity
.
getKnowledgeIds
(),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
()
,
messages
,
httpServletResponse
);
,
messages
,
infoEntity
.
getIsLongMemory
().
equals
(
CommonConstant
.
IsDeleted
.
Y
),
infoEntity
.
getVariableStructure
(),
AgentApplicationConstants
.
USE_AGENT_STATUS
.
PUBLISH
,
httpServletResponse
);
//保存对话记录
//保存对话记录
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/Function.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
.
domain
;
import
java.util.Map
;
public
class
Function
{
private
String
name
;
// 函数名
private
String
description
;
// 函数描述
private
Map
<
String
,
Object
>
parameters
;
// 函数请求参数
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Map
<
String
,
Object
>
getParameters
()
{
return
parameters
;
}
public
void
setParameters
(
Map
<
String
,
Object
>
parameters
)
{
this
.
parameters
=
parameters
;
}
@Override
public
String
toString
()
{
return
"Function{"
+
"name='"
+
name
+
'\''
+
", description='"
+
description
+
'\''
+
", parameters="
+
parameters
+
'}'
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/FunctionCall.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
.
domain
;
public
class
FunctionCall
{
private
String
name
;
private
String
arguments
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getArguments
()
{
return
arguments
;
}
public
void
setArguments
(
String
arguments
)
{
this
.
arguments
=
arguments
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/Message.java
View file @
5e8e4b56
...
@@ -16,6 +16,10 @@ public class Message {
...
@@ -16,6 +16,10 @@ public class Message {
private
String
role
;
private
String
role
;
private
List
<
FunctionCall
>
function_call
;
private
String
name
;
public
List
<
MultiContent
>
getContent
()
{
public
List
<
MultiContent
>
getContent
()
{
return
content
;
return
content
;
}
}
...
@@ -32,11 +36,29 @@ public class Message {
...
@@ -32,11 +36,29 @@ public class Message {
this
.
role
=
role
;
this
.
role
=
role
;
}
}
public
List
<
FunctionCall
>
getFunction_call
()
{
return
function_call
;
}
public
void
setFunction_call
(
List
<
FunctionCall
>
function_call
)
{
this
.
function_call
=
function_call
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Message{"
+
return
"Message{"
+
"content="
+
content
+
"content="
+
content
+
", role='"
+
role
+
'\''
+
", role='"
+
role
+
'\''
+
", function_call="
+
function_call
+
", name='"
+
name
+
'\''
+
'}'
;
'}'
;
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/Tool.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
.
domain
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
Tool
{
private
String
type
;
private
AbstractLargeModelFunction
function
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
AbstractLargeModelFunction
getFunction
()
{
return
function
;
}
public
void
setFunction
(
AbstractLargeModelFunction
function
)
{
this
.
function
=
function
;
}
@Override
public
String
toString
()
{
return
"Tool{"
+
"type='"
+
type
+
'\''
+
", function="
+
function
+
'}'
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/ToolChoice.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
.
domain
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
ToolChoice
{
// 属性: type, 必填
private
String
type
;
private
ToolFunction
toolFunction
;
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getType
()
{
return
type
;
}
public
ToolFunction
getToolFunction
()
{
return
toolFunction
;
}
public
void
setToolFunction
(
ToolFunction
toolFunction
)
{
this
.
toolFunction
=
toolFunction
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/common/domain/ToolFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
.
domain
;
public
class
ToolFunction
{
private
String
name
;
private
String
arguments
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getArguments
()
{
return
arguments
;
}
public
void
setArguments
(
String
arguments
)
{
this
.
arguments
=
arguments
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/entity/largemodel/LargeModelDemandResult.java
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
entity
.
largemodel
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
entity
.
largemodel
;
import
cn.com.poc.support.dgTools.result.AbstractResult
;
import
cn.com.poc.support.dgTools.result.AbstractResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.common.domain.ToolFunction
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -10,6 +11,10 @@ public class LargeModelDemandResult extends AbstractResult implements Serializab
...
@@ -10,6 +11,10 @@ public class LargeModelDemandResult extends AbstractResult implements Serializab
private
String
message
;
private
String
message
;
private
ToolFunction
function
;
private
String
finish_reason
;
public
String
getCode
()
{
public
String
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -26,11 +31,29 @@ public class LargeModelDemandResult extends AbstractResult implements Serializab
...
@@ -26,11 +31,29 @@ public class LargeModelDemandResult extends AbstractResult implements Serializab
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
ToolFunction
getFunction
()
{
return
function
;
}
public
void
setFunction
(
ToolFunction
function
)
{
this
.
function
=
function
;
}
public
String
getFinish_reason
()
{
return
finish_reason
;
}
public
void
setFinish_reason
(
String
finish_reason
)
{
this
.
finish_reason
=
finish_reason
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"LargeModelDemandResult{"
+
return
"LargeModelDemandResult{"
+
"code='"
+
code
+
'\''
+
"code='"
+
code
+
'\''
+
", message='"
+
message
+
'\''
+
", message='"
+
message
+
'\''
+
", function="
+
function
+
", finish_reason='"
+
finish_reason
+
'\''
+
'}'
;
'}'
;
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/entity/largemodel/LargeModelResponse.java
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
entity
.
largemodel
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
entity
.
largemodel
;
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
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFilter
;
import
com.fasterxml.jackson.annotation.JsonFilter
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -22,6 +22,8 @@ public class LargeModelResponse implements Serializable {
...
@@ -22,6 +22,8 @@ public class LargeModelResponse implements Serializable {
private
Message
[]
messages
;
private
Message
[]
messages
;
private
Tool
[]
tools
;
private
Float
temperature
;
private
Float
temperature
;
@JsonFilter
(
"top_p"
)
@JsonFilter
(
"top_p"
)
...
@@ -46,6 +48,8 @@ public class LargeModelResponse implements Serializable {
...
@@ -46,6 +48,8 @@ public class LargeModelResponse implements Serializable {
private
String
user
;
private
String
user
;
private
String
tool_choice
;
public
String
getModel
()
{
public
String
getModel
()
{
return
model
;
return
model
;
}
}
...
@@ -142,21 +146,19 @@ public class LargeModelResponse implements Serializable {
...
@@ -142,21 +146,19 @@ public class LargeModelResponse implements Serializable {
this
.
user
=
user
;
this
.
user
=
user
;
}
}
@Override
public
String
getTool_choice
()
{
public
String
toString
()
{
return
tool_choice
;
return
"LargeModelResponse{"
+
}
"model='"
+
model
+
'\''
+
", messages="
+
Arrays
.
toString
(
messages
)
+
public
void
setTool_choice
(
String
tool_choice
)
{
", temperature="
+
temperature
+
this
.
tool_choice
=
tool_choice
;
", topP="
+
topP
+
}
", n="
+
n
+
", stream="
+
stream
+
public
Tool
[]
getTools
()
{
", stop="
+
Arrays
.
toString
(
stop
)
+
return
tools
;
", maxTokens="
+
maxTokens
+
}
", presencePenalty="
+
presencePenalty
+
", frequencyPenalty="
+
frequencyPenalty
+
public
void
setTools
(
Tool
[]
tools
)
{
", logit_bias="
+
logit_bias
+
this
.
tools
=
tools
;
", user='"
+
user
+
'\''
+
'}'
;
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/AbstractExecuteLargeModelFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
public
interface
AbstractExecuteLargeModelFunction
{
String
doMemoryFunction
(
String
content
,
String
useStatus
,
Boolean
isLongMemory
);
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/AbstractLargeModelFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
java.util.Map
;
public
class
AbstractLargeModelFunction
{
private
String
name
;
// 函数名
private
String
description
;
// 函数描述
private
Map
<
String
,
Object
>
parameters
;
// 函数请求参数
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Map
<
String
,
Object
>
getParameters
()
{
return
parameters
;
}
public
void
setParameters
(
Map
<
String
,
Object
>
parameters
)
{
this
.
parameters
=
parameters
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/ExecuteLargeModelFunctionEnum.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.utils.SpringUtils
;
public
enum
ExecuteLargeModelFunctionEnum
{
set_long_memory
(
ExecuteSetLongMemoryFunction
.
class
),
set_value_memory
(
ExecuteSetValueMemoryFunction
.
class
),
search_memory_content
(
ExecuteSearchMemoryContentFunction
.
class
),
search_memory_content_by_Enum
(
ExecuteSearchMemoryContentByEnumFunction
.
class
);
private
Class
<?
extends
AbstractExecuteLargeModelFunction
>
executeFunction
;
ExecuteLargeModelFunctionEnum
(
Class
<?
extends
AbstractExecuteLargeModelFunction
>
executeFunction
)
{
this
.
executeFunction
=
executeFunction
;
}
public
AbstractExecuteLargeModelFunction
getExecuteFunction
()
{
return
SpringUtils
.
getBean
(
executeFunction
);
}
public
void
setExecuteFunction
(
Class
<
AbstractExecuteLargeModelFunction
>
executeFunction
)
{
this
.
executeFunction
=
executeFunction
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/ExecuteSearchMemoryContentByEnumFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.hutool.json.JSONObject
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
ExecuteSearchMemoryContentByEnumFunction
implements
AbstractExecuteLargeModelFunction
{
@Resource
private
RedisService
redisService
;
@Override
public
String
doMemoryFunction
(
String
content
,
String
useStatus
,
Boolean
isLongMemory
)
{
// 用enum给定的内容名来查询用户相关信息
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
String
contentName
=
jsonObject
.
getStr
(
"content"
);
StringBuffer
result
=
new
StringBuffer
();
// 先查询变量记忆
String
key
=
useStatus
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
contentName
;
result
.
append
(
redisService
.
get
(
key
));
// 如果短期记忆没查到
if
(
result
.
toString
().
isEmpty
()){
// 判断是否开启了长期记忆,若开启,则查询长期记忆
if
(
isLongMemory
)
{
String
longMemoryKey
=
useStatus
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
result
.
append
(
redisService
.
get
(
longMemoryKey
));
}
}
return
result
.
toString
();
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/ExecuteSearchMemoryContentFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
ExecuteSearchMemoryContentFunction
implements
AbstractExecuteLargeModelFunction
{
@Resource
private
RedisService
redisService
;
@Override
public
String
doMemoryFunction
(
String
content
,
String
useStatus
,
Boolean
isLongMemory
)
{
// 查询用户相关信息(什么内容都可以)
String
result
=
null
;
// 判断是否开启了长期记忆,若开启,则查询长期记忆
if
(
isLongMemory
)
{
String
longMemoryKey
=
useStatus
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
"longMemory"
;
result
=
redisService
.
hmget
(
longMemoryKey
).
toString
();
}
return
result
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/ExecuteSetLongMemoryFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.DateUtils
;
import
cn.hutool.json.JSONObject
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
ExecuteSetLongMemoryFunction
implements
AbstractExecuteLargeModelFunction
{
@Resource
private
RedisService
redisService
;
@Override
public
String
doMemoryFunction
(
String
content
,
String
useStatus
,
Boolean
isLongMemory
)
{
// todo 执行保存长期记忆的操作
if
(
isLongMemory
){
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 content
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
key
=
useStatus
+
":"
+
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
(
key
,
result
);
}
return
"SUCCESS"
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/ExecuteSetValueMemoryFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.hutool.json.JSONObject
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
ExecuteSetValueMemoryFunction
implements
AbstractExecuteLargeModelFunction
{
@Resource
private
RedisService
redisService
;
@Override
public
String
doMemoryFunction
(
String
content
,
String
useStatus
,
Boolean
isLongMemory
)
{
// todo 执行保存变量的操作
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 contentName 和 contentValue
String
contentName
=
jsonObject
.
getStr
(
"contentName"
);
String
contentValue
=
jsonObject
.
getStr
(
"contentValue"
);
String
key
=
useStatus
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
()
+
":"
+
contentName
;
redisService
.
set
(
key
,
contentValue
);
return
"SUCCESS"
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/LargeModelFunctionEnum.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
public
enum
LargeModelFunctionEnum
{
setLongMemory
(
new
SetLongMemoryLargeModelFunction
()),
setValueMemory
(
new
SetValueMemoryLargeModelFunction
()),
searchMemoryContent
(
new
SearchMemoryContentFunction
()),
search_memory_content_by_Enum
(
new
SearchMemoryContentByEnumFunction
());
private
AbstractLargeModelFunction
function
;
LargeModelFunctionEnum
(
AbstractLargeModelFunction
function
){
this
.
function
=
function
;
}
public
AbstractLargeModelFunction
getFunction
()
{
return
function
;
}
public
void
setFunction
(
AbstractLargeModelFunction
function
)
{
this
.
function
=
function
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SearchMemoryContentByEnumFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SearchMemoryContentByEnumFunction
extends
AbstractLargeModelFunction
{
public
SearchMemoryContentByEnumFunction
()
{
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
parameters
.
put
(
"required"
,
required
);
super
.
setName
(
"search_memory_content_by_Enum"
);
super
.
setDescription
(
"用enum给定的内容名来查询用信息"
);
super
.
setParameters
(
parameters
);
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SearchMemoryContentFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SearchMemoryContentFunction
extends
AbstractLargeModelFunction
{
public
SearchMemoryContentFunction
()
{
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
"string"
);
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
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
parameters
.
put
(
"required"
,
required
);
super
.
setName
(
"search_memory_content"
);
super
.
setDescription
(
"获取用户相关信息"
);
super
.
setParameters
(
parameters
);
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SetLongMemoryLargeModelFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SetLongMemoryLargeModelFunction
extends
AbstractLargeModelFunction
{
public
SetLongMemoryLargeModelFunction
()
{
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
"string"
);
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
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
parameters
.
put
(
"required"
,
required
);
super
.
setName
(
"set_long_memory"
);
super
.
setDescription
(
"用来保存用户想记录的内容(什么内容都可以)"
);
super
.
setParameters
(
parameters
);
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/SetValueMemoryLargeModelFunction.java
0 → 100644
View file @
5e8e4b56
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SetValueMemoryLargeModelFunction
extends
AbstractLargeModelFunction
{
public
SetValueMemoryLargeModelFunction
()
{
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"contentName"
);
required
.
add
(
"contentValue"
);
parameters
.
put
(
"required"
,
required
);
super
.
setName
(
"set_value_memory"
);
super
.
setDescription
(
"用enum给定的内容名来保存用户想记录的内容值"
);
super
.
setParameters
(
parameters
);
}
}
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