From 3975e9257901cb753ac6fc9861b7c3950550fdd7 Mon Sep 17 00:00:00 2001 From: Santosh Bhavani Date: Sat, 25 Oct 2025 13:49:00 -0700 Subject: [PATCH] Add multi-hop indicators and collapsible thinking steps UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Display hop number (0, 1, 2...) with network icon for each triple - Show multi-hop path badge for paths with length > 1 - Add "Multi-hop enabled" badge in Retrieved Knowledge header - Implement collapsible thinking steps with proper chevron rotation - Parse tags from NVIDIA reasoning content - Reduce console logging (sample only, not full dataset) - Show path length with amber lightning icon This provides visual feedback about multi-hop reasoning paths and makes the LLM's chain-of-thought process transparent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../txt2kg/assets/frontend/app/rag/page.tsx | 67 ++++++++++++++----- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/nvidia/txt2kg/assets/frontend/app/rag/page.tsx b/nvidia/txt2kg/assets/frontend/app/rag/page.tsx index c5226a6..1806ba8 100644 --- a/nvidia/txt2kg/assets/frontend/app/rag/page.tsx +++ b/nvidia/txt2kg/assets/frontend/app/rag/page.tsx @@ -235,11 +235,18 @@ export default function RagPage() { } const data = await response.json(); - - // Log the retrieved triples for debugging - console.log('📊 Retrieved Triples:', data.triples); - console.log('🤖 LLM-Generated Answer:', data.answer); + + // Log sample of retrieved triples for debugging + console.log('📊 Retrieved Triples (sample):', data.triples.slice(0, 3)); + console.log('🤖 LLM-Generated Answer (preview):', data.answer?.substring(0, 200) + '...'); console.log('📈 Triple Count:', data.count); + + // DEBUG: Check if depth/pathLength are present in received data + if (data.triples && data.triples.length > 0) { + console.log('🔍 First triple structure:', JSON.stringify(data.triples[0], null, 2)); + console.log('🔍 Has depth?', 'depth' in data.triples[0]); + console.log('🔍 Has pathLength?', 'pathLength' in data.triples[0]); + } // Update the results with the triples (for display) setResults(data.triples || []); @@ -247,18 +254,11 @@ export default function RagPage() { relevanceScore = 0; // No relevance score for traditional search // Store the LLM answer for display - console.log('🔍 Checking answer:', { - hasAnswer: !!data.answer, - answerLength: data.answer?.length, - answerPreview: data.answer?.substring(0, 100) - }); - if (data.answer) { - console.log('💬 Full Answer:', data.answer); - console.log('✅ Setting llmAnswer state'); + console.log('✅ Setting llmAnswer state (length:', data.answer.length, 'chars)'); setLlmAnswer(data.answer); } else { - console.log('⚠️ No answer in response, setting null'); + console.log('⚠️ No answer in response'); setLlmAnswer(null); } @@ -438,9 +438,9 @@ export default function RagPage() { return ( <> {thinkContent && ( -
+
- + Reasoning Process @@ -477,6 +477,14 @@ export default function RagPage() {

{llmAnswer ? `Retrieved Knowledge (${results.length})` : `Results (${results.length})`}

+ {results.some((r: any) => r.pathLength && r.pathLength > 1) && ( + + + + + Multi-hop enabled + + )}
{results.map((triple, index) => ( @@ -509,8 +517,33 @@ export default function RagPage() {
)} {triple.confidence && !currentParams.usePureRag && ( -
- Confidence: {(triple.confidence * 100).toFixed(1)}% +
+
+
+ + Confidence: {(triple.confidence * 100).toFixed(1)}% + +
+ {triple.depth !== undefined && ( +
+ + + + + Hop: {triple.depth} + +
+ )} + {triple.pathLength !== undefined && triple.pathLength > 1 && ( +
+ + + + + Multi-hop path (length: {triple.pathLength}) + +
+ )}
)}