feat(rag): notify browser of LLM retry/waiting/fallback/warning and search hit count#3130
Merged
Merged
Conversation
…seComplete to ChatPhaseCallback
…t in phase complete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces previously-invisible in-progress events from the AI Search (RAG/Chat) flow to the browser UI via new SSE event types and an extended phase-complete payload.
New SSE events
retry{phase, operation, attempt, maxAttempts, sleepMs, cause?}waiting{phase, reason, elapsedMs, timeoutMs}streamChatWithConcurrencyControlblocks on an exhausted permitfallback{phase, reason, originalQuery, newQuery}no_results/no_relevant_results)warning{phase, code, detail}The existing
event: phase(status: complete) payload is now extended for the search phase to includehitCountso the browser can show "N documents found" before the longer evaluate/fetch phases finish.Changes
LlmStreamCallback— addsdefaultno-oponRetry/onWaiting/onWarning.@FunctionalInterfacepreserved.ChatPhaseCallback— addsdefaultno-oponRetry/onWaiting/onFallback/onWarningand a payload-awareonPhaseComplete(String, Map<String,Object>)that defaults to delegating to the legacy single-arg form.PhaseAwareStreamCallback(new) — bridges LLM-layerLlmStreamCallbackevents to phase-awareChatPhaseCallbackevents.ChatClient.streamChatEnhanced— wraps everyLlmStreamCallbacklambda withPhaseAwareStreamCallback, emitsonFallbackbefore query regeneration, includeshitCountin search phase completion, firesonWarningwhen intent detection falls back.AbstractLlmClient.streamChatWithConcurrencyControl— firesonWaitingwhen the concurrency permit is unavailable.IntentDetectionResult— addsisFallback()flag (additive; onlyfallbackSearch(...)setstrue).ChatApiManager— emits the new SSE events. NewemitSseEventSafely+putIfNotNullhelpers reduce boilerplate.chat.js/chat.jsp— adds listeners for the new events and i18n labels.fess_label*.properties— adds 6 new keys across all 17 language files (English source for non-translated languages, Japanese translations included).Backwards compatibility
All interface additions are
defaultno-op methods. Existing implementers (including the 3 LLM plugins) compile and behave unchanged. Plugin PRs to actually fireonRetryfollow this PR — see "Companion PRs" below.Companion PRs (must merge AFTER this one and a new SNAPSHOT is published)
LlmStreamCallback#onRetryfromexecuteWithRetryUntil those merge, the
retrySSE event will not fire (rest of the events fire from this PR alone).Test plan
mvn test— 8 touched test classes, 72 tests, 0 failuresLlmStreamCallbackTest(1)ChatPhaseCallbackTest(9 — 7 preexisting preserved + 2 new)PhaseAwareStreamCallbackTest(4)AbstractLlmClientWaitingTest(2)ChatClientFallbackTest(1)ChatClientHitCountTest(2)ChatClientWarningTest(2)ChatApiManagerTest(51 — 47 preexisting preserved + 4 new)mvn formatter:format && mvn license:format— clean (no-op)node -c chat.js— JS syntax OK