address doc

This commit is contained in:
pablodanswer 2025-01-30 16:50:19 -08:00 committed by Evan Lohn
parent c43c2320e7
commit 23bf50b90a
4 changed files with 22 additions and 23 deletions

View File

@ -28,11 +28,7 @@ export function useOrderedPhases(externalPhase: StreamingPhase) {
// Whenever externalPhase changes, add any missing steps into the queue
useEffect(() => {
setPhaseQueue((prevQueue) => {
const lastDisplayed = displayedPhases[displayedPhases.length - 1];
const lastIndex = finalPhaseIndex.current || 0;
// lastDisplayed
// ? getPhaseIndex(lastDisplayed)
// : getPhaseIndex(StreamingPhase.WAITING);
let targetPhase = externalPhase;
let targetIndex = getPhaseIndex(targetPhase);
@ -50,11 +46,6 @@ export function useOrderedPhases(externalPhase: StreamingPhase) {
targetIndex + 1
);
// [];
// for (let i = lastIndex + 1; i <= targetIndex; i++) {
// missingPhases= PHASES_ORDER[i]);
// }
return [...prevQueue, ...missingPhases];
});
}, [externalPhase, displayedPhases]);
@ -125,6 +116,7 @@ export function RefinemenetBadge({
// Expand/collapse, hover states
const [expanded, setExpanded] = useState(true);
const [toolTipHoveredInternal, setToolTipHoveredInternal] = useState(false);
const [isHovered, setIsHovered] = useState(false);
const [shouldShow, setShouldShow] = useState(true);
@ -145,7 +137,7 @@ export function RefinemenetBadge({
return (
<TooltipProvider delayDuration={0}>
<Tooltip>
<Tooltip open={isHovered || toolTipHoveredInternal}>
<div
className="relative w-fit max-w-sm"
onMouseEnter={() => setIsHovered(true)}
@ -167,10 +159,16 @@ export function RefinemenetBadge({
</TooltipTrigger>
{expanded && (
<TooltipContent
onMouseEnter={() => setToolTipHovered(true)}
onMouseEnter={() => {
setToolTipHoveredInternal(true);
setToolTipHovered(true);
}}
onMouseLeave={() => {
setToolTipHoveredInternal(false);
}}
side="bottom"
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 */}
@ -322,7 +320,9 @@ export function StatusRefinement({
<Badge
// NOTE: This is a hack to make the badge slightly higher
className="cursor-pointer mt-[1px]"
variant="agent"
variant={`${
isViewingInitialAnswer ? "agent" : "agent-faded"
}`}
onClick={() => {
const viewInitialAnswer = !isViewingInitialAnswer;
setIsViewingInitialAnswer(viewInitialAnswer);

View File

@ -147,7 +147,7 @@ export const AgenticMessage = ({
processed = processed.replace(/\]\](?!\()/g, "]]()");
return preprocessLaTeX(processed) + (!isComplete ? " [*]() " : "");
return preprocessLaTeX(processed);
};
const finalContent = processContent(content) as string;
@ -322,10 +322,11 @@ export const AgenticMessage = ({
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[[rehypePrism, { ignoreMissing: true }], rehypeKatex]}
>
{streamedContent}
{streamedContent +
(!isComplete && !secondLevelGenerating ? " [*]() " : "")}
</ReactMarkdown>
);
}, [streamedContent, markdownComponents]);
}, [streamedContent, markdownComponents, isComplete]);
const includeMessageSwitcher =
currentMessageInd !== undefined &&
@ -335,10 +336,6 @@ export const AgenticMessage = ({
useEffect(() => {
if (!allowStreaming) {
// if (typeof content === "string") {
// setStreamedContent(finalContent);
// setLastKnownContentLength(finalContent.length);
// }
return;
}

View File

@ -31,7 +31,7 @@ export const MemoizedAnchor = memo(
if (value?.startsWith("[") && value?.endsWith("]")) {
const match = value.match(/\[(D|Q)?(\d+)\]/);
if (match) {
const index = parseInt(match[1], 10) - 1;
const index = parseInt(match[2], 10) - 1;
const associatedDoc = docs?.[index];
if (!associatedDoc) {
return <a href={children as string}>{children}</a>;
@ -53,7 +53,7 @@ export const MemoizedAnchor = memo(
if (!associatedDoc && !associatedSubQuestion) {
return (
<>
{children}
l{children}
{/* No associated docs or subquestions.
<div className="text-sm text-gray-600">
<p>Number of questions: {subQuestions?.length}</p>
@ -114,7 +114,7 @@ export const MemoizedAnchor = memo(
}
return (
<MemoizedLink updatePresentingDocument={updatePresentingDocument}>
{children}
{children}l
</MemoizedLink>
);
}

View File

@ -8,6 +8,8 @@ const badgeVariants = cva(
{
variants: {
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",
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",