Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data-agent-frontend/src/services/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export interface GraphRequest {
agentId: string;
threadId?: string;
sessionId?: string;
query: string;
humanFeedback: boolean;
humanFeedbackContent?: string;
Expand Down Expand Up @@ -72,6 +73,9 @@ class GraphService {
params.append('rejectedPlan', request.rejectedPlan.toString());
params.append('nl2sqlOnly', request.nl2sqlOnly.toString());

if (request.sessionId) {
params.append('sessionId', request.sessionId);
}
if (request.humanFeedbackContent) {
params.append('humanFeedbackContent', request.humanFeedbackContent);
}
Expand Down
1 change: 1 addition & 0 deletions data-agent-frontend/src/views/AgentRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@
rejectedPlan: false,
humanFeedbackContent: null,
threadId: sessionState.lastRequest?.threadId || null,
sessionId: currentSession.value.id,
};

userInput.value = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public Flux<ServerSentEvent<GraphNodeResponse>> streamSearch(@RequestParam("agen
@RequestParam(value = "humanFeedback", required = false) boolean humanFeedback,
@RequestParam(value = "humanFeedbackContent", required = false) String humanFeedbackContent,
@RequestParam(value = "rejectedPlan", required = false) boolean rejectedPlan,
@RequestParam(value = "nl2sqlOnly", required = false) boolean nl2sqlOnly, ServerHttpResponse response) {
@RequestParam(value = "nl2sqlOnly", required = false) boolean nl2sqlOnly,
@RequestParam(value = "sessionId", required = false) String sessionId, ServerHttpResponse response) {
// Set SSE-related HTTP headers
response.getHeaders().add("Cache-Control", "no-cache");
response.getHeaders().add("Connection", "keep-alive");
Expand All @@ -65,6 +66,7 @@ public Flux<ServerSentEvent<GraphNodeResponse>> streamSearch(@RequestParam("agen
.humanFeedbackContent(humanFeedbackContent)
.rejectedPlan(rejectedPlan)
.nl2sqlOnly(nl2sqlOnly)
.sessionId(sessionId)
.build();
graphService.graphStreamProcess(sink, request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class GraphRequest {

private boolean nl2sqlOnly;

private String sessionId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public void graphStreamProcess(Sinks.Many<ServerSentEvent<GraphNodeResponse>> si
graphRequest.setThreadId(UUID.randomUUID().toString());
}
String threadId = graphRequest.getThreadId();
// 如果前端传了 sessionId,用 sessionId 统一多轮对话的 threadId
if (StringUtils.hasText(graphRequest.getSessionId())) {
threadId = graphRequest.getSessionId();
graphRequest.setThreadId(threadId);
}
log.info("[多轮调试-修复后] graphStreamProcess 入口, threadId={}, sessionId={}, query={}", threadId,
graphRequest.getSessionId(), graphRequest.getQuery());
// 创建或获取 StreamContext
StreamContext context = streamContextMap.computeIfAbsent(threadId, k -> new StreamContext());
context.setSink(sink);
Expand Down Expand Up @@ -138,6 +145,7 @@ private void handleNewProcess(GraphRequest graphRequest) {
context.setSpan(span);

String multiTurnContext = multiTurnContextManager.buildContext(threadId);
log.info("[多轮调试] handleNewProcess, threadId={}, multiTurnContext={}", threadId, multiTurnContext);
multiTurnContextManager.beginTurn(threadId, query);
Flux<NodeOutput> nodeOutputFlux = compiledGraph.stream(
Map.of(IS_ONLY_NL2SQL, nl2sqlOnly, INPUT_KEY, query, AGENT_ID, agentId, HUMAN_REVIEW_ENABLED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void streamSearch_validRequest_invokesGraphServiceAndReturnsFlux() {
doNothing().when(graphService).graphStreamProcess(any(Sinks.Many.class), any(GraphRequest.class));

Flux<ServerSentEvent<GraphNodeResponse>> result = graphController.streamSearch("agent-1", "thread-1",
"show me sales data", false, null, false, false, serverHttpResponse);
"show me sales data", false, null, false, false, null, serverHttpResponse);

assertNotNull(result);

Expand All @@ -81,7 +81,7 @@ void streamSearch_humanFeedback_passesHumanFeedbackParams() {
doNothing().when(graphService).graphStreamProcess(any(Sinks.Many.class), any(GraphRequest.class));

Flux<ServerSentEvent<GraphNodeResponse>> result = graphController.streamSearch("agent-1", "thread-2",
"approve this plan", true, "looks good", false, false, serverHttpResponse);
"approve this plan", true, "looks good", false, false, null, serverHttpResponse);

assertNotNull(result);

Expand All @@ -99,7 +99,7 @@ void streamSearch_nl2sqlOnly_setsNl2sqlOnlyFlag() {
doNothing().when(graphService).graphStreamProcess(any(Sinks.Many.class), any(GraphRequest.class));

Flux<ServerSentEvent<GraphNodeResponse>> result = graphController.streamSearch("agent-1", null, "SELECT query",
false, null, false, true, serverHttpResponse);
false, null, false, true, null, serverHttpResponse);

assertNotNull(result);

Expand Down