From 6896c7795d20b952ac70f61f18bd06100b7f6f82 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Sun, 15 Mar 2026 18:17:58 +0800 Subject: [PATCH] feat: add web search option to AgentQA functionality - Introduced a new parameter `webSearchEnabled` to the `AgentQA` method, allowing for conditional web search capabilities. - Updated the session service interface and handler to accommodate the new parameter, enhancing the flexibility of the AgentQA process. - Adjusted the configuration to ensure that web search functionality can be toggled based on the provided input. These changes improve the AgentQA feature by enabling users to control web search integration, enhancing the overall user experience. --- internal/application/service/session.go | 3 ++- internal/handler/session/qa.go | 1 + internal/types/interfaces/session.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/application/service/session.go b/internal/application/service/session.go index a1841b25..91408dca 100644 --- a/internal/application/service/session.go +++ b/internal/application/service/session.go @@ -1371,6 +1371,7 @@ func (s *sessionService) AgentQA( knowledgeBaseIDs []string, knowledgeIDs []string, imageURLs []string, imageDescription string, userMessageID string, + webSearchEnabled bool, ) error { _ = userMessageID // reserved for future use (AgentQA pipeline differs from KnowledgeQA) sessionID := session.ID @@ -1421,7 +1422,7 @@ func (s *sessionService) AgentQA( MaxIterations: customAgent.Config.MaxIterations, ReflectionEnabled: customAgent.Config.ReflectionEnabled, Temperature: customAgent.Config.Temperature, - WebSearchEnabled: customAgent.Config.WebSearchEnabled, + WebSearchEnabled: customAgent.Config.WebSearchEnabled && webSearchEnabled, WebSearchMaxResults: customAgent.Config.WebSearchMaxResults, MultiTurnEnabled: customAgent.Config.MultiTurnEnabled, HistoryTurns: customAgent.Config.HistoryTurns, diff --git a/internal/handler/session/qa.go b/internal/handler/session/qa.go index 457a4ced..cf8baf3f 100644 --- a/internal/handler/session/qa.go +++ b/internal/handler/session/qa.go @@ -654,6 +654,7 @@ func (h *Handler) executeAgentModeQA(reqCtx *qaRequestContext) { reqCtx.knowledgeIDs, imageURLs, imageDescription, reqCtx.userMessageID, + reqCtx.webSearchEnabled, ) if err != nil { logger.ErrorWithFields(streamCtx.asyncCtx, err, nil) diff --git a/internal/types/interfaces/session.go b/internal/types/interfaces/session.go index 776b93b6..06bf034c 100644 --- a/internal/types/interfaces/session.go +++ b/internal/types/interfaces/session.go @@ -67,6 +67,7 @@ type SessionService interface { knowledgeBaseIDs []string, knowledgeIDs []string, imageURLs []string, imageDescription string, userMessageID string, + webSearchEnabled bool, ) error // ClearContext clears the LLM context for a session ClearContext(ctx context.Context, sessionID string) error