Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

Merge branch 'main' of github.com:langflow-ai/openrag into IBM_COS_S3_SPIKE

Mike Fortman55961a3a6a59
diff --cc frontend/app/chat/page.tsx
index fe0d660e9,57317b08c..1f94aa530
--- a/frontend/app/chat/page.tsx
+++ b/frontend/app/chat/page.tsx
@@@ -283,6 -284,7 +284,7 @@@ function ChatPage()
role: "assistant",
content: `❌ Failed to process document. Please try again.`,
timestamp: new Date(),
- error: true,
++ error: true,
};
setMessages((prev) => [...prev.slice(0, -1), errorMessage]);
} finally {
@@@ -367,6 -369,7 +369,7 @@@
content: string;
timestamp?: string;
response_id?: string;
- error?: boolean;
++ error?: boolean;
chunks?: Array<{
item?: {
type?: string;
@@@ -394,6 -397,7 +397,7 @@@
role: msg.role as "user" | "assistant",
content: msg.content,
timestamp: new Date(msg.timestamp || new Date()),
- error: msg.error || false,
++ error: msg.error || false,
};
// Extract function calls from chunks or response_data
@@@ -905,6 -909,7 +909,7 @@@
role: "assistant",
content: "Sorry, I encountered an error. Please try again.",
timestamp: new Date(),
- error: true,
++ error: true,
};
setMessages((prev) => [...prev, errorMessage]);
}
@@@ -917,6 -922,7 +922,7 @@@
content:
"Sorry, I couldn't connect to the chat service. Please try again.",
timestamp: new Date(),
- error: true,
++ error: true,
};
setMessages((prev) => [...prev, errorMessage]);
}
diff --cc frontend/app/settings/_components/anthropic-settings-dialog.tsx
index 2cc1e2232,4652a26e6..f120ad36c
--- a/frontend/app/settings/_components/anthropic-settings-dialog.tsx
+++ b/frontend/app/settings/_components/anthropic-settings-dialog.tsx
@@@ -108,7 -138,7 +138,13 @@@ const AnthropicSettingsDialog = (
};
return (
- <Dialog open={open} onOpenChange={setOpen}>
- <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}>
++ <Dialog
++ open={open}
++ onOpenChange={(o) => {
++ setShowRemoveConfirm(false);
++ setOpen(o);
++ }}
++ >
<DialogContent className="max-w-2xl">
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">
diff --cc frontend/app/settings/_components/connector-card.tsx
index 2a958e2ec,b01b04bd7..a2229ff02
--- a/frontend/app/settings/_components/connector-card.tsx
+++ b/frontend/app/settings/_components/connector-card.tsx
@@@ -53,10 -50,10 +53,7 @@@ export default function ConnectorCard(
<div className="flex flex-col items-start justify-between">
<div className="flex flex-col gap-4 mb-2 w-full">
<div className="flex items-center justify-between mb-1">
-- <CardIcon
- isActive={!!isConnected}
- isActive={!!(connector?.available && isConnected)}
-- activeBgColor="bg-white"
-- >
++ <CardIcon isActive={!!isConnected} activeBgColor="bg-white">
{connector.icon}
</CardIcon>
{isConnected ? (
@@@ -80,97 -77,76 +77,112 @@@
</div>
</CardHeader>
<CardContent className="flex-1 flex flex-col justify-end space-y-4">
- {isConnected ? (
- <div className="flex gap-2 overflow-hidden w-full">
- <Button
- variant="default"
- onClick={() => onNavigateToKnowledge(connector)}
- disabled={isDisconnecting || isConnecting}
- className="cursor-pointer !text-sm truncate rounded-md"
- size="md"
- >
- <Plus className="h-4 w-4" />
- <span className="text-mmd truncate">Add Knowledge</span>
- </Button>
- {onConfigure ? (
- <Button
- variant="outline"
- onClick={() => onConfigure(connector)}
- disabled={isConnecting || isDisconnecting}
- className="cursor-pointer"
- size="iconMd"
- title="Edit configuration"
- >
- <Settings2 className="h-4 w-4" />
- </Button>
+ {connector?.available ? (
+ <div className="space-y-3">
+ {isConnected ? (
+ <div className="flex gap-2 overflow-hidden w-full">
+ <Button
+ variant="default"
+ onClick={() => onNavigateToKnowledge(connector)}
+ disabled={isDisconnecting || isConnecting}
+ className="cursor-pointer !text-sm truncate rounded-md flex-1"
+ size="md"
+ >
+ <Plus className="h-4 w-4" />
+ <span className="text-mmd truncate">Add Knowledge</span>
+ </Button>
+ <Button
+ variant="outline"
+ onClick={() => onConnect(connector)}
+ disabled={isConnecting || isDisconnecting}
+ className="cursor-pointer"
+ size="iconMd"
+ >
+ {isConnecting ? (
+ <RefreshCcw className="h-4 w-4 animate-spin" />
+ ) : (
+ <RefreshCcw className="h-4 w-4" />
+ )}
+ </Button>
+ <Button
+ variant="outline"
+ onClick={() => onDisconnect(connector)}
+ disabled={isDisconnecting || isConnecting}
+ className="cursor-pointer text-destructive hover:text-destructive"
+ size="iconMd"
+ >
+ {isDisconnecting ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <Trash2 className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
) : (
<Button
+ variant="outline"
onClick={() => onConnect(connector)}
- disabled={isConnecting}
- className="w-full cursor-pointer group-hover:bg-background group-hover:border-zinc-700 group-hover:text-primary"
- size="sm"
+ disabled={isConnecting || isDisconnecting}
+ className="cursor-pointer"
+ size="iconMd"
>
{isConnecting ? (
- <>
- <Loader2 className="h-4 w-4 animate-spin" />
- Connecting...
- </>
+ <RefreshCcw className="h-4 w-4 animate-spin" />
) : (
- <>Connect</>
+ <RefreshCcw className="h-4 w-4" />
)}
</Button>
)}
+ <Button
+ variant="outline"
+ onClick={() => onDisconnect(connector)}
+ disabled={isDisconnecting || isConnecting}
+ className="cursor-pointer text-destructive hover:text-destructive"
+ size="iconMd"
+ >
+ {isDisconnecting ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <Trash2 className="h-4 w-4" />
+ )}
+ </Button>
</div>
+ ) : onConfigure ? (
+ <Button
+ onClick={() => onConfigure(connector)}
+ disabled={isConnecting}
+ className="w-full cursor-pointer group-hover:bg-background group-hover:border-zinc-700 group-hover:text-primary"
+ size="sm"
+ >
+ Configure
+ </Button>
+ ) : connector?.available ? (
+ <Button
+ onClick={() => onConnect(connector)}
+ disabled={isConnecting}
+ className="w-full cursor-pointer group-hover:bg-background group-hover:border-zinc-700 group-hover:text-primary"
+ size="sm"
+ >
+ {isConnecting ? (
+ <>
+ <Loader2 className="h-4 w-4 animate-spin" />
+ Connecting...
+ </>
+ ) : (
+ <>Connect</>
+ )}
+ </Button>
) : (
<div className="text-sm text-muted-foreground">
- <p>
- See our{" "}
- <Link
- className="text-accent-pink-foreground"
- href="https://docs.openr.ag/knowledge#oauth-ingestion"
- target="_blank"
- rel="noopener noreferrer"
- >
- Cloud Connectors installation guide
- </Link>{" "}
- for more detail.
- </p>
+ <p>For more details see our</p>
+ <Link
+ className="text-accent-pink-foreground"
+ href="https://docs.openr.ag/knowledge#oauth-ingestion"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ Cloud Connectors guide
+ </Link>
</div>
)}
</CardContent>
diff --cc frontend/app/settings/_components/ollama-settings-dialog.tsx
index e0759600e,b60665bf3..e911cb2ab
--- a/frontend/app/settings/_components/ollama-settings-dialog.tsx
+++ b/frontend/app/settings/_components/ollama-settings-dialog.tsx
@@@ -18,6 -17,6 +17,7 @@@ import
DialogTitle,
} from "@/components/ui/dialog";
import { useAuth } from "@/contexts/auth-context";
++import ModelProviderDialogFooter from "./model-provider-dialog-footer";
import {
OllamaSettingsForm,
type OllamaSettingsFormData,
@@@ -110,7 -131,7 +131,13 @@@ const OllamaSettingsDialog = (
};
return (
- <Dialog open={open} onOpenChange={setOpen}>
- <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}>
++ <Dialog
++ open={open}
++ onOpenChange={(o) => {
++ setShowRemoveConfirm(false);
++ setOpen(o);
++ }}
++ >
<DialogContent className="max-w-2xl">
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">
diff --cc frontend/app/settings/_components/openai-settings-dialog.tsx
index 6d2ba8736,0eb08f9e4..eeb3e83f7
--- a/frontend/app/settings/_components/openai-settings-dialog.tsx
+++ b/frontend/app/settings/_components/openai-settings-dialog.tsx
@@@ -15,7 -16,7 +16,8 @@@ import
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
+ import { useAuth } from "@/contexts/auth-context";
++import ModelProviderDialogFooter from "./model-provider-dialog-footer";
import {
OpenAISettingsForm,
type OpenAISettingsFormData,
@@@ -109,7 -138,7 +138,13 @@@ const OpenAISettingsDialog = (
};
return (
- <Dialog open={open} onOpenChange={setOpen}>
- <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}>
++ <Dialog
++ open={open}
++ onOpenChange={(o) => {
++ setShowRemoveConfirm(false);
++ setOpen(o);
++ }}
++ >
<DialogContent className="max-w-2xl">
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">
diff --cc frontend/app/settings/_components/watsonx-settings-dialog.tsx
index 1c781272a,d6b1d9334..36ed50cc8
--- a/frontend/app/settings/_components/watsonx-settings-dialog.tsx
+++ b/frontend/app/settings/_components/watsonx-settings-dialog.tsx
@@@ -15,7 -16,7 +16,8 @@@ import
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
+ import { useAuth } from "@/contexts/auth-context";
++import ModelProviderDialogFooter from "./model-provider-dialog-footer";
import {
WatsonxSettingsForm,
type WatsonxSettingsFormData,
@@@ -118,7 -147,7 +147,13 @@@ const WatsonxSettingsDialog = (
};
return (
- <Dialog open={open} onOpenChange={setOpen}>
- <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}>
++ <Dialog
++ open={open}
++ onOpenChange={(o) => {
++ setShowRemoveConfirm(false);
++ setOpen(o);
++ }}
++ >
<DialogContent autoFocus={false} className="max-w-2xl">
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">
diff --cc frontend/hooks/useChatStreaming.ts
index 13144e910,eee28360c..e500c62f5
--- a/frontend/hooks/useChatStreaming.ts
+++ b/frontend/hooks/useChatStreaming.ts
@@@ -454,6 -455,17 +455,20 @@@ export function useChatStreaming(
currentFunctionCalls.push(newFunctionCall);
}
}
-
++
+ // Check for error status from Langflow
- if (chunk.finish_reason === "error" || chunk.status === "failed") {
++ if (
++ chunk.finish_reason === "error" ||
++ chunk.status === "failed"
++ ) {
+ console.error("Error detected in stream");
-
++
+ // Mark this as an error message and complete the stream
+ isError = true;
-
++
+ // Exit the streaming loop by throwing so the reader stops promptly on error
+ throw new Error("Error detected in stream");
+ }
// Handle text output streaming (Realtime API)
else if (chunk.type === "response.output_text.delta") {
currentContent += chunk.delta || "";
@@@ -468,15 -480,15 +483,19 @@@
// Handle OpenRAG backend format
else if (chunk.output_text) {
currentContent += chunk.output_text;
- } else if (chunk.delta) {
+ }
+ // Note: chunk.delta.content is already handled in the OpenAI format section above (line 271)
+ // Only handle delta if it's a string or has text (not content)
+ else if (chunk.delta) {
if (typeof chunk.delta === "string") {
currentContent += chunk.delta;
- } else if (typeof chunk.delta === "object") {
- if (chunk.delta.content) {
- currentContent += chunk.delta.content;
- } else if (chunk.delta.text) {
- currentContent += chunk.delta.text;
- }
- } else if (typeof chunk.delta === "object" && chunk.delta.text && !chunk.delta.content) {
++ } else if (
++ typeof chunk.delta === "object" &&
++ chunk.delta.text &&
++ !chunk.delta.content
++ ) {
+ // Only add text if content wasn't already processed
+ currentContent += chunk.delta.text;
}
}
@@@ -633,10 -646,10 +653,10 @@@
setStreamingMessage(null);
// Create user-friendly error message
- let errorContent =
- "Sorry, I couldn't connect to the chat service. Please try again.";
-
const errorMessage = (error as Error).message;
+ let errorContent = errorMessage; // Default to the actual error message
-
++
+ // Only override with generic messages for specific infrastructure errors
if (errorMessage?.includes("timed out")) {
errorContent =
"The request timed out. The server took too long to respond. Please try again.";