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
802b8915
Commit
802b8915
authored
Jun 05, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dbChain): 新增上下文内容
parent
fe27629d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
AgentApplicationServiceImpl.java
...plication/aggregate/impl/AgentApplicationServiceImpl.java
+16
-0
DBChainResponse.java
...ty/resource/demand/ai/entity/dbchain/DBChainResponse.java
+9
-0
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationServiceImpl.java
View file @
802b8915
...
@@ -1133,6 +1133,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -1133,6 +1133,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
return
null
;
return
null
;
}
}
String
query
=
getMessageQuestion
(
messages
);
String
query
=
getMessageQuestion
(
messages
);
String
context
=
getContext
(
messages
);
List
<
DBChainResult
>
results
=
new
ArrayList
<>();
List
<
DBChainResult
>
results
=
new
ArrayList
<>();
for
(
Integer
databaseId
:
databaseIds
)
{
for
(
Integer
databaseId
:
databaseIds
)
{
BizKnowledgeDatabaseEntity
bizKnowledgeDatabaseEntity
=
bizKnowledgeDatabaseService
.
get
(
databaseId
.
longValue
());
BizKnowledgeDatabaseEntity
bizKnowledgeDatabaseEntity
=
bizKnowledgeDatabaseService
.
get
(
databaseId
.
longValue
());
...
@@ -1141,6 +1142,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -1141,6 +1142,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
}
}
DBChainResponse
dbChainResponse
=
new
DBChainResponse
();
DBChainResponse
dbChainResponse
=
new
DBChainResponse
();
dbChainResponse
.
setQuestion
(
query
);
dbChainResponse
.
setQuestion
(
query
);
dbChainResponse
.
setContext
(
context
);
dbChainResponse
.
setPrompt
(
null
);
dbChainResponse
.
setPrompt
(
null
);
dbChainResponse
.
setTableFilters
(
null
);
dbChainResponse
.
setTableFilters
(
null
);
dbChainResponse
.
setMysqlUser
(
bizKnowledgeDatabaseEntity
.
getDbUsername
());
dbChainResponse
.
setMysqlUser
(
bizKnowledgeDatabaseEntity
.
getDbUsername
());
...
@@ -1168,6 +1170,20 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -1168,6 +1170,20 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
return
query
;
return
query
;
}
}
private
String
getContext
(
List
<
Message
>
messages
)
{
StringBuilder
context
=
new
StringBuilder
();
if
(
messages
.
size
()
>=
6
)
{
for
(
int
i
=
6
;
i
>
0
;
i
--)
{
Message
message
=
messages
.
get
(
messages
.
size
()
-
i
);
context
.
append
(
message
.
getRole
()).
append
(
":"
).
append
(
message
.
getContent
()).
append
(
StringUtils
.
LF
);
}
}
else
{
for
(
Message
message
:
messages
)
{
context
.
append
(
message
.
getRole
()).
append
(
":"
).
append
(
message
.
getContent
()).
append
(
StringUtils
.
LF
);
}
}
return
context
.
toString
();
}
/**
/**
* 更新【记忆变量】结构
* 更新【记忆变量】结构
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/entity/dbchain/DBChainResponse.java
View file @
802b8915
...
@@ -15,6 +15,8 @@ public class DBChainResponse extends AbstractRequest<DBChainResult> implements S
...
@@ -15,6 +15,8 @@ public class DBChainResponse extends AbstractRequest<DBChainResult> implements S
private
String
prompt
;
private
String
prompt
;
private
String
context
;
private
List
<
String
>
tableFilters
;
private
List
<
String
>
tableFilters
;
private
String
mysqlUser
;
private
String
mysqlUser
;
...
@@ -29,6 +31,13 @@ public class DBChainResponse extends AbstractRequest<DBChainResult> implements S
...
@@ -29,6 +31,13 @@ public class DBChainResponse extends AbstractRequest<DBChainResult> implements S
private
String
apiKey
;
private
String
apiKey
;
public
String
getContext
()
{
return
context
;
}
public
void
setContext
(
String
context
)
{
this
.
context
=
context
;
}
public
String
getQuestion
()
{
public
String
getQuestion
()
{
return
question
;
return
question
;
...
...
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