diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 99682400e..e9bc93ac8 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -1429,10 +1429,10 @@ export function ChatPage({ Object.hasOwn(packet, "stop_reason") && Object.hasOwn(packet, "level_question_num") ) { - sub_questions = constructSubQuestions( - sub_questions, - packet as StreamStopInfo - ); + // sub_questions = constructSubQuestions( + // sub_questions, + // packet as StreamStopInfo + // ); } else if (Object.hasOwn(packet, "sub_question")) { is_generating = true; sub_questions = constructSubQuestions( diff --git a/web/src/app/chat/interfaces.ts b/web/src/app/chat/interfaces.ts index 17c3a9989..b0bb36447 100644 --- a/web/src/app/chat/interfaces.ts +++ b/web/src/app/chat/interfaces.ts @@ -256,7 +256,7 @@ export const constructSubQuestions = ( (sq) => sq.level === level && sq.level_question_num === level_question_num ); if (subQuestion) { - subQuestion.is_complete = true; + // subQuestion.is_complete = true; } } else if ("top_documents" in newDetail) { const { level, level_question_num, top_documents } = newDetail; @@ -271,6 +271,7 @@ export const constructSubQuestions = ( answer: "", sub_queries: [], context_docs: { top_documents }, + is_complete: false, }; } else { subQuestion.context_docs = { top_documents }; @@ -291,6 +292,7 @@ export const constructSubQuestions = ( answer: "", sub_queries: [], context_docs: undefined, + is_complete: false, }; updatedSubQuestions.push(subQuestion); } @@ -314,6 +316,7 @@ export const constructSubQuestions = ( answer: "", sub_queries: [], context_docs: undefined, + is_complete: false, }; updatedSubQuestions.push(subQuestion); } diff --git a/web/src/app/chat/message/AgenticMessage.tsx b/web/src/app/chat/message/AgenticMessage.tsx index 905d21aa6..a2e581499 100644 --- a/web/src/app/chat/message/AgenticMessage.tsx +++ b/web/src/app/chat/message/AgenticMessage.tsx @@ -48,6 +48,7 @@ import rehypeKatex from "rehype-katex"; import "katex/dist/katex.min.css"; import SubQuestionsDisplay from "./SubQuestionsDisplay"; import { StatusRefinement } from "../Refinement"; +import SubQuestionProgress from "./SubQuestionProgress"; export const AgenticMessage = ({ docSidebarToggled, @@ -250,15 +251,10 @@ export const AgenticMessage = ({ ? agenticDocs : docs } - subQuestions={ - (isViewingInitialAnswer - ? subQuestions && subQuestions.length > 0 - ? subQuestions - : secondLevelSubquestions - : secondLevelSubquestions && secondLevelSubquestions.length > 0 - ? secondLevelSubquestions - : subQuestions) || undefined - } + subQuestions={[ + ...(subQuestions || []), + ...(secondLevelSubquestions || []), + ]} openQuestion={openQuestion} > {props.children} @@ -399,8 +395,18 @@ export const AgenticMessage = ({ {subQuestions && subQuestions.length > 0 && ( 8} - overallAnswerGenerating={finalContent.length < 8} + finishedGenerating={ + finalContent.length > 8 && + streamedContent.length == streamedContent.length + } + overallAnswerGenerating={false} + // overallAnswerGenerating={ + // !!( + // secondLevelSubquestions && + // secondLevelSubquestions.length > 0 && + // finalContent.length < 8 + // ) + // } showSecondLevel={!isViewingInitialAnswer} currentlyOpenQuestion={currentlyOpenQuestion} allowStreaming={() => setAllowStreaming(true)} diff --git a/web/src/app/chat/message/MemoizedTextComponents.tsx b/web/src/app/chat/message/MemoizedTextComponents.tsx index 9fbfd4bd2..c4f7da196 100644 --- a/web/src/app/chat/message/MemoizedTextComponents.tsx +++ b/web/src/app/chat/message/MemoizedTextComponents.tsx @@ -27,14 +27,22 @@ export const MemoizedAnchor = memo( children: React.ReactNode; }): JSX.Element => { const value = children?.toString(); - // return <> if (value?.startsWith("[") && value?.endsWith("]")) { const match = value.match(/\[(D|Q)?(\d+)\]/); if (match) { - const index = parseInt(match[2], 10) - 1; - const associatedDoc = docs?.[index]; - if (!associatedDoc) { - return {children}; + const isSubQuestion = match[1] === "Q"; + if (!isSubQuestion) { + const index = parseInt(match[2], 10) - 1; + const associatedDoc = docs?.[index]; + if (!associatedDoc) { + return {children}; + } + } else { + const index = parseInt(match[2], 10) - 1; + const associatedSubQuestion = subQuestions?.[index]; + if (!associatedSubQuestion) { + return {children}; + } } } @@ -51,18 +59,7 @@ export const MemoizedAnchor = memo( : undefined; if (!associatedDoc && !associatedSubQuestion) { - return ( - <> - l{children} - {/* No associated docs or subquestions. -
-

Number of questions: {subQuestions?.length}

-

Number of docs: {docs?.length}

-

{children}

-

index: {index}

-
*/} - - ); + return <>{children}; } let icon: React.ReactNode = null; @@ -85,22 +82,6 @@ export const MemoizedAnchor = memo( : undefined; return ( - //
- //

Debug Info:

- // {children} - //

document length: {docs?.length}

- //

question length: {subQuestions?.length}

- //

document_info: {JSON.stringify(associatedDoc)}

- //

question_info: {JSON.stringify(associatedSubQuestion)}

- //
= ({ const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {}); const { dynamicSubQuestions: dynamicSecondLevelQuestions } = useStreamingMessages(secondLevelQuestions || [], () => {}); - const memoizedSubQuestions = useMemo(() => { - return overallAnswerGenerating ? dynamicSubQuestions : subQuestions; - }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]); - + // const memoizedSubQuestions = useMemo(() => { + // return overallAnswerGenerating ? dynamicSubQuestions : subQuestions; + // }, [overallAnswerGenerating, dynamicSubQuestions, subQuestions]); + const memoizedSubQuestions = dynamicSubQuestions; const memoizedSecondLevelQuestions = useMemo(() => { return overallAnswerGenerating ? dynamicSecondLevelQuestions