Spaces:
Sleeping
Sleeping
dynamic validation status message
Browse files- src/App.js +24 -1
src/App.js
CHANGED
|
@@ -672,7 +672,7 @@ function App() {
|
|
| 672 |
// After streaming completes, switch to validation phase
|
| 673 |
setIsValidating(true);
|
| 674 |
setLoadingStatus("Validating response...");
|
| 675 |
-
assistantMsg.statusText = "
|
| 676 |
assistantMsg.thinking = true;
|
| 677 |
setMessages([...newMessages]);
|
| 678 |
|
|
@@ -681,8 +681,27 @@ function App() {
|
|
| 681 |
|
| 682 |
// Fetch debug info via non-streaming endpoint
|
| 683 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
const debugResult = await sendChat(userMsg.text, strictMode, historyForBackend, token, sessionId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 685 |
if (debugResult.prolog_query_info) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 686 |
// Replace the streamed text with the authoritative non-streaming reply
|
| 687 |
// so citations/strict-mode enforcement match the debug panel.
|
| 688 |
if (typeof debugResult.reply === "string" && debugResult.reply.trim()) {
|
|
@@ -691,14 +710,18 @@ function App() {
|
|
| 691 |
assistantMsg.text = debugResult.reply;
|
| 692 |
}
|
| 693 |
assistantMsg.thinking = false;
|
|
|
|
| 694 |
assistantMsg.debug = debugResult.prolog_query_info;
|
| 695 |
setMessages([...newMessages]);
|
| 696 |
} else {
|
| 697 |
// Still re-render if we replaced the text above.
|
|
|
|
|
|
|
| 698 |
setMessages([...newMessages]);
|
| 699 |
}
|
| 700 |
} catch (debugErr) {
|
| 701 |
assistantMsg.thinking = false;
|
|
|
|
| 702 |
assistantMsg.debug = {
|
| 703 |
error: String((debugErr && debugErr.message) || debugErr || "Debug fetch failed"),
|
| 704 |
hint: "Non-stream /chat request failed; check gateway/backend logs and timeouts."
|
|
|
|
| 672 |
// After streaming completes, switch to validation phase
|
| 673 |
setIsValidating(true);
|
| 674 |
setLoadingStatus("Validating response...");
|
| 675 |
+
assistantMsg.statusText = "Re-querying knowledge base for validation...";
|
| 676 |
assistantMsg.thinking = true;
|
| 677 |
setMessages([...newMessages]);
|
| 678 |
|
|
|
|
| 681 |
|
| 682 |
// Fetch debug info via non-streaming endpoint
|
| 683 |
try {
|
| 684 |
+
// Update status: verifying citations
|
| 685 |
+
assistantMsg.statusText = "Verifying citations and strict mode compliance...";
|
| 686 |
+
setMessages([...newMessages]);
|
| 687 |
+
|
| 688 |
const debugResult = await sendChat(userMsg.text, strictMode, historyForBackend, token, sessionId);
|
| 689 |
+
|
| 690 |
+
// Update status: processing debug info
|
| 691 |
+
assistantMsg.statusText = "Processing debug information...";
|
| 692 |
+
setMessages([...newMessages]);
|
| 693 |
+
|
| 694 |
if (debugResult.prolog_query_info) {
|
| 695 |
+
// Update status: finalizing response
|
| 696 |
+
const totalResults = debugResult.prolog_query_info.total_results || 0;
|
| 697 |
+
const predicates = debugResult.prolog_query_info.predicates_queried || [];
|
| 698 |
+
if (predicates.length > 0) {
|
| 699 |
+
assistantMsg.statusText = `Validated ${predicates.length} predicates, ${totalResults} results`;
|
| 700 |
+
setMessages([...newMessages]);
|
| 701 |
+
// Brief delay to show the final status
|
| 702 |
+
await new Promise(resolve => setTimeout(resolve, 300));
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
// Replace the streamed text with the authoritative non-streaming reply
|
| 706 |
// so citations/strict-mode enforcement match the debug panel.
|
| 707 |
if (typeof debugResult.reply === "string" && debugResult.reply.trim()) {
|
|
|
|
| 710 |
assistantMsg.text = debugResult.reply;
|
| 711 |
}
|
| 712 |
assistantMsg.thinking = false;
|
| 713 |
+
assistantMsg.statusText = "";
|
| 714 |
assistantMsg.debug = debugResult.prolog_query_info;
|
| 715 |
setMessages([...newMessages]);
|
| 716 |
} else {
|
| 717 |
// Still re-render if we replaced the text above.
|
| 718 |
+
assistantMsg.thinking = false;
|
| 719 |
+
assistantMsg.statusText = "";
|
| 720 |
setMessages([...newMessages]);
|
| 721 |
}
|
| 722 |
} catch (debugErr) {
|
| 723 |
assistantMsg.thinking = false;
|
| 724 |
+
assistantMsg.statusText = "";
|
| 725 |
assistantMsg.debug = {
|
| 726 |
error: String((debugErr && debugErr.message) || debugErr || "Debug fetch failed"),
|
| 727 |
hint: "Non-stream /chat request failed; check gateway/backend logs and timeouts."
|