Merge branch 'main' into docs-perf-test

This commit is contained in:
Mendon Kissling 2025-10-28 09:29:57 -04:00
commit ea7c7954e2
24 changed files with 900 additions and 815 deletions

View file

@ -594,8 +594,8 @@ export function Navigation({
No documents yet No documents yet
</div> </div>
) : ( ) : (
newConversationFiles?.map((file) => ( newConversationFiles?.map((file, index) => (
<div key={`${file}`} className="flex-1 min-w-0 px-3"> <div key={`${file}-${index}`} className="flex-1 min-w-0 px-3">
<div className="text-mmd font-medium text-foreground truncate"> <div className="text-mmd font-medium text-foreground truncate">
{file} {file}
</div> </div>

View file

@ -1,7 +1,7 @@
"use client"; "use client";
import * as AccordionPrimitive from "@radix-ui/react-accordion"; import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react"; import { ChevronRight } from "lucide-react";
import * as React from "react"; import * as React from "react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@ -28,12 +28,12 @@ const AccordionTrigger = React.forwardRef<
<AccordionPrimitive.Trigger <AccordionPrimitive.Trigger
ref={ref} ref={ref}
className={cn( className={cn(
"flex flex-1 items-center p-4 py-2.5 gap-2 font-medium !text-mmd text-muted-foreground transition-all [&[data-state=open]>svg]:rotate-180", "flex flex-1 items-center p-4 py-2.5 gap-2 font-medium !text-mmd text-muted-foreground transition-all [&[data-state=open]>svg]:rotate-90",
className, className,
)} )}
{...props} {...props}
> >
<ChevronDown className="h-3.5 w-3.5 shrink-0 transition-transform duration-200" /> <ChevronRight className="h-3.5 w-3.5 shrink-0 transition-transform duration-200" />
{children} {children}
</AccordionPrimitive.Trigger> </AccordionPrimitive.Trigger>
</AccordionPrimitive.Header> </AccordionPrimitive.Header>

View file

@ -6,7 +6,7 @@ import { cn } from "@/lib/utils";
import { Message } from "./message"; import { Message } from "./message";
interface UserMessageProps { interface UserMessageProps {
content: string; content: string | undefined;
isCompleted?: boolean; isCompleted?: boolean;
animate?: boolean; animate?: boolean;
files?: string; files?: string;

View file

@ -9,7 +9,7 @@ import { type EndpointType, useChat } from "@/contexts/chat-context";
import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context";
import { useTask } from "@/contexts/task-context"; import { useTask } from "@/contexts/task-context";
import { useChatStreaming } from "@/hooks/useChatStreaming"; import { useChatStreaming } from "@/hooks/useChatStreaming";
import { FILES_REGEX } from "@/lib/constants"; import { FILE_CONFIRMATION, FILES_REGEX } from "@/lib/constants";
import { useLoadingStore } from "@/stores/loadingStore"; import { useLoadingStore } from "@/stores/loadingStore";
import { useGetNudgesQuery } from "../api/queries/useGetNudgesQuery"; import { useGetNudgesQuery } from "../api/queries/useGetNudgesQuery";
import { AssistantMessage } from "./components/assistant-message"; import { AssistantMessage } from "./components/assistant-message";
@ -911,9 +911,9 @@ function ChatPage() {
} }
// Only send message if there's input text // Only send message if there's input text
if (input.trim()) { if (input.trim() || uploadedFile) {
// Pass the responseId from upload (if any) to handleSendMessage // Pass the responseId from upload (if any) to handleSendMessage
handleSendMessage(input, uploadedResponseId || undefined); handleSendMessage(!input.trim() ? FILE_CONFIRMATION : input, uploadedResponseId || undefined);
} }
}; };
@ -1154,6 +1154,8 @@ function ChatPage() {
} }
}; };
console.log(messages)
return ( return (
<> <>
{/* Debug header - only show in debug mode */} {/* Debug header - only show in debug mode */}
@ -1236,7 +1238,10 @@ function ChatPage() {
? message.source !== "langflow" ? message.source !== "langflow"
: false : false
} }
content={message.content} content={index >= 2
&& (messages[index - 2]?.content.match(
FILES_REGEX,
)?.[0] ?? undefined) && message.content === FILE_CONFIRMATION ? undefined : message.content}
files={ files={
index >= 2 index >= 2
? messages[index - 2]?.content.match( ? messages[index - 2]?.content.match(

View file

@ -24,9 +24,6 @@ export function OnboardingContent({
const [assistantMessage, setAssistantMessage] = useState<Message | null>( const [assistantMessage, setAssistantMessage] = useState<Message | null>(
null, null,
); );
const [isLoadingModels, setIsLoadingModels] = useState<boolean>(false);
const [loadingStatus, setLoadingStatus] = useState<string[]>([]);
const [hasStartedOnboarding, setHasStartedOnboarding] = useState<boolean>(false);
const { streamingMessage, isLoading, sendMessage } = useChatStreaming({ const { streamingMessage, isLoading, sendMessage } = useChatStreaming({
onComplete: (message, newResponseId) => { onComplete: (message, newResponseId) => {
@ -81,18 +78,14 @@ export function OnboardingContent({
<OnboardingStep <OnboardingStep
isVisible={currentStep >= 0} isVisible={currentStep >= 0}
isCompleted={currentStep > 0} isCompleted={currentStep > 0}
showCompleted={true}
text="Let's get started by setting up your model provider." text="Let's get started by setting up your model provider."
isLoadingModels={isLoadingModels}
loadingStatus={loadingStatus}
reserveSpaceForThinking={!hasStartedOnboarding}
> >
<OnboardingCard <OnboardingCard
onComplete={() => { onComplete={() => {
setHasStartedOnboarding(true);
handleStepComplete(); handleStepComplete();
}} }}
setIsLoadingModels={setIsLoadingModels} isCompleted={currentStep > 0}
setLoadingStatus={setLoadingStatus}
/> />
</OnboardingStep> </OnboardingStep>

View file

@ -2,7 +2,6 @@ import { AnimatePresence, motion } from "motion/react";
import { type ReactNode, useEffect, useState } from "react"; import { type ReactNode, useEffect, useState } from "react";
import { Message } from "@/app/chat/components/message"; import { Message } from "@/app/chat/components/message";
import DogIcon from "@/components/logo/dog-icon"; import DogIcon from "@/components/logo/dog-icon";
import AnimatedProcessingIcon from "@/components/ui/animated-processing-icon";
import { MarkdownRenderer } from "@/components/markdown-renderer"; import { MarkdownRenderer } from "@/components/markdown-renderer";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@ -11,12 +10,10 @@ interface OnboardingStepProps {
children?: ReactNode; children?: ReactNode;
isVisible: boolean; isVisible: boolean;
isCompleted?: boolean; isCompleted?: boolean;
showCompleted?: boolean;
icon?: ReactNode; icon?: ReactNode;
isMarkdown?: boolean; isMarkdown?: boolean;
hideIcon?: boolean; hideIcon?: boolean;
isLoadingModels?: boolean;
loadingStatus?: string[];
reserveSpaceForThinking?: boolean;
} }
export function OnboardingStep({ export function OnboardingStep({
@ -24,38 +21,13 @@ export function OnboardingStep({
children, children,
isVisible, isVisible,
isCompleted = false, isCompleted = false,
showCompleted = false,
icon, icon,
isMarkdown = false, isMarkdown = false,
hideIcon = false, hideIcon = false,
isLoadingModels = false,
loadingStatus = [],
reserveSpaceForThinking = false,
}: OnboardingStepProps) { }: OnboardingStepProps) {
const [displayedText, setDisplayedText] = useState(""); const [displayedText, setDisplayedText] = useState("");
const [showChildren, setShowChildren] = useState(false); const [showChildren, setShowChildren] = useState(false);
const [currentStatusIndex, setCurrentStatusIndex] = useState<number>(0);
// Cycle through loading status messages once
useEffect(() => {
if (!isLoadingModels || loadingStatus.length === 0) {
setCurrentStatusIndex(0);
return;
}
const interval = setInterval(() => {
setCurrentStatusIndex((prev) => {
const nextIndex = prev + 1;
// Stop at the last message
if (nextIndex >= loadingStatus.length - 1) {
clearInterval(interval);
return loadingStatus.length - 1;
}
return nextIndex;
});
}, 1500); // Change status every 1.5 seconds
return () => clearInterval(interval);
}, [isLoadingModels, loadingStatus]);
useEffect(() => { useEffect(() => {
if (!isVisible) { if (!isVisible) {
@ -113,48 +85,15 @@ export function OnboardingStep({
} }
> >
<div> <div>
{isLoadingModels && loadingStatus.length > 0 ? ( {isMarkdown ? (
<div className="flex flex-col gap-2 py-1.5">
<div className="flex items-center gap-2">
<div className="relative w-1.5 h-2.5">
<AnimatedProcessingIcon className="text-current shrink-0 absolute inset-0" />
</div>
<span className="text-mmd font-medium text-muted-foreground">
Thinking
</span>
</div>
<div className="overflow-hidden">
<div className="flex items-center gap-5 overflow-y-hidden relative h-6">
<div className="w-px h-6 bg-border" />
<div className="relative h-5 w-full">
<AnimatePresence mode="sync" initial={false}>
<motion.span
key={currentStatusIndex}
initial={{ y: 24, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: -24, opacity: 0 }}
transition={{ duration: 0.3, ease: "easeInOut" }}
className="text-mmd font-medium text-primary absolute left-0"
>
{loadingStatus[currentStatusIndex]}
</motion.span>
</AnimatePresence>
</div>
</div>
</div>
</div>
) : isMarkdown ? (
<MarkdownRenderer <MarkdownRenderer
className={cn( className={cn(
isCompleted isCompleted ? "text-placeholder-foreground" : "text-foreground",
? "text-placeholder-foreground"
: "text-foreground",
"text-sm py-1.5 transition-colors duration-300", "text-sm py-1.5 transition-colors duration-300",
)} )}
chatMessage={text} chatMessage={text}
/> />
) : ( ) : (
<>
<p <p
className={`text-foreground text-sm py-1.5 transition-colors duration-300 ${ className={`text-foreground text-sm py-1.5 transition-colors duration-300 ${
isCompleted ? "text-placeholder-foreground" : "" isCompleted ? "text-placeholder-foreground" : ""
@ -165,22 +104,18 @@ export function OnboardingStep({
<span className="inline-block w-1 h-3.5 bg-primary ml-1 animate-pulse" /> <span className="inline-block w-1 h-3.5 bg-primary ml-1 animate-pulse" />
)} )}
</p> </p>
{reserveSpaceForThinking && (
<div className="h-8" />
)}
</>
)} )}
{children && ( {children && (
<AnimatePresence> <AnimatePresence>
{((showChildren && !isCompleted) || isMarkdown) && ( {((showChildren && (!isCompleted || showCompleted)) ||
isMarkdown) && (
<motion.div <motion.div
initial={{ opacity: 0, y: -10 }} initial={{ opacity: 0, y: -10 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, height: 0 }} exit={{ opacity: 0, height: 0 }}
transition={{ duration: 0.3, delay: 0.3, ease: "easeOut" }} transition={{ duration: 0.3, delay: 0.3, ease: "easeOut" }}
> >
<div className="pt-2"> <div className="pt-4">{children}</div>
{children}</div>
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>

View file

@ -1,8 +1,8 @@
import { ChangeEvent, useRef, useState } from "react"; import { AnimatePresence, motion } from "motion/react";
import { type ChangeEvent, useRef, useState } from "react";
import { AnimatedProviderSteps } from "@/app/onboarding/components/animated-provider-steps";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { uploadFileForContext } from "@/lib/upload-utils"; import { uploadFileForContext } from "@/lib/upload-utils";
import { AnimatePresence, motion } from "motion/react";
import { AnimatedProviderSteps } from "@/app/onboarding/components/animated-provider-steps";
interface OnboardingUploadProps { interface OnboardingUploadProps {
onComplete: () => void; onComplete: () => void;
@ -13,10 +13,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
const [isUploading, setIsUploading] = useState(false); const [isUploading, setIsUploading] = useState(false);
const [currentStep, setCurrentStep] = useState<number | null>(null); const [currentStep, setCurrentStep] = useState<number | null>(null);
const STEP_LIST = [ const STEP_LIST = ["Uploading your document", "Processing your document"];
"Uploading your document",
"Processing your document",
];
const resetFileInput = () => { const resetFileInput = () => {
if (fileInputRef.current) { if (fileInputRef.current) {
@ -38,9 +35,9 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
console.error("Upload failed", (error as Error).message); console.error("Upload failed", (error as Error).message);
} finally { } finally {
setIsUploading(false); setIsUploading(false);
await new Promise(resolve => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
setCurrentStep(STEP_LIST.length); setCurrentStep(STEP_LIST.length);
await new Promise(resolve => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
onComplete(); onComplete();
} }
}; };
@ -55,13 +52,15 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
try { try {
await performUpload(selectedFile); await performUpload(selectedFile);
} catch (error) { } catch (error) {
console.error("Unable to prepare file for upload", (error as Error).message); console.error(
"Unable to prepare file for upload",
(error as Error).message,
);
} finally { } finally {
resetFileInput(); resetFileInput();
} }
}; };
return ( return (
<AnimatePresence mode="wait"> <AnimatePresence mode="wait">
{currentStep === null ? ( {currentStep === null ? (
@ -97,12 +96,13 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
<AnimatedProviderSteps <AnimatedProviderSteps
currentStep={currentStep} currentStep={currentStep}
setCurrentStep={setCurrentStep} setCurrentStep={setCurrentStep}
isCompleted={false}
steps={STEP_LIST} steps={STEP_LIST}
/> />
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>
) );
} };
export default OnboardingUpload; export default OnboardingUpload;

View file

@ -1,15 +1,20 @@
import { ArrowRight } from 'lucide-react';
import { Button } from '@/components/ui/button';
interface ProgressBarProps { interface ProgressBarProps {
currentStep: number; currentStep: number;
totalSteps: number; totalSteps: number;
onSkip?: () => void;
} }
export function ProgressBar({ currentStep, totalSteps }: ProgressBarProps) { export function ProgressBar({ currentStep, totalSteps, onSkip }: ProgressBarProps) {
const progressPercentage = ((currentStep + 1) / totalSteps) * 100; const progressPercentage = ((currentStep + 1) / totalSteps) * 100;
return ( return (
<div className="w-full"> <div className="w-full flex items-center px-6 gap-4">
<div className="flex items-center max-w-48 mx-auto gap-3"> <div className="flex-1" />
<div className="flex-1 h-1 bg-background rounded-full overflow-hidden"> <div className="flex items-center gap-3">
<div className="w-48 h-1 bg-background rounded-full overflow-hidden">
<div <div
className="h-full transition-all duration-300 ease-in-out" className="h-full transition-all duration-300 ease-in-out"
style={{ style={{
@ -22,6 +27,19 @@ export function ProgressBar({ currentStep, totalSteps }: ProgressBarProps) {
{currentStep + 1}/{totalSteps} {currentStep + 1}/{totalSteps}
</span> </span>
</div> </div>
<div className="flex-1 flex justify-end">
{currentStep > 0 && onSkip && (
<Button
variant="ghost"
size="sm"
onClick={onSkip}
className="flex items-center gap-2 text-xs text-muted-foreground"
>
Skip onboarding
<ArrowRight className="w-4 h-4" />
</Button>
)}
</div>
</div> </div>
); );
} }

View file

@ -2,38 +2,85 @@
import { AnimatePresence, motion } from "framer-motion"; import { AnimatePresence, motion } from "framer-motion";
import { CheckIcon } from "lucide-react"; import { CheckIcon } from "lucide-react";
import { useEffect } from "react"; import { useEffect, useState } from "react";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import AnimatedProcessingIcon from "@/components/ui/animated-processing-icon"; import AnimatedProcessingIcon from "@/components/ui/animated-processing-icon";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
export function AnimatedProviderSteps({ export function AnimatedProviderSteps({
currentStep, currentStep,
isCompleted,
setCurrentStep, setCurrentStep,
steps, steps,
storageKey = "provider-steps",
processingStartTime,
}: { }: {
currentStep: number; currentStep: number;
isCompleted: boolean;
setCurrentStep: (step: number) => void; setCurrentStep: (step: number) => void;
steps: string[]; steps: string[];
storageKey?: string;
processingStartTime?: number | null;
}) { }) {
const [startTime, setStartTime] = useState<number | null>(null);
const [elapsedTime, setElapsedTime] = useState<number>(0);
// Initialize start time from prop or local storage
useEffect(() => { useEffect(() => {
if (currentStep < steps.length - 1) { const storedElapsedTime = localStorage.getItem(`${storageKey}-elapsed`);
if (isCompleted && storedElapsedTime) {
// If completed, use stored elapsed time
setElapsedTime(parseFloat(storedElapsedTime));
} else if (processingStartTime) {
// Use the start time passed from parent (when user clicked Complete)
setStartTime(processingStartTime);
}
}, [storageKey, isCompleted, processingStartTime]);
// Progress through steps
useEffect(() => {
if (currentStep < steps.length - 1 && !isCompleted) {
const interval = setInterval(() => { const interval = setInterval(() => {
setCurrentStep(currentStep + 1); setCurrentStep(currentStep + 1);
}, 1500); }, 1500);
return () => clearInterval(interval); return () => clearInterval(interval);
} }
}, [currentStep, setCurrentStep, steps]); }, [currentStep, setCurrentStep, steps, isCompleted]);
const isDone = currentStep >= steps.length; // Calculate and store elapsed time when completed
useEffect(() => {
if (isCompleted && startTime) {
const elapsed = Date.now() - startTime;
setElapsedTime(elapsed);
localStorage.setItem(`${storageKey}-elapsed`, elapsed.toString());
}
}, [isCompleted, startTime, storageKey]);
const isDone = currentStep >= steps.length && !isCompleted;
return ( return (
<div className="flex flex-col gap-2"> <AnimatePresence mode="wait">
{!isCompleted ? (
<motion.div
key="processing"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.3 }}
className="flex flex-col gap-2"
>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<div <div
className={cn( className={cn(
"transition-all duration-150 relative", "transition-all duration-150 relative",
isDone ? "w-3.5 h-3.5" : "w-1.5 h-2.5", isDone ? "w-3.5 h-3.5" : "w-3.5 h-2.5",
)} )}
> >
<CheckIcon <CheckIcon
@ -61,9 +108,9 @@ export function AnimatedProviderSteps({
initial={{ opacity: 1, y: 0, height: "auto" }} initial={{ opacity: 1, y: 0, height: "auto" }}
exit={{ opacity: 0, y: -24, height: 0 }} exit={{ opacity: 0, y: -24, height: 0 }}
transition={{ duration: 0.4, ease: "easeInOut" }} transition={{ duration: 0.4, ease: "easeInOut" }}
className="flex items-center gap-5 overflow-y-hidden relative h-6" className="flex items-center gap-4 overflow-y-hidden relative h-6"
> >
<div className="w-px h-6 bg-border" /> <div className="w-px h-6 bg-border ml-2" />
<div className="relative h-5 w-full"> <div className="relative h-5 w-full">
<AnimatePresence mode="sync" initial={false}> <AnimatePresence mode="sync" initial={false}>
<motion.span <motion.span
@ -82,6 +129,79 @@ export function AnimatedProviderSteps({
)} )}
</AnimatePresence> </AnimatePresence>
</div> </div>
</motion.div>
) : (
<motion.div
key="completed"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.3 }}
>
<Accordion type="single" collapsible>
<AccordionItem value="steps" className="border-none">
<AccordionTrigger className="hover:no-underline p-0 py-2">
<div className="flex items-center gap-2">
<span className="text-mmd font-medium text-muted-foreground">
{`Initialized in ${(elapsedTime / 1000).toFixed(1)} seconds`}
</span>
</div> </div>
</AccordionTrigger>
<AccordionContent className="pl-0 pt-2 pb-0">
<div className="relative pl-1">
{/* Connecting line on the left */}
<motion.div
className="absolute left-[7px] top-0 bottom-0 w-px bg-border z-0"
initial={{ scaleY: 0 }}
animate={{ scaleY: 1 }}
transition={{ duration: 0.3, ease: "easeOut" }}
style={{ transformOrigin: "top" }}
/>
<div className="space-y-3 ml-4">
<AnimatePresence>
{steps.map((step, index) => (
<motion.div
key={step}
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
transition={{
duration: 0.3,
delay: index * 0.05,
}}
className="flex items-center gap-1.5"
>
<motion.div
className="relative w-3.5 h-3.5 shrink-0 z-10 bg-background"
initial={{ scale: 0 }}
animate={{ scale: 1 }}
transition={{
duration: 0.2,
delay: index * 0.05 + 0.1,
}}
>
<motion.div
key="check"
initial={{ scale: 0, rotate: -180 }}
animate={{ scale: 1, rotate: 0 }}
transition={{ duration: 0.3 }}
>
<CheckIcon className="text-accent-emerald-foreground w-3.5 h-3.5" />
</motion.div>
</motion.div>
<span className="text-mmd text-muted-foreground">
{step}
</span>
</motion.div>
))}
</AnimatePresence>
</div>
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
</motion.div>
)}
</AnimatePresence>
); );
} }

View file

@ -15,13 +15,11 @@ export function IBMOnboarding({
sampleDataset, sampleDataset,
setSampleDataset, setSampleDataset,
setIsLoadingModels, setIsLoadingModels,
setLoadingStatus,
}: { }: {
setSettings: (settings: OnboardingVariables) => void; setSettings: (settings: OnboardingVariables) => void;
sampleDataset: boolean; sampleDataset: boolean;
setSampleDataset: (dataset: boolean) => void; setSampleDataset: (dataset: boolean) => void;
setIsLoadingModels?: (isLoading: boolean) => void; setIsLoadingModels?: (isLoading: boolean) => void;
setLoadingStatus?: (status: string[]) => void;
}) { }) {
const [endpoint, setEndpoint] = useState("https://us-south.ml.cloud.ibm.com"); const [endpoint, setEndpoint] = useState("https://us-south.ml.cloud.ibm.com");
const [apiKey, setApiKey] = useState(""); const [apiKey, setApiKey] = useState("");
@ -91,6 +89,10 @@ export function IBMOnboarding({
setSampleDataset(dataset); setSampleDataset(dataset);
}; };
useEffect(() => {
setIsLoadingModels?.(isLoadingModels);
}, [isLoadingModels, setIsLoadingModels]);
// Update settings when values change // Update settings when values change
useUpdateSettings( useUpdateSettings(
"watsonx", "watsonx",
@ -104,18 +106,6 @@ export function IBMOnboarding({
setSettings, setSettings,
); );
// Notify parent about loading state
useEffect(() => {
setIsLoadingModels?.(isLoadingModels);
// Set detailed loading status
if (isLoadingModels) {
const status = ["Connecting to IBM watsonx.ai", "Fetching language models", "Fetching embedding models"];
setLoadingStatus?.(status);
} else {
setLoadingStatus?.([]);
}
}, [isLoadingModels, setIsLoadingModels, setLoadingStatus]);
return ( return (
<> <>
<div className="space-y-4"> <div className="space-y-4">

View file

@ -14,13 +14,11 @@ export function OllamaOnboarding({
sampleDataset, sampleDataset,
setSampleDataset, setSampleDataset,
setIsLoadingModels, setIsLoadingModels,
setLoadingStatus,
}: { }: {
setSettings: (settings: OnboardingVariables) => void; setSettings: (settings: OnboardingVariables) => void;
sampleDataset: boolean; sampleDataset: boolean;
setSampleDataset: (dataset: boolean) => void; setSampleDataset: (dataset: boolean) => void;
setIsLoadingModels?: (isLoading: boolean) => void; setIsLoadingModels?: (isLoading: boolean) => void;
setLoadingStatus?: (status: string[]) => void;
}) { }) {
const [endpoint, setEndpoint] = useState(`http://localhost:11434`); const [endpoint, setEndpoint] = useState(`http://localhost:11434`);
const [showConnecting, setShowConnecting] = useState(false); const [showConnecting, setShowConnecting] = useState(false);
@ -75,19 +73,6 @@ export function OllamaOnboarding({
setSettings, setSettings,
); );
// Notify parent about loading state
useEffect(() => {
setIsLoadingModels?.(isLoadingModels);
// Set detailed loading status
if (isLoadingModels) {
const status = ["Connecting to Ollama", "Fetching language models", "Fetching embedding models"];
setLoadingStatus?.(status);
} else {
setLoadingStatus?.([]);
}
}, [isLoadingModels, setIsLoadingModels, setLoadingStatus]);
// Check validation state based on models query // Check validation state based on models query
const hasConnectionError = debouncedEndpoint && modelsError; const hasConnectionError = debouncedEndpoint && modelsError;
const hasNoModels = const hasNoModels =

View file

@ -27,11 +27,11 @@ import { OpenAIOnboarding } from "./openai-onboarding";
interface OnboardingCardProps { interface OnboardingCardProps {
onComplete: () => void; onComplete: () => void;
isCompleted?: boolean;
setIsLoadingModels?: (isLoading: boolean) => void; setIsLoadingModels?: (isLoading: boolean) => void;
setLoadingStatus?: (status: string[]) => void; setLoadingStatus?: (status: string[]) => void;
} }
const STEP_LIST = [ const STEP_LIST = [
"Setting up your model provider", "Setting up your model provider",
"Defining schema", "Defining schema",
@ -43,8 +43,7 @@ const TOTAL_PROVIDER_STEPS = STEP_LIST.length;
const OnboardingCard = ({ const OnboardingCard = ({
onComplete, onComplete,
setIsLoadingModels: setIsLoadingModelsParent, isCompleted = false,
setLoadingStatus: setLoadingStatusParent,
}: OnboardingCardProps) => { }: OnboardingCardProps) => {
const { isHealthy: isDoclingHealthy } = useDoclingHealth(); const { isHealthy: isDoclingHealthy } = useDoclingHealth();
@ -54,40 +53,14 @@ const OnboardingCard = ({
const [isLoadingModels, setIsLoadingModels] = useState<boolean>(false); const [isLoadingModels, setIsLoadingModels] = useState<boolean>(false);
const [loadingStatus, setLoadingStatus] = useState<string[]>([]); const [loadingStep, setLoadingStep] = useState<number>(0);
const [currentStatusIndex, setCurrentStatusIndex] = useState<number>(0); // Reset loading step when models start loading
// Pass loading state to parent
useEffect(() => { useEffect(() => {
setIsLoadingModelsParent?.(isLoadingModels); if (isLoadingModels) {
}, [isLoadingModels, setIsLoadingModelsParent]); setLoadingStep(0);
useEffect(() => {
setLoadingStatusParent?.(loadingStatus);
}, [loadingStatus, setLoadingStatusParent]);
// Cycle through loading status messages once
useEffect(() => {
if (!isLoadingModels || loadingStatus.length === 0) {
setCurrentStatusIndex(0);
return;
} }
}, [isLoadingModels]);
const interval = setInterval(() => {
setCurrentStatusIndex((prev) => {
const nextIndex = prev + 1;
// Stop at the last message
if (nextIndex >= loadingStatus.length - 1) {
clearInterval(interval);
return loadingStatus.length - 1;
}
return nextIndex;
});
}, 1500); // Change status every 1.5 seconds
return () => clearInterval(interval);
}, [isLoadingModels, loadingStatus]);
const handleSetModelProvider = (provider: string) => { const handleSetModelProvider = (provider: string) => {
setModelProvider(provider); setModelProvider(provider);
@ -104,7 +77,13 @@ const OnboardingCard = ({
llm_model: "", llm_model: "",
}); });
const [currentStep, setCurrentStep] = useState<number | null>(null); const [currentStep, setCurrentStep] = useState<number | null>(
isCompleted ? TOTAL_PROVIDER_STEPS : null,
);
const [processingStartTime, setProcessingStartTime] = useState<number | null>(
null,
);
// Query tasks to track completion // Query tasks to track completion
const { data: tasks } = useGetTasksQuery({ const { data: tasks } = useGetTasksQuery({
@ -129,7 +108,8 @@ const OnboardingCard = ({
// If no active tasks and we've started onboarding, complete it // If no active tasks and we've started onboarding, complete it
if ( if (
(!activeTasks || (activeTasks.processed_files ?? 0) > 0) && (!activeTasks || (activeTasks.processed_files ?? 0) > 0) &&
tasks.length > 0 tasks.length > 0 &&
!isCompleted
) { ) {
// Set to final step to show "Done" // Set to final step to show "Done"
setCurrentStep(TOTAL_PROVIDER_STEPS); setCurrentStep(TOTAL_PROVIDER_STEPS);
@ -138,7 +118,7 @@ const OnboardingCard = ({
onComplete(); onComplete();
}, 1000); }, 1000);
} }
}, [tasks, currentStep, onComplete]); }, [tasks, currentStep, onComplete, isCompleted]);
// Mutations // Mutations
const onboardingMutation = useOnboardingMutation({ const onboardingMutation = useOnboardingMutation({
@ -186,6 +166,8 @@ const OnboardingCard = ({
onboardingData.project_id = settings.project_id; onboardingData.project_id = settings.project_id;
} }
// Record the start time when user clicks Complete
setProcessingStartTime(Date.now());
onboardingMutation.mutate(onboardingData); onboardingMutation.mutate(onboardingData);
setCurrentStep(0); setCurrentStep(0);
}; };
@ -208,43 +190,91 @@ const OnboardingCard = ({
onValueChange={handleSetModelProvider} onValueChange={handleSetModelProvider}
> >
<TabsList className="mb-4"> <TabsList className="mb-4">
<TabsTrigger <TabsTrigger value="openai">
value="openai" <div
className={cn(
"flex items-center justify-center gap-2 w-8 h-8 rounded-md",
modelProvider === "openai" ? "bg-white" : "bg-muted",
)}
> >
<div className={cn("flex items-center justify-center gap-2 w-8 h-8 rounded-md", modelProvider === "openai" ? "bg-white" : "bg-muted")}> <OpenAILogo
<OpenAILogo className={cn("w-4 h-4 shrink-0", modelProvider === "openai" ? "text-black" : "text-muted-foreground")} /> className={cn(
"w-4 h-4 shrink-0",
modelProvider === "openai"
? "text-black"
: "text-muted-foreground",
)}
/>
</div> </div>
OpenAI OpenAI
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger value="watsonx">
value="watsonx" <div
className={cn(
"flex items-center justify-center gap-2 w-8 h-8 rounded-md",
modelProvider === "watsonx" ? "bg-[#1063FE]" : "bg-muted",
)}
> >
<div className={cn("flex items-center justify-center gap-2 w-8 h-8 rounded-md", modelProvider === "watsonx" ? "bg-[#1063FE]" : "bg-muted")}> <IBMLogo
<IBMLogo className={cn("w-4 h-4 shrink-0", modelProvider === "watsonx" ? "text-white" : "text-muted-foreground")} /> className={cn(
"w-4 h-4 shrink-0",
modelProvider === "watsonx"
? "text-white"
: "text-muted-foreground",
)}
/>
</div> </div>
IBM watsonx.ai IBM watsonx.ai
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger value="ollama">
value="ollama" <div
className={cn(
"flex items-center justify-center gap-2 w-8 h-8 rounded-md",
modelProvider === "ollama" ? "bg-white" : "bg-muted",
)}
> >
<div className={cn("flex items-center justify-center gap-2 w-8 h-8 rounded-md", modelProvider === "ollama" ? "bg-white" : "bg-muted")}>
<OllamaLogo <OllamaLogo
className={cn( className={cn(
"w-4 h-4 shrink-0", "w-4 h-4 shrink-0",
modelProvider === "ollama" ? "text-black" : "text-muted-foreground", modelProvider === "ollama"
? "text-black"
: "text-muted-foreground",
)} )}
/> />
</div> </div>
Ollama Ollama
</TabsTrigger> </TabsTrigger>
</TabsList> </TabsList>
<AnimatePresence>
{isLoadingModels && (
<motion.div
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: "auto" }}
exit={{ opacity: 0, height: 0 }}
transition={{ duration: 0.1, ease: "easeInOut" }}
className="overflow-hidden"
>
<div className="py-3">
<AnimatedProviderSteps
currentStep={loadingStep}
isCompleted={false}
setCurrentStep={setLoadingStep}
steps={[
"Connecting to the provider",
"Fetching language models",
"Fetching embedding models",
]}
storageKey="model-loading-steps"
/></div>
</motion.div>
)}
</AnimatePresence>
<TabsContent value="openai"> <TabsContent value="openai">
<OpenAIOnboarding <OpenAIOnboarding
setSettings={setSettings} setSettings={setSettings}
sampleDataset={sampleDataset} sampleDataset={sampleDataset}
setSampleDataset={setSampleDataset} setSampleDataset={setSampleDataset}
setIsLoadingModels={setIsLoadingModels} setIsLoadingModels={setIsLoadingModels}
setLoadingStatus={setLoadingStatus}
/> />
</TabsContent> </TabsContent>
<TabsContent value="watsonx"> <TabsContent value="watsonx">
@ -253,7 +283,6 @@ const OnboardingCard = ({
sampleDataset={sampleDataset} sampleDataset={sampleDataset}
setSampleDataset={setSampleDataset} setSampleDataset={setSampleDataset}
setIsLoadingModels={setIsLoadingModels} setIsLoadingModels={setIsLoadingModels}
setLoadingStatus={setLoadingStatus}
/> />
</TabsContent> </TabsContent>
<TabsContent value="ollama"> <TabsContent value="ollama">
@ -262,19 +291,19 @@ const OnboardingCard = ({
sampleDataset={sampleDataset} sampleDataset={sampleDataset}
setSampleDataset={setSampleDataset} setSampleDataset={setSampleDataset}
setIsLoadingModels={setIsLoadingModels} setIsLoadingModels={setIsLoadingModels}
setLoadingStatus={setLoadingStatus}
/> />
</TabsContent> </TabsContent>
</Tabs> </Tabs>
{!isLoadingModels && (
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<div> <div>
<Button <Button
size="sm" size="sm"
onClick={handleComplete} onClick={handleComplete}
disabled={!isComplete} disabled={!isComplete || isLoadingModels}
loading={onboardingMutation.isPending} loading={onboardingMutation.isPending}
> >
<span className="select-none">Complete</span> <span className="select-none">Complete</span>
@ -283,7 +312,9 @@ const OnboardingCard = ({
</TooltipTrigger> </TooltipTrigger>
{!isComplete && ( {!isComplete && (
<TooltipContent> <TooltipContent>
{!!settings.llm_model && {isLoadingModels
? "Loading models..."
: !!settings.llm_model &&
!!settings.embedding_model && !!settings.embedding_model &&
!isDoclingHealthy !isDoclingHealthy
? "docling-serve must be running to continue" ? "docling-serve must be running to continue"
@ -291,7 +322,6 @@ const OnboardingCard = ({
</TooltipContent> </TooltipContent>
)} )}
</Tooltip> </Tooltip>
)}
</div> </div>
</motion.div> </motion.div>
) : ( ) : (
@ -303,8 +333,10 @@ const OnboardingCard = ({
> >
<AnimatedProviderSteps <AnimatedProviderSteps
currentStep={currentStep} currentStep={currentStep}
isCompleted={isCompleted}
setCurrentStep={setCurrentStep} setCurrentStep={setCurrentStep}
steps={STEP_LIST} steps={STEP_LIST}
processingStartTime={processingStartTime}
/> />
</motion.div> </motion.div>
)} )}

View file

@ -15,13 +15,11 @@ export function OpenAIOnboarding({
sampleDataset, sampleDataset,
setSampleDataset, setSampleDataset,
setIsLoadingModels, setIsLoadingModels,
setLoadingStatus,
}: { }: {
setSettings: (settings: OnboardingVariables) => void; setSettings: (settings: OnboardingVariables) => void;
sampleDataset: boolean; sampleDataset: boolean;
setSampleDataset: (dataset: boolean) => void; setSampleDataset: (dataset: boolean) => void;
setIsLoadingModels?: (isLoading: boolean) => void; setIsLoadingModels?: (isLoading: boolean) => void;
setLoadingStatus?: (status: string[]) => void;
}) { }) {
const [apiKey, setApiKey] = useState(""); const [apiKey, setApiKey] = useState("");
const [getFromEnv, setGetFromEnv] = useState(true); const [getFromEnv, setGetFromEnv] = useState(true);
@ -62,6 +60,10 @@ export function OpenAIOnboarding({
setEmbeddingModel(""); setEmbeddingModel("");
}; };
useEffect(() => {
setIsLoadingModels?.(isLoadingModels);
}, [isLoadingModels, setIsLoadingModels]);
// Update settings when values change // Update settings when values change
useUpdateSettings( useUpdateSettings(
"openai", "openai",
@ -73,18 +75,6 @@ export function OpenAIOnboarding({
setSettings, setSettings,
); );
// Notify parent about loading state
useEffect(() => {
setIsLoadingModels?.(isLoadingModels);
// Set detailed loading status
if (isLoadingModels) {
const status = ["Connecting to OpenAI", "Fetching language models", "Fetching embedding models"];
setLoadingStatus?.(status);
} else {
setLoadingStatus?.([]);
}
}, [isLoadingModels, setIsLoadingModels, setLoadingStatus]);
return ( return (
<> <>
<div className="space-y-5"> <div className="space-y-5">

View file

@ -86,6 +86,14 @@ export function ChatRenderer({
} }
}; };
const handleSkipOnboarding = () => {
// Skip onboarding by marking it as complete
if (typeof window !== "undefined") {
localStorage.removeItem(ONBOARDING_STEP_KEY);
}
setShowLayout(true);
};
// List of paths with smaller max-width // List of paths with smaller max-width
const smallWidthPaths = ["/settings/connector/new"]; const smallWidthPaths = ["/settings/connector/new"];
const isSmallWidthPath = smallWidthPaths.includes(pathname); const isSmallWidthPath = smallWidthPaths.includes(pathname);
@ -149,6 +157,7 @@ export function ChatRenderer({
className={cn( className={cn(
"flex h-full w-full max-w-full max-h-full items-center justify-center overflow-hidden", "flex h-full w-full max-w-full max-h-full items-center justify-center overflow-hidden",
!showLayout && "absolute", !showLayout && "absolute",
showLayout && !isOnChatPage && "bg-background",
)} )}
> >
<div <div
@ -172,7 +181,7 @@ export function ChatRenderer({
ease: "easeOut", ease: "easeOut",
delay: ANIMATION_DURATION, delay: ANIMATION_DURATION,
}} }}
className={cn("w-full h-full 0v")} className={cn("w-full h-full")}
> >
<div className={cn("w-full h-full", !showLayout && "hidden")}> <div className={cn("w-full h-full", !showLayout && "hidden")}>
{children} {children}
@ -195,6 +204,7 @@ export function ChatRenderer({
<ProgressBar <ProgressBar
currentStep={currentStep} currentStep={currentStep}
totalSteps={TOTAL_ONBOARDING_STEPS} totalSteps={TOTAL_ONBOARDING_STEPS}
onSkip={handleSkipOnboarding}
/> />
</motion.div> </motion.div>
</main> </main>

View file

@ -18,6 +18,7 @@ import {
useGetTasksQuery, useGetTasksQuery,
} from "@/app/api/queries/useGetTasksQuery"; } from "@/app/api/queries/useGetTasksQuery";
import { useAuth } from "@/contexts/auth-context"; import { useAuth } from "@/contexts/auth-context";
import { ONBOARDING_STEP_KEY } from "@/lib/constants";
// Task interface is now imported from useGetTasksQuery // Task interface is now imported from useGetTasksQuery
export type { Task }; export type { Task };
@ -89,6 +90,12 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
}, },
}); });
// Helper function to check if onboarding is active
const isOnboardingActive = useCallback(() => {
if (typeof window === "undefined") return false;
return localStorage.getItem(ONBOARDING_STEP_KEY) !== null;
}, []);
const refetchSearch = useCallback(() => { const refetchSearch = useCallback(() => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["search"], queryKey: ["search"],
@ -148,9 +155,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
const fileInfoEntry = fileInfo as TaskFileEntry; const fileInfoEntry = fileInfo as TaskFileEntry;
// Use the filename from backend if available, otherwise extract from path // Use the filename from backend if available, otherwise extract from path
const fileName = const fileName =
fileInfoEntry.filename || fileInfoEntry.filename || filePath.split("/").pop() || filePath;
filePath.split("/").pop() ||
filePath;
const fileStatus = fileInfoEntry.status ?? "processing"; const fileStatus = fileInfoEntry.status ?? "processing";
// Map backend file status to our TaskFile status // Map backend file status to our TaskFile status
@ -262,7 +267,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
successfulFiles !== 1 ? "s" : "" successfulFiles !== 1 ? "s" : ""
} uploaded successfully`; } uploaded successfully`;
} }
if (!isOnboardingActive()) {
toast.success("Task completed", { toast.success("Task completed", {
description, description,
action: { action: {
@ -273,6 +278,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
}, },
}, },
}); });
}
setTimeout(() => { setTimeout(() => {
setFiles((prevFiles) => setFiles((prevFiles) =>
prevFiles.filter( prevFiles.filter(
@ -301,7 +307,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
// Store current tasks as previous for next comparison // Store current tasks as previous for next comparison
previousTasksRef.current = tasks; previousTasksRef.current = tasks;
}, [tasks, refetchSearch]); }, [tasks, refetchSearch, isOnboardingActive]);
const addTask = useCallback( const addTask = useCallback(
(_taskId: string) => { (_taskId: string) => {
@ -319,7 +325,6 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
await refetchTasks(); await refetchTasks();
}, [refetchTasks]); }, [refetchTasks]);
const cancelTask = useCallback( const cancelTask = useCallback(
async (taskId: string) => { async (taskId: string) => {
cancelTaskMutation.mutate({ taskId }); cancelTaskMutation.mutate({ taskId });

View file

@ -36,3 +36,5 @@ export const ONBOARDING_STEP_KEY = "onboarding_current_step";
export const FILES_REGEX = export const FILES_REGEX =
/(?<=I'm uploading a document called ['"])[^'"]+\.[^.]+(?=['"]\. Here is its content:)/; /(?<=I'm uploading a document called ['"])[^'"]+\.[^.]+(?=['"]\. Here is its content:)/;
export const FILE_CONFIRMATION = "Confirm that you received this file.";

View file

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "openrag" name = "openrag"
version = "0.1.24" version = "0.1.25"
description = "Add your description here" description = "Add your description here"
readme = "README.md" readme = "README.md"
requires-python = ">=3.13" requires-python = ">=3.13"

View file

@ -1 +0,0 @@
../../../../documents/2506.08231v1.pdf

View file

@ -1 +0,0 @@
../../../../documents/ai-human-resources.pdf

View file

@ -0,0 +1 @@
../../../../documents/docling.pdf

View file

@ -0,0 +1 @@
../../../../documents/ibm_anthropic.pdf

View file

@ -0,0 +1 @@
../../../../documents/openrag-documentation.pdf

View file

@ -1 +0,0 @@
../../../../flows/openrag_ingest_docling.json

4
uv.lock generated
View file

@ -1,5 +1,5 @@
version = 1 version = 1
revision = 2 revision = 3
requires-python = ">=3.13" requires-python = ">=3.13"
resolution-markers = [ resolution-markers = [
"platform_machine == 'x86_64' and sys_platform == 'linux'", "platform_machine == 'x86_64' and sys_platform == 'linux'",
@ -2352,7 +2352,7 @@ wheels = [
[[package]] [[package]]
name = "openrag" name = "openrag"
version = "0.1.24" version = "0.1.25"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "agentd" }, { name = "agentd" },