diff --git a/src/components/AssistantSteps.tsx b/src/components/AssistantSteps.tsx index b369d1a..6c84ec6 100644 --- a/src/components/AssistantSteps.tsx +++ b/src/components/AssistantSteps.tsx @@ -16,9 +16,12 @@ import { useChat } from '@/lib/hooks/useChat'; const getStepIcon = (step: ResearchBlockSubStep) => { if (step.type === 'reasoning') { return ; - } else if (step.type === 'searching') { + } else if (step.type === 'searching' || step.type === 'upload_searching') { return ; - } else if (step.type === 'search_results') { + } else if ( + step.type === 'search_results' || + step.type === 'upload_search_results' + ) { return ; } else if (step.type === 'reading') { return ; @@ -39,6 +42,10 @@ const getStepTitle = ( return `Found ${step.reading.length} ${step.reading.length === 1 ? 'result' : 'results'}`; } else if (step.type === 'reading') { return `Reading ${step.reading.length} ${step.reading.length === 1 ? 'source' : 'sources'}`; + } else if (step.type === 'upload_searching') { + return 'Scanning your uploaded documents'; + } else if (step.type === 'upload_search_results') { + return `Reading ${step.results.length} ${step.results.length === 1 ? 'document' : 'documents'}`; } return 'Processing'; @@ -195,6 +202,56 @@ const AssistantSteps = ({ })} )} + + {step.type === 'upload_searching' && + step.queries.length > 0 && ( +
+ {step.queries.map((query, idx) => ( + + {query} + + ))} +
+ )} + + {step.type === 'upload_search_results' && + step.results.length > 0 && ( +
+ {step.results.slice(0, 4).map((result, idx) => { + const title = + (result.metadata && + (result.metadata.title || + result.metadata.fileName)) || + 'Untitled document'; + const snippet = (result.content || '') + .replace(/\s+/g, ' ') + .trim() + .slice(0, 220); + + return ( +
+
+ +
+
+
+ {title} +
+
+ {snippet || 'No preview available.'} +
+
+
+ ); + })} +
+ )} ); diff --git a/src/components/MessageSources.tsx b/src/components/MessageSources.tsx index ea5fa79..a1db27a 100644 --- a/src/components/MessageSources.tsx +++ b/src/components/MessageSources.tsx @@ -37,7 +37,7 @@ const MessageSources = ({ sources }: { sources: Chunk[] }) => {

- {source.metadata.url === 'File' ? ( + {source.metadata.url.includes('file_id://') ? (
@@ -51,7 +51,9 @@ const MessageSources = ({ sources }: { sources: Chunk[] }) => { /> )}

- {source.metadata.url.replace(/.+\/\/|www.|\..+/g, '')} + {source.metadata.url.includes('file_id://') + ? 'Uploaded File' + : source.metadata.url.replace(/.+\/\/|www.|\..+/g, '')}