From dd494d2daa4a340dceea2ee78b137aa1123f7ecc Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Thu, 23 Jan 2025 11:44:42 -0800 Subject: [PATCH] k --- web/src/app/chat/ChatPage.tsx | 62 +++++++++++++++++++ web/src/app/chat/message/AgenticMessage.tsx | 20 +++--- .../app/chat/message/SubQuestionsDisplay.tsx | 19 ++++-- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 312332404..b462093e1 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -287,6 +287,16 @@ export function ChatPage({ SEARCH_PARAM_NAMES.TEMPERATURE ); + const defaultTemperature = search_param_temperature + ? parseFloat(search_param_temperature) + : selectedAssistant?.tools.some( + (tool) => + tool.in_code_tool_id === SEARCH_TOOL_ID || + tool.in_code_tool_id === INTERNET_SEARCH_TOOL_ID + ) + ? 0 + : 0.7; + const setSelectedAssistantFromId = (assistantId: number) => { // NOTE: also intentionally look through available assistants here, so that // even if the user has hidden an assistant they can still go back to it @@ -2569,6 +2579,10 @@ export function ChatPage({ if (parentMessage?.type == "assistant") { return <>; } + const secondLevelMessage = + messageHistory[i + 1]?.type === "assistant" + ? messageHistory[i + 1] + : undefined; const secondLevelAssistantMessage = messageHistory[i + 1]?.type === "assistant" @@ -2631,6 +2645,21 @@ export function ChatPage({ agenticDocs={ message.agentic_docs || agenticDocs } + toggleDocDisplay={( + agentic: boolean + ) => { + if (agentic) { + setSelectedMessageForDocDisplay( + message.messageId + ); + } else { + setSelectedMessageForDocDisplay( + secondLevelMessage + ? secondLevelMessage.messageId + : null + ); + } + }} docs={ message?.documents && message?.documents.length > 0 @@ -2738,6 +2767,39 @@ export function ChatPage({ message.messageId as number, ]) } + handleSearchQueryEdit={ + i === messageHistory.length - 1 && + currentSessionChatState == "input" + ? (newQuery) => { + if (!previousMessage) { + setPopup({ + type: "error", + message: + "Cannot edit query of first message - please refresh the page and try again.", + }); + return; + } + if ( + previousMessage.messageId === + null + ) { + setPopup({ + type: "error", + message: + "Cannot edit query of a pending message - please wait a few seconds and try again.", + }); + return; + } + onSubmit({ + messageIdToResend: + previousMessage.messageId, + queryOverride: newQuery, + alternativeAssistantOverride: + currentAlternativeAssistant, + }); + } + : undefined + } handleShowRetrieved={( messageNumber ) => { diff --git a/web/src/app/chat/message/AgenticMessage.tsx b/web/src/app/chat/message/AgenticMessage.tsx index 18f03fb21..82005e765 100644 --- a/web/src/app/chat/message/AgenticMessage.tsx +++ b/web/src/app/chat/message/AgenticMessage.tsx @@ -118,6 +118,7 @@ export const AgenticMessage = ({ secondLevelSubquestions, setStreamingAllowed, streamingAllowed, + toggleDocDisplay, }: { secondLevelSubquestions?: SubQuestionDetail[] | null; agenticDocs?: OnyxDocument[] | null; @@ -156,6 +157,7 @@ export const AgenticMessage = ({ setPresentingDocument?: (document: OnyxDocument) => void; setStreamingAllowed?: (allowed: boolean) => void; streamingAllowed?: boolean; + toggleDocDisplay?: (agentic: boolean) => void; }) => { const [streamedContent, setStreamedContent] = useState(content as string); @@ -292,8 +294,8 @@ export const AgenticMessage = ({ ? docs : agenticDocs : agenticDocs && agenticDocs.length > 0 - ? agenticDocs - : docs + ? agenticDocs + : docs } subQuestions={ isViewingInitialAnswer @@ -378,12 +380,12 @@ export const AgenticMessage = ({ ? StreamingPhase.COMPLETE : StreamingPhase.ANSWER : secondLevelSubquestions[0].context_docs - ? StreamingPhase.CONTEXT_DOCS - : secondLevelSubquestions[0].sub_queries - ? StreamingPhase.SUB_QUERIES - : secondLevelSubquestions[0].question - ? StreamingPhase.WAITING - : StreamingPhase.WAITING + ? StreamingPhase.CONTEXT_DOCS + : secondLevelSubquestions[0].sub_queries + ? StreamingPhase.SUB_QUERIES + : secondLevelSubquestions[0].question + ? StreamingPhase.WAITING + : StreamingPhase.WAITING : StreamingPhase.WAITING; const message = useOrderedPhases(currentState); @@ -542,6 +544,8 @@ export const AgenticMessage = ({ const viewInitialAnswer = !isViewingInitialAnswer; setIsViewingInitialAnswer(viewInitialAnswer); + toggleDocDisplay && + toggleDocDisplay(isViewingInitialAnswer); if (viewInitialAnswer) { setIsViewingInitialAnswer(true); } diff --git a/web/src/app/chat/message/SubQuestionsDisplay.tsx b/web/src/app/chat/message/SubQuestionsDisplay.tsx index 4cc7e488a..28a28aad0 100644 --- a/web/src/app/chat/message/SubQuestionsDisplay.tsx +++ b/web/src/app/chat/message/SubQuestionsDisplay.tsx @@ -308,8 +308,8 @@ const SubQuestionDisplay: React.FC<{ status === ToggleState.Todo ? "!border-4 border border-background-900 bg-background" : false - ? "bg-background border-3 border border-background-900 rotating-border" - : "bg-background-900 flex items-center justify-center" + ? "bg-background border-3 border border-background-900 rotating-border" + : "bg-background-900 flex items-center justify-center" } `} > @@ -637,7 +637,15 @@ const SubQuestionsDisplay: React.FC = ({ !finishedGenerating ? ToggleState.Todo : ToggleState.Done } documents={documents} - isLast={false} + isLast={ + !showSummarizing && + memoizedSubQuestions.length > index + 1 && + !( + showSecondLevel && + memoizedSecondLevelQuestions && + memoizedSecondLevelQuestions?.length > 0 + ) + } isFirst={index === 0} setPresentingDocument={setPresentingDocument} unToggle={ @@ -679,7 +687,10 @@ const SubQuestionsDisplay: React.FC = ({ key={index} subQuestion={subQuestion} documents={documents} - isLast={false} + isLast={ + !showSummarizing && + memoizedSecondLevelQuestions.length > index + 1 + } isFirst={false} setPresentingDocument={setPresentingDocument} unToggle={