feat: add fallback response handling and UI indicators

- Introduced a new `is_fallback` property to track when responses are generated without knowledge base matches.
- Updated the chat components to display fallback hints and indicators in the UI, enhancing user awareness of fallback responses.
- Added translations for fallback hints in multiple languages, improving accessibility for diverse users.
- Modified backend logic to emit fallback status in response events, ensuring consistent handling across the application.

These changes improve the user experience by providing clear feedback on fallback responses, enhancing the overall interaction with the chat system.
This commit is contained in:
wizardchen
2026-03-04 21:32:19 +08:00
committed by lyingbug
parent 5ae076e22c
commit 44f38ca6c3
16 changed files with 177 additions and 36 deletions
@@ -291,6 +291,9 @@ func (h *AgentStreamHandler) handleFinalAnswer(ctx context.Context, evt event.Ev
// Accumulate final answer locally for assistant message (database)
h.finalAnswer += data.Content
if data.IsFallback {
h.assistantMessage.IsFallback = true
}
// Calculate duration if done
var metadata map[string]interface{}
@@ -308,6 +311,9 @@ func (h *AgentStreamHandler) handleFinalAnswer(ctx context.Context, evt event.Ev
"event_id": evt.ID,
}
}
if data.IsFallback {
metadata["is_fallback"] = true
}
h.mu.Unlock()
// Append this chunk to stream (frontend will accumulate by event ID)