quick update

This commit is contained in:
pablodanswer 2025-02-02 18:34:31 -08:00 committed by Evan Lohn
parent 59c65a4192
commit 87a53d6d80
5 changed files with 39 additions and 68 deletions

View File

@ -477,7 +477,6 @@ export function ChatPage({
);
const session = await response.json();
console.log(session);
const chatSession = session as BackendChatSession;
setSelectedAssistantFromId(chatSession.persona_id);

View File

@ -117,6 +117,7 @@ export const AgenticMessage = ({
const [lastKnownContentLength, setLastKnownContentLength] = useState(0);
const [allowStreaming, setAllowStreaming] = useState(isComplete);
const [allowDocuments, setAllowDocuments] = useState(isComplete);
const alternativeContent = secondLevelAssistantMessage || "";
@ -231,7 +232,6 @@ export const AgenticMessage = ({
level_question_num: question.level_question_num,
});
setTimeout(() => {
console.log("closing question");
setCurrentlyOpenQuestion(null);
}, 1000);
},
@ -394,6 +394,7 @@ export const AgenticMessage = ({
<div className="w-full desktop:ml-4">
{subQuestions && subQuestions.length > 0 && (
<SubQuestionsDisplay
allowDocuments={() => setAllowDocuments(true)}
docSidebarToggled={docSidebarToggled || false}
finishedGenerating={
finalContent.length > 10 &&
@ -412,7 +413,13 @@ export const AgenticMessage = ({
allowStreaming={() => setAllowStreaming(true)}
subQuestions={subQuestions}
secondLevelQuestions={secondLevelSubquestions || []}
documents={isViewingInitialAnswer ? docs! : agenticDocs!}
documents={
!allowDocuments
? []
: isViewingInitialAnswer
? docs!
: agenticDocs!
}
toggleDocumentSelection={() => {
toggleDocumentSelection!(!isViewingInitialAnswer);
}}

View File

@ -61,25 +61,6 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
}) => {
const displayedDocuments = documents.slice(0, 5);
const hasMoreDocuments = documents.length > 3;
// const [visibleCards, setVisibleCards] = useState<number>(0);
// useEffect(() => {
// if (animateEntrance) {
// const timer = setInterval(() => {
// setVisibleCards((prev) => {
// if (prev < displayedDocuments.length) {
// return prev + 1;
// }
// clearInterval(timer);
// return prev;
// });
// }, 140);
// return () => clearInterval(timer);
// } else {
// setVisibleCards(displayedDocuments.length);
// }
// }, [animateEntrance, displayedDocuments.length]);
return (
<div
@ -98,7 +79,6 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
{displayedDocuments.map((doc, index) => (
<div
key={index}
onClick={() => openDocument(doc, setPresentingDocument)}
className={`transition-opacity duration-300 ${
animateEntrance ? "opacity-100" : "opacity-100"
}`}

View File

@ -77,6 +77,7 @@ interface SubQuestionsDisplayProps {
secondLevelQuestions?: SubQuestionDetail[];
showSecondLevel?: boolean;
overallAnswerGenerating?: boolean;
allowDocuments: () => void;
}
export enum ToggleState {
@ -97,6 +98,7 @@ const SubQuestionDisplay: React.FC<{
temporaryDisplay?: TemporaryDisplay;
completed?: boolean;
initialStatus: ToggleState;
forcedStatus?: ToggleState;
}> = ({
currentlyOpen,
currentlyClosed,
@ -109,6 +111,7 @@ const SubQuestionDisplay: React.FC<{
setPresentingDocument,
completed,
initialStatus,
forcedStatus,
}) => {
const [analysisToggled, setAnalysisToggled] = useState(false);
const [status, setStatus] = useState(initialStatus);
@ -147,12 +150,6 @@ const SubQuestionDisplay: React.FC<{
// Add () after ]] if not present
content = content.replace(/\]\](?!\()/g, "]]()");
// // Turn [Qn] into citation in content
// content = content.replace(/\[Q(\d+)\]/g, (match, p1) => {
// const questionNumber = parseInt(p1, 10);
// return `[[Q${questionNumber}]]()`;
// });
return (
preprocessLaTeX(content) + (!subQuestion?.is_complete ? " [*]() " : "")
);
@ -222,16 +219,12 @@ const SubQuestionDisplay: React.FC<{
useEffect(() => {
if (subQuestion?.is_complete) {
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
} else {
// setStatus(ToggleState.Todo);
}
}, [subQuestion?.is_complete]);
useEffect(() => {
if (completed) {
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
// setToggled(true);
console.log("COMPLETED SO IS TOGGLED");
setIsVisible(true);
}
}, [completed]);
@ -240,27 +233,24 @@ const SubQuestionDisplay: React.FC<{
if (unToggle) {
if (subQuestion?.answer) {
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
} else {
// setStatus(ToggleState.Todo);
}
} else {
setStatus(ToggleState.InProgress);
// if (subQuestion?.is_complete) {
// setStatus(ToggleState.Done);
// }
}
setTimeout(
() => {
// if (!unToggle) {
// console.log("NOT TOGGLED SO UPDATED");
// }
setToggled(!unToggle);
},
unToggle ? PHASE_MIN_MS * 0.75 : 0
);
}, [unToggle]);
useEffect(() => {
if (forcedStatus === ToggleState.Done) {
setToggled(false);
}
}, [forcedStatus]);
useEffect(() => {
let timer: NodeJS.Timeout;
if (toggled && !temporaryDisplay) {
@ -274,7 +264,6 @@ const SubQuestionDisplay: React.FC<{
useEffect(() => {
if (currentlyOpen) {
console.log("CURRENLTY OPENED SO TOGGLED TO TRUE");
setToggled(true);
setAnalysisToggled(true);
if (questionRef.current) {
@ -334,10 +323,10 @@ const SubQuestionDisplay: React.FC<{
<div
style={{ scrollMarginTop: "20px" }}
ref={questionRef}
className={`flex items-start ${!isLast ? "pb-2" : ""}`}
className={`flex items-start ${!isLast ? "pb-2" : ""}`}
>
<div className="absolute left-0 w-3 h-3 rounded-full mt-[12px] z-10">
<StatusIndicator status={status} />
<StatusIndicator status={forcedStatus || status} />
</div>
<div className="ml-8 w-full">
<div
@ -476,6 +465,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
docSidebarToggled,
showSecondLevel,
overallAnswerGenerating,
allowDocuments,
}) => {
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
@ -518,12 +508,9 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
useEffect(() => {
if (documents && documents.length > 0) {
setTimeout(
() => {
setShownDocuments(documents);
},
overallAnswerGenerating ? 1500 : 0
);
setTimeout(() => {
setShownDocuments(documents);
}, 800);
}
}, [documents]);
@ -534,7 +521,12 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
(subQuestion) => subQuestion?.answer.length > 2
).length == memoizedSubQuestions.length
) {
setTimeout(() => setCanShowSummarizing(true), PHASE_MIN_MS);
setTimeout(() => {
setCanShowSummarizing(true);
}, PHASE_MIN_MS);
setTimeout(() => {
allowDocuments();
}, PHASE_MIN_MS * 2);
}
}, [memoizedSubQuestions]);
@ -561,6 +553,9 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
if (index <= fullText.length) {
setStreamedText(fullText.slice(0, index));
index++;
if (index === fullText.length) {
allowDocuments();
}
} else {
clearInterval(streamInterval);
}
@ -727,6 +722,11 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
currentlyClosed={
shownDocuments != null && shownDocuments.length > 0
}
forcedStatus={
shownDocuments && shownDocuments.length > 0
? ToggleState.Done
: undefined
}
subQuestion={null}
documents={shownDocuments}
isLast={true}

View File

@ -37,22 +37,7 @@ export function Citation({
: index;
if (!document_info && !question_info) {
return (
<div
className="debug-info"
style={{
backgroundColor: "#f0f0f0",
padding: "10px",
border: "1px solid #ccc",
margin: "5px 0",
}}
>
<h4>Debug Info:</h4>
<p>document_info: {JSON.stringify(document_info)}</p>
<p>question_info: {JSON.stringify(question_info)}</p>
<p>No document or question info available.</p>
</div>
);
return children;
}
return (
<TooltipProvider delayDuration={0}>