mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 12:29:41 +02:00
address doc
This commit is contained in:
@@ -28,11 +28,7 @@ export function useOrderedPhases(externalPhase: StreamingPhase) {
|
|||||||
// Whenever externalPhase changes, add any missing steps into the queue
|
// Whenever externalPhase changes, add any missing steps into the queue
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPhaseQueue((prevQueue) => {
|
setPhaseQueue((prevQueue) => {
|
||||||
const lastDisplayed = displayedPhases[displayedPhases.length - 1];
|
|
||||||
const lastIndex = finalPhaseIndex.current || 0;
|
const lastIndex = finalPhaseIndex.current || 0;
|
||||||
// lastDisplayed
|
|
||||||
// ? getPhaseIndex(lastDisplayed)
|
|
||||||
// : getPhaseIndex(StreamingPhase.WAITING);
|
|
||||||
|
|
||||||
let targetPhase = externalPhase;
|
let targetPhase = externalPhase;
|
||||||
let targetIndex = getPhaseIndex(targetPhase);
|
let targetIndex = getPhaseIndex(targetPhase);
|
||||||
@@ -50,11 +46,6 @@ export function useOrderedPhases(externalPhase: StreamingPhase) {
|
|||||||
targetIndex + 1
|
targetIndex + 1
|
||||||
);
|
);
|
||||||
|
|
||||||
// [];
|
|
||||||
|
|
||||||
// for (let i = lastIndex + 1; i <= targetIndex; i++) {
|
|
||||||
// missingPhases= PHASES_ORDER[i]);
|
|
||||||
// }
|
|
||||||
return [...prevQueue, ...missingPhases];
|
return [...prevQueue, ...missingPhases];
|
||||||
});
|
});
|
||||||
}, [externalPhase, displayedPhases]);
|
}, [externalPhase, displayedPhases]);
|
||||||
@@ -125,6 +116,7 @@ export function RefinemenetBadge({
|
|||||||
|
|
||||||
// Expand/collapse, hover states
|
// Expand/collapse, hover states
|
||||||
const [expanded, setExpanded] = useState(true);
|
const [expanded, setExpanded] = useState(true);
|
||||||
|
const [toolTipHoveredInternal, setToolTipHoveredInternal] = useState(false);
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [shouldShow, setShouldShow] = useState(true);
|
const [shouldShow, setShouldShow] = useState(true);
|
||||||
|
|
||||||
@@ -145,7 +137,7 @@ export function RefinemenetBadge({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
<Tooltip>
|
<Tooltip open={isHovered || toolTipHoveredInternal}>
|
||||||
<div
|
<div
|
||||||
className="relative w-fit max-w-sm"
|
className="relative w-fit max-w-sm"
|
||||||
onMouseEnter={() => setIsHovered(true)}
|
onMouseEnter={() => setIsHovered(true)}
|
||||||
@@ -167,10 +159,16 @@ export function RefinemenetBadge({
|
|||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<TooltipContent
|
<TooltipContent
|
||||||
onMouseEnter={() => setToolTipHovered(true)}
|
onMouseEnter={() => {
|
||||||
|
setToolTipHoveredInternal(true);
|
||||||
|
setToolTipHovered(true);
|
||||||
|
}}
|
||||||
|
onMouseLeave={() => {
|
||||||
|
setToolTipHoveredInternal(false);
|
||||||
|
}}
|
||||||
side="bottom"
|
side="bottom"
|
||||||
align="start"
|
align="start"
|
||||||
className="w-fit p-4 bg-white border-2 border-border shadow-lg rounded-md"
|
className="w-fit -mt-1 p-4 bg-white border-2 border-border shadow-lg rounded-md"
|
||||||
>
|
>
|
||||||
{/* If not done, show the "Refining" box + a chevron */}
|
{/* If not done, show the "Refining" box + a chevron */}
|
||||||
|
|
||||||
@@ -322,7 +320,9 @@ export function StatusRefinement({
|
|||||||
<Badge
|
<Badge
|
||||||
// NOTE: This is a hack to make the badge slightly higher
|
// NOTE: This is a hack to make the badge slightly higher
|
||||||
className="cursor-pointer mt-[1px]"
|
className="cursor-pointer mt-[1px]"
|
||||||
variant="agent"
|
variant={`${
|
||||||
|
isViewingInitialAnswer ? "agent" : "agent-faded"
|
||||||
|
}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const viewInitialAnswer = !isViewingInitialAnswer;
|
const viewInitialAnswer = !isViewingInitialAnswer;
|
||||||
setIsViewingInitialAnswer(viewInitialAnswer);
|
setIsViewingInitialAnswer(viewInitialAnswer);
|
||||||
|
@@ -147,7 +147,7 @@ export const AgenticMessage = ({
|
|||||||
|
|
||||||
processed = processed.replace(/\]\](?!\()/g, "]]()");
|
processed = processed.replace(/\]\](?!\()/g, "]]()");
|
||||||
|
|
||||||
return preprocessLaTeX(processed) + (!isComplete ? " [*]() " : "");
|
return preprocessLaTeX(processed);
|
||||||
};
|
};
|
||||||
|
|
||||||
const finalContent = processContent(content) as string;
|
const finalContent = processContent(content) as string;
|
||||||
@@ -322,10 +322,11 @@ export const AgenticMessage = ({
|
|||||||
remarkPlugins={[remarkGfm, remarkMath]}
|
remarkPlugins={[remarkGfm, remarkMath]}
|
||||||
rehypePlugins={[[rehypePrism, { ignoreMissing: true }], rehypeKatex]}
|
rehypePlugins={[[rehypePrism, { ignoreMissing: true }], rehypeKatex]}
|
||||||
>
|
>
|
||||||
{streamedContent}
|
{streamedContent +
|
||||||
|
(!isComplete && !secondLevelGenerating ? " [*]() " : "")}
|
||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
);
|
);
|
||||||
}, [streamedContent, markdownComponents]);
|
}, [streamedContent, markdownComponents, isComplete]);
|
||||||
|
|
||||||
const includeMessageSwitcher =
|
const includeMessageSwitcher =
|
||||||
currentMessageInd !== undefined &&
|
currentMessageInd !== undefined &&
|
||||||
@@ -335,10 +336,6 @@ export const AgenticMessage = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!allowStreaming) {
|
if (!allowStreaming) {
|
||||||
// if (typeof content === "string") {
|
|
||||||
// setStreamedContent(finalContent);
|
|
||||||
// setLastKnownContentLength(finalContent.length);
|
|
||||||
// }
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ export const MemoizedAnchor = memo(
|
|||||||
if (value?.startsWith("[") && value?.endsWith("]")) {
|
if (value?.startsWith("[") && value?.endsWith("]")) {
|
||||||
const match = value.match(/\[(D|Q)?(\d+)\]/);
|
const match = value.match(/\[(D|Q)?(\d+)\]/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const index = parseInt(match[1], 10) - 1;
|
const index = parseInt(match[2], 10) - 1;
|
||||||
const associatedDoc = docs?.[index];
|
const associatedDoc = docs?.[index];
|
||||||
if (!associatedDoc) {
|
if (!associatedDoc) {
|
||||||
return <a href={children as string}>{children}</a>;
|
return <a href={children as string}>{children}</a>;
|
||||||
@@ -53,7 +53,7 @@ export const MemoizedAnchor = memo(
|
|||||||
if (!associatedDoc && !associatedSubQuestion) {
|
if (!associatedDoc && !associatedSubQuestion) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{children}
|
l{children}
|
||||||
{/* No associated docs or subquestions.
|
{/* No associated docs or subquestions.
|
||||||
<div className="text-sm text-gray-600">
|
<div className="text-sm text-gray-600">
|
||||||
<p>Number of questions: {subQuestions?.length}</p>
|
<p>Number of questions: {subQuestions?.length}</p>
|
||||||
@@ -114,7 +114,7 @@ export const MemoizedAnchor = memo(
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<MemoizedLink updatePresentingDocument={updatePresentingDocument}>
|
<MemoizedLink updatePresentingDocument={updatePresentingDocument}>
|
||||||
{children}
|
{children}l
|
||||||
</MemoizedLink>
|
</MemoizedLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,8 @@ const badgeVariants = cva(
|
|||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
"agent-faded":
|
||||||
|
"border-neutral-200 bg-neutral-100 text-neutral-600 hover:bg-neutral-200",
|
||||||
agent: "border-agent bg-agent text-white hover:bg-agent-hover",
|
agent: "border-agent bg-agent text-white hover:bg-agent-hover",
|
||||||
canceled:
|
canceled:
|
||||||
"border-gray-200 bg-gray-50 text-gray-600 hover:bg-gray-75 dark:bg-gray-900 dark:text-neutral-50 dark:hover:bg-gray-850",
|
"border-gray-200 bg-gray-50 text-gray-600 hover:bg-gray-75 dark:bg-gray-900 dark:text-neutral-50 dark:hover:bg-gray-850",
|
||||||
|
Reference in New Issue
Block a user