From 8b81b17984dfdc2099fb98af62f3bb92c55247e3 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser Date: Wed, 24 Apr 2024 14:41:03 +0800 Subject: [PATCH] fix: only render sources with metadata --- .../nextjs/app/components/ui/chat/chat-sources.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/types/streaming/nextjs/app/components/ui/chat/chat-sources.tsx b/templates/types/streaming/nextjs/app/components/ui/chat/chat-sources.tsx index ece5641ed..de8c3edb0 100644 --- a/templates/types/streaming/nextjs/app/components/ui/chat/chat-sources.tsx +++ b/templates/types/streaming/nextjs/app/components/ui/chat/chat-sources.tsx @@ -11,6 +11,7 @@ export function ChatSources({ data }: { data: SourceData }) { const sources = useMemo(() => { return ( data.nodes + ?.filter((node) => Object.keys(node.metadata).length > 0) ?.filter((node) => (node.score ?? 1) > SCORE_THRESHOLD) .sort((a, b) => (b.score ?? 1) - (a.score ?? 1)) || [] ); @@ -84,5 +85,10 @@ function NodeInfo({ node }: { node: SourceNode }) { // node generated by unknown loader, implement renderer by analyzing logged out metadata console.log("Node metadata", node.metadata); - return

Sorry, unknown node type. Please add a new renderer.

; + return ( +

+ Sorry, unknown node type. Please add a new renderer in the NodeInfo + component. +

+ ); }