mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-20 13:05:49 +02:00
k
This commit is contained in:
@@ -372,35 +372,33 @@ export const AgenticMessage = ({
|
|||||||
onMessageSelection &&
|
onMessageSelection &&
|
||||||
otherMessagesCanSwitchTo &&
|
otherMessagesCanSwitchTo &&
|
||||||
otherMessagesCanSwitchTo.length > 1;
|
otherMessagesCanSwitchTo.length > 1;
|
||||||
const currentIndexRef = useRef(0);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!allowStreaming) {
|
if (!allowStreaming) {
|
||||||
|
// if (typeof content === "string") {
|
||||||
|
// setStreamedContent(finalContent);
|
||||||
|
// setLastKnownContentLength(finalContent.length);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof finalContent !== "string") return;
|
if (typeof finalContent !== "string") return;
|
||||||
|
|
||||||
|
let currentIndex = streamedContent.length;
|
||||||
let intervalId: NodeJS.Timeout | null = null;
|
let intervalId: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
|
// if (finalContent.length > currentIndex) {
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
setStreamedContent((prev) => {
|
setStreamedContent((prev) => {
|
||||||
if (streamedContent.length == finalContent.length) {
|
if (prev.length < finalContent.length) {
|
||||||
return finalContent;
|
const nextLength = Math.min(prev.length + 5, finalContent.length);
|
||||||
}
|
|
||||||
if (currentIndexRef.current < finalContent.length) {
|
|
||||||
const nextLength = Math.min(
|
|
||||||
currentIndexRef.current + 5,
|
|
||||||
finalContent.length
|
|
||||||
);
|
|
||||||
currentIndexRef.current = nextLength;
|
|
||||||
return finalContent.slice(0, nextLength);
|
return finalContent.slice(0, nextLength);
|
||||||
} else {
|
} else {
|
||||||
if (intervalId) clearInterval(intervalId);
|
if (intervalId) clearInterval(intervalId);
|
||||||
return finalContent;
|
return finalContent;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 5);
|
}, 10);
|
||||||
// } else {
|
// } else {
|
||||||
// setStreamedContent(finalContent);
|
// setStreamedContent(finalContent);
|
||||||
// }
|
// }
|
||||||
@@ -447,7 +445,7 @@ export const AgenticMessage = ({
|
|||||||
subQuestions={subQuestions}
|
subQuestions={subQuestions}
|
||||||
secondLevelQuestions={secondLevelSubquestions || []}
|
secondLevelQuestions={secondLevelSubquestions || []}
|
||||||
documents={
|
documents={
|
||||||
isViewingInitialAnswer || (!agenticDocs && docs)
|
isViewingInitialAnswer
|
||||||
? (docs && docs.length > 0 ? docs : agenticDocs)!
|
? (docs && docs.length > 0 ? docs : agenticDocs)!
|
||||||
: (agenticDocs && agenticDocs.length > 0
|
: (agenticDocs && agenticDocs.length > 0
|
||||||
? agenticDocs
|
? agenticDocs
|
||||||
@@ -474,81 +472,47 @@ export const AgenticMessage = ({
|
|||||||
Answer
|
Answer
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* {
|
{isImprovement == null &&
|
||||||
<div className="bg-gray-100 p-4 rounded-md shadow-sm">
|
subQuestions &&
|
||||||
<p>
|
subQuestions.length > 0 ? (
|
||||||
isGenerating: {isGenerating ? "true" : "false"}
|
<RefinemenetBadge
|
||||||
</p>
|
finished={!secondLevelGenerating}
|
||||||
<p>
|
overallAnswer={secondLevelAssistantMessage || ""}
|
||||||
secondLevelGenerating:{" "}
|
secondLevelSubquestions={secondLevelSubquestions}
|
||||||
{secondLevelGenerating ? "true" : "false"}
|
toggleInitialAnswerVieinwg={() => {
|
||||||
</p>
|
setIsViewingInitialAnswer(
|
||||||
<p>
|
!isViewingInitialAnswer
|
||||||
isImprovement:{" "}
|
);
|
||||||
{isImprovement === null ? "null" : "not null"}
|
}}
|
||||||
</p>
|
isViewingInitialAnswer={isViewingInitialAnswer}
|
||||||
<p>
|
/>
|
||||||
subQuestions:{" "}
|
) : secondLevelAssistantMessage ? (
|
||||||
{subQuestions ? "exists" : "does not exist"}
|
isImprovement ? (
|
||||||
</p>
|
<Badge
|
||||||
<p>
|
// NOTE: This is a hack to make the badge slightly higher
|
||||||
subQuestions length:{" "}
|
className="cursor-pointer mt-[1px]"
|
||||||
{subQuestions ? subQuestions.length : "N/A"}
|
variant="agent"
|
||||||
</p>
|
onClick={() => {
|
||||||
</div>
|
const viewInitialAnswer =
|
||||||
} */}
|
!isViewingInitialAnswer;
|
||||||
{/* {isImprovement ? "true" : "false"} */}
|
setIsViewingInitialAnswer(viewInitialAnswer);
|
||||||
{
|
toggleDocDisplay &&
|
||||||
// !isGenerating &&
|
toggleDocDisplay(isViewingInitialAnswer);
|
||||||
secondLevelGenerating &&
|
if (viewInitialAnswer) {
|
||||||
isImprovement == null &&
|
setIsViewingInitialAnswer(true);
|
||||||
subQuestions &&
|
}
|
||||||
subQuestions.length > 0 ? (
|
|
||||||
<RefinemenetBadge
|
|
||||||
finished={!secondLevelGenerating}
|
|
||||||
overallAnswer={
|
|
||||||
secondLevelAssistantMessage || ""
|
|
||||||
}
|
|
||||||
secondLevelSubquestions={
|
|
||||||
secondLevelSubquestions
|
|
||||||
}
|
|
||||||
toggleInitialAnswerVieinwg={() => {
|
|
||||||
setIsViewingInitialAnswer(
|
|
||||||
!isViewingInitialAnswer
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
isViewingInitialAnswer={isViewingInitialAnswer}
|
>
|
||||||
/>
|
{isViewingInitialAnswer
|
||||||
) : secondLevelAssistantMessage ? (
|
? "See Refined Answer"
|
||||||
isImprovement ? (
|
: "See Original Answer"}
|
||||||
<Badge
|
</Badge>
|
||||||
// NOTE: This is a hack to make the badge slightly higher
|
|
||||||
className="cursor-pointer mt-[1px]"
|
|
||||||
variant="agent"
|
|
||||||
onClick={() => {
|
|
||||||
const viewInitialAnswer =
|
|
||||||
!isViewingInitialAnswer;
|
|
||||||
setIsViewingInitialAnswer(
|
|
||||||
viewInitialAnswer
|
|
||||||
);
|
|
||||||
toggleDocDisplay &&
|
|
||||||
toggleDocDisplay(isViewingInitialAnswer);
|
|
||||||
if (viewInitialAnswer) {
|
|
||||||
setIsViewingInitialAnswer(true);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{isViewingInitialAnswer
|
|
||||||
? "See Refined Answer"
|
|
||||||
: "See Original Answer"}
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
<NoNewAnswerMessage />
|
|
||||||
)
|
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<NoNewAnswerMessage />
|
||||||
)
|
)
|
||||||
}
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
|
Reference in New Issue
Block a user