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
7876e3fa
Commit
7876e3fa
authored
Nov 01, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 初始化 valueMemory 函数
parent
ef6af236
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
4 deletions
+65
-4
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+1
-1
AgentApplicationValueMemoryDto.java
...agent_application/dto/AgentApplicationValueMemoryDto.java
+24
-0
AgentApplicationInfoRest.java
.../poc/agent_application/rest/AgentApplicationInfoRest.java
+5
-0
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+27
-1
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+2
-1
SetValueMemoryFunction.java
...mand/ai/function/value_memory/SetValueMemoryFunction.java
+6
-1
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
7876e3fa
...
...
@@ -422,7 +422,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
if
(
MapUtils
.
isNotEmpty
(
map
))
{
Set
<
Object
>
keySet
=
map
.
keySet
();
for
(
Object
key
:
keySet
)
{
stringBuilder
.
append
(
key
.
toString
()).
append
(
":"
).
append
(
map
.
get
(
key
)
.
toString
()
).
append
(
StringUtils
.
LF
);
stringBuilder
.
append
(
key
.
toString
()).
append
(
":"
).
append
(
map
.
get
(
key
)).
append
(
StringUtils
.
LF
);
}
}
promptTemplate
=
promptTemplate
.
replace
(
"${valueMemoryResult}"
,
stringBuilder
.
toString
());
...
...
src/main/java/cn/com/poc/agent_application/dto/AgentApplicationValueMemoryDto.java
0 → 100644
View file @
7876e3fa
package
cn
.
com
.
poc
.
agent_application
.
dto
;
public
class
AgentApplicationValueMemoryDto
{
private
String
key
;
private
String
value
;
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/cn/com/poc/agent_application/rest/AgentApplicationInfoRest.java
View file @
7876e3fa
...
...
@@ -94,6 +94,11 @@ public interface AgentApplicationInfoRest extends BaseRest {
* */
void
collectOrCancelAgentInPerson
(
@RequestParam
String
agentId
)
throws
Exception
;
/**
* 获取【变量】列表
*/
List
<
AgentApplicationValueMemoryDto
>
getVariableList
(
@RequestParam
String
agentId
)
throws
Exception
;
/**
* 获取应用的记忆片段
*
...
...
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
7876e3fa
...
...
@@ -223,7 +223,8 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
String
key
=
variable
.
getKey
();
String
variableDefault
=
variable
.
getVariableDefault
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
key
,
variableDefault
);
jsonObject
.
put
(
"contentName"
,
key
);
jsonObject
.
put
(
"contentValue"
,
variableDefault
);
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
doFunction
(
jsonObject
.
toJSONString
(),
agentId
);
}
}
...
...
@@ -331,6 +332,31 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
agentApplicationInfoService
.
collectOrCancelAgentInPerson
(
agentId
);
}
@Override
public
List
<
AgentApplicationValueMemoryDto
>
getVariableList
(
String
agentId
)
{
Map
<
Object
,
Object
>
map
=
GetValueMemory
.
get
(
agentId
);
List
<
AgentApplicationValueMemoryDto
>
result
=
new
ArrayList
<>();
if
(
MapUtils
.
isEmpty
(
map
))
{
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
agentId
);
List
<
Variable
>
variableStructure
=
infoEntity
.
getVariableStructure
();
for
(
Variable
variable
:
variableStructure
)
{
AgentApplicationValueMemoryDto
valueMemoryDto
=
new
AgentApplicationValueMemoryDto
();
valueMemoryDto
.
setKey
(
variable
.
getKey
());
valueMemoryDto
.
setValue
(
variable
.
getVariableDefault
());
result
.
add
(
valueMemoryDto
);
}
}
else
{
Set
<
Object
>
keySet
=
map
.
keySet
();
for
(
Object
key
:
keySet
)
{
AgentApplicationValueMemoryDto
valueMemoryDto
=
new
AgentApplicationValueMemoryDto
();
valueMemoryDto
.
setKey
(
key
.
toString
());
valueMemoryDto
.
setValue
(
map
.
get
(
key
).
toString
());
result
.
add
(
valueMemoryDto
);
}
}
return
result
;
}
@Override
public
List
<
AgentLongMemoryDto
>
getLongMemoryList
(
String
agentId
)
throws
Exception
{
Assert
.
notNull
(
agentId
);
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
7876e3fa
...
...
@@ -324,7 +324,8 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
String
key
=
variable
.
getKey
();
String
variableDefault
=
variable
.
getVariableDefault
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
key
,
variableDefault
);
jsonObject
.
put
(
"contentName"
,
key
);
jsonObject
.
put
(
"contentValue"
,
variableDefault
);
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
doFunction
(
jsonObject
.
toJSONString
(),
identifier
);
}
}
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/value_memory/SetValueMemoryFunction.java
View file @
7876e3fa
...
...
@@ -3,6 +3,7 @@ package cn.com.poc.thirdparty.resource.demand.ai.function.value_memory;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.hutool.json.JSONObject
;
...
...
@@ -65,7 +66,11 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
Map
<
String
,
Object
>
contentName
=
new
HashMap
<>();
contentName
.
put
(
"type"
,
"string"
);
contentName
.
put
(
"description"
,
"内容名"
);
contentName
.
put
(
"enum"
,
variableStructure
);
// 设置变量
List
<
String
>
enumList
=
new
ArrayList
<>();
for
(
Variable
variable
:
variableStructure
)
{
enumList
.
add
(
variable
.
getKey
());
}
contentName
.
put
(
"enum"
,
JsonUtils
.
serialize
(
enumList
));
// 设置变量
Map
<
String
,
Object
>
contentValue
=
new
HashMap
<>();
contentValue
.
put
(
"type"
,
"string"
);
contentValue
.
put
(
"description"
,
"内容值"
);
...
...
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