mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-29 13:25:50 +02:00
quick update
This commit is contained in:
@@ -477,7 +477,6 @@ export function ChatPage({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const session = await response.json();
|
const session = await response.json();
|
||||||
console.log(session);
|
|
||||||
const chatSession = session as BackendChatSession;
|
const chatSession = session as BackendChatSession;
|
||||||
setSelectedAssistantFromId(chatSession.persona_id);
|
setSelectedAssistantFromId(chatSession.persona_id);
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ export const AgenticMessage = ({
|
|||||||
const [lastKnownContentLength, setLastKnownContentLength] = useState(0);
|
const [lastKnownContentLength, setLastKnownContentLength] = useState(0);
|
||||||
|
|
||||||
const [allowStreaming, setAllowStreaming] = useState(isComplete);
|
const [allowStreaming, setAllowStreaming] = useState(isComplete);
|
||||||
|
const [allowDocuments, setAllowDocuments] = useState(isComplete);
|
||||||
|
|
||||||
const alternativeContent = secondLevelAssistantMessage || "";
|
const alternativeContent = secondLevelAssistantMessage || "";
|
||||||
|
|
||||||
@@ -231,7 +232,6 @@ export const AgenticMessage = ({
|
|||||||
level_question_num: question.level_question_num,
|
level_question_num: question.level_question_num,
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log("closing question");
|
|
||||||
setCurrentlyOpenQuestion(null);
|
setCurrentlyOpenQuestion(null);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
@@ -394,6 +394,7 @@ export const AgenticMessage = ({
|
|||||||
<div className="w-full desktop:ml-4">
|
<div className="w-full desktop:ml-4">
|
||||||
{subQuestions && subQuestions.length > 0 && (
|
{subQuestions && subQuestions.length > 0 && (
|
||||||
<SubQuestionsDisplay
|
<SubQuestionsDisplay
|
||||||
|
allowDocuments={() => setAllowDocuments(true)}
|
||||||
docSidebarToggled={docSidebarToggled || false}
|
docSidebarToggled={docSidebarToggled || false}
|
||||||
finishedGenerating={
|
finishedGenerating={
|
||||||
finalContent.length > 10 &&
|
finalContent.length > 10 &&
|
||||||
@@ -412,7 +413,13 @@ export const AgenticMessage = ({
|
|||||||
allowStreaming={() => setAllowStreaming(true)}
|
allowStreaming={() => setAllowStreaming(true)}
|
||||||
subQuestions={subQuestions}
|
subQuestions={subQuestions}
|
||||||
secondLevelQuestions={secondLevelSubquestions || []}
|
secondLevelQuestions={secondLevelSubquestions || []}
|
||||||
documents={isViewingInitialAnswer ? docs! : agenticDocs!}
|
documents={
|
||||||
|
!allowDocuments
|
||||||
|
? []
|
||||||
|
: isViewingInitialAnswer
|
||||||
|
? docs!
|
||||||
|
: agenticDocs!
|
||||||
|
}
|
||||||
toggleDocumentSelection={() => {
|
toggleDocumentSelection={() => {
|
||||||
toggleDocumentSelection!(!isViewingInitialAnswer);
|
toggleDocumentSelection!(!isViewingInitialAnswer);
|
||||||
}}
|
}}
|
||||||
|
@@ -61,25 +61,6 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const displayedDocuments = documents.slice(0, 5);
|
const displayedDocuments = documents.slice(0, 5);
|
||||||
const hasMoreDocuments = documents.length > 3;
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -98,7 +79,6 @@ export const SourcesDisplay: React.FC<SourcesDisplayProps> = ({
|
|||||||
{displayedDocuments.map((doc, index) => (
|
{displayedDocuments.map((doc, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => openDocument(doc, setPresentingDocument)}
|
|
||||||
className={`transition-opacity duration-300 ${
|
className={`transition-opacity duration-300 ${
|
||||||
animateEntrance ? "opacity-100" : "opacity-100"
|
animateEntrance ? "opacity-100" : "opacity-100"
|
||||||
}`}
|
}`}
|
||||||
|
@@ -77,6 +77,7 @@ interface SubQuestionsDisplayProps {
|
|||||||
secondLevelQuestions?: SubQuestionDetail[];
|
secondLevelQuestions?: SubQuestionDetail[];
|
||||||
showSecondLevel?: boolean;
|
showSecondLevel?: boolean;
|
||||||
overallAnswerGenerating?: boolean;
|
overallAnswerGenerating?: boolean;
|
||||||
|
allowDocuments: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ToggleState {
|
export enum ToggleState {
|
||||||
@@ -97,6 +98,7 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
temporaryDisplay?: TemporaryDisplay;
|
temporaryDisplay?: TemporaryDisplay;
|
||||||
completed?: boolean;
|
completed?: boolean;
|
||||||
initialStatus: ToggleState;
|
initialStatus: ToggleState;
|
||||||
|
forcedStatus?: ToggleState;
|
||||||
}> = ({
|
}> = ({
|
||||||
currentlyOpen,
|
currentlyOpen,
|
||||||
currentlyClosed,
|
currentlyClosed,
|
||||||
@@ -109,6 +111,7 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
setPresentingDocument,
|
setPresentingDocument,
|
||||||
completed,
|
completed,
|
||||||
initialStatus,
|
initialStatus,
|
||||||
|
forcedStatus,
|
||||||
}) => {
|
}) => {
|
||||||
const [analysisToggled, setAnalysisToggled] = useState(false);
|
const [analysisToggled, setAnalysisToggled] = useState(false);
|
||||||
const [status, setStatus] = useState(initialStatus);
|
const [status, setStatus] = useState(initialStatus);
|
||||||
@@ -147,12 +150,6 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
// Add () after ]] if not present
|
// Add () after ]] if not present
|
||||||
content = content.replace(/\]\](?!\()/g, "]]()");
|
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 (
|
return (
|
||||||
preprocessLaTeX(content) + (!subQuestion?.is_complete ? " [*]() " : "")
|
preprocessLaTeX(content) + (!subQuestion?.is_complete ? " [*]() " : "")
|
||||||
);
|
);
|
||||||
@@ -222,16 +219,12 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (subQuestion?.is_complete) {
|
if (subQuestion?.is_complete) {
|
||||||
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
||||||
} else {
|
|
||||||
// setStatus(ToggleState.Todo);
|
|
||||||
}
|
}
|
||||||
}, [subQuestion?.is_complete]);
|
}, [subQuestion?.is_complete]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (completed) {
|
if (completed) {
|
||||||
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
||||||
// setToggled(true);
|
|
||||||
console.log("COMPLETED SO IS TOGGLED");
|
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
}
|
}
|
||||||
}, [completed]);
|
}, [completed]);
|
||||||
@@ -240,27 +233,24 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
if (unToggle) {
|
if (unToggle) {
|
||||||
if (subQuestion?.answer) {
|
if (subQuestion?.answer) {
|
||||||
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
setTimeout(() => setStatus(ToggleState.Done), PHASE_MIN_MS);
|
||||||
} else {
|
|
||||||
// setStatus(ToggleState.Todo);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setStatus(ToggleState.InProgress);
|
setStatus(ToggleState.InProgress);
|
||||||
|
|
||||||
// if (subQuestion?.is_complete) {
|
|
||||||
// setStatus(ToggleState.Done);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
// if (!unToggle) {
|
|
||||||
// console.log("NOT TOGGLED SO UPDATED");
|
|
||||||
// }
|
|
||||||
setToggled(!unToggle);
|
setToggled(!unToggle);
|
||||||
},
|
},
|
||||||
unToggle ? PHASE_MIN_MS * 0.75 : 0
|
unToggle ? PHASE_MIN_MS * 0.75 : 0
|
||||||
);
|
);
|
||||||
}, [unToggle]);
|
}, [unToggle]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (forcedStatus === ToggleState.Done) {
|
||||||
|
setToggled(false);
|
||||||
|
}
|
||||||
|
}, [forcedStatus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let timer: NodeJS.Timeout;
|
let timer: NodeJS.Timeout;
|
||||||
if (toggled && !temporaryDisplay) {
|
if (toggled && !temporaryDisplay) {
|
||||||
@@ -274,7 +264,6 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentlyOpen) {
|
if (currentlyOpen) {
|
||||||
console.log("CURRENLTY OPENED SO TOGGLED TO TRUE");
|
|
||||||
setToggled(true);
|
setToggled(true);
|
||||||
setAnalysisToggled(true);
|
setAnalysisToggled(true);
|
||||||
if (questionRef.current) {
|
if (questionRef.current) {
|
||||||
@@ -334,10 +323,10 @@ const SubQuestionDisplay: React.FC<{
|
|||||||
<div
|
<div
|
||||||
style={{ scrollMarginTop: "20px" }}
|
style={{ scrollMarginTop: "20px" }}
|
||||||
ref={questionRef}
|
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">
|
<div className="absolute left-0 w-3 h-3 rounded-full mt-[12px] z-10">
|
||||||
<StatusIndicator status={status} />
|
<StatusIndicator status={forcedStatus || status} />
|
||||||
</div>
|
</div>
|
||||||
<div className="ml-8 w-full">
|
<div className="ml-8 w-full">
|
||||||
<div
|
<div
|
||||||
@@ -476,6 +465,7 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
docSidebarToggled,
|
docSidebarToggled,
|
||||||
showSecondLevel,
|
showSecondLevel,
|
||||||
overallAnswerGenerating,
|
overallAnswerGenerating,
|
||||||
|
allowDocuments,
|
||||||
}) => {
|
}) => {
|
||||||
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
const { dynamicSubQuestions } = useStreamingMessages(subQuestions, () => {});
|
||||||
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
const { dynamicSubQuestions: dynamicSecondLevelQuestions } =
|
||||||
@@ -518,12 +508,9 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (documents && documents.length > 0) {
|
if (documents && documents.length > 0) {
|
||||||
setTimeout(
|
setTimeout(() => {
|
||||||
() => {
|
setShownDocuments(documents);
|
||||||
setShownDocuments(documents);
|
}, 800);
|
||||||
},
|
|
||||||
overallAnswerGenerating ? 1500 : 0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, [documents]);
|
}, [documents]);
|
||||||
|
|
||||||
@@ -534,7 +521,12 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
(subQuestion) => subQuestion?.answer.length > 2
|
(subQuestion) => subQuestion?.answer.length > 2
|
||||||
).length == memoizedSubQuestions.length
|
).length == memoizedSubQuestions.length
|
||||||
) {
|
) {
|
||||||
setTimeout(() => setCanShowSummarizing(true), PHASE_MIN_MS);
|
setTimeout(() => {
|
||||||
|
setCanShowSummarizing(true);
|
||||||
|
}, PHASE_MIN_MS);
|
||||||
|
setTimeout(() => {
|
||||||
|
allowDocuments();
|
||||||
|
}, PHASE_MIN_MS * 2);
|
||||||
}
|
}
|
||||||
}, [memoizedSubQuestions]);
|
}, [memoizedSubQuestions]);
|
||||||
|
|
||||||
@@ -561,6 +553,9 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
if (index <= fullText.length) {
|
if (index <= fullText.length) {
|
||||||
setStreamedText(fullText.slice(0, index));
|
setStreamedText(fullText.slice(0, index));
|
||||||
index++;
|
index++;
|
||||||
|
if (index === fullText.length) {
|
||||||
|
allowDocuments();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clearInterval(streamInterval);
|
clearInterval(streamInterval);
|
||||||
}
|
}
|
||||||
@@ -727,6 +722,11 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
|
|||||||
currentlyClosed={
|
currentlyClosed={
|
||||||
shownDocuments != null && shownDocuments.length > 0
|
shownDocuments != null && shownDocuments.length > 0
|
||||||
}
|
}
|
||||||
|
forcedStatus={
|
||||||
|
shownDocuments && shownDocuments.length > 0
|
||||||
|
? ToggleState.Done
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
subQuestion={null}
|
subQuestion={null}
|
||||||
documents={shownDocuments}
|
documents={shownDocuments}
|
||||||
isLast={true}
|
isLast={true}
|
||||||
|
@@ -37,22 +37,7 @@ export function Citation({
|
|||||||
: index;
|
: index;
|
||||||
|
|
||||||
if (!document_info && !question_info) {
|
if (!document_info && !question_info) {
|
||||||
return (
|
return children;
|
||||||
<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 (
|
return (
|
||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
|
Reference in New Issue
Block a user