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 watsonx.data
Mike Fortman7434defa67b3
diff --cc frontend/app/knowledge/page.tsxindex 6eb62854f,fe3068bfb..ad3948a82--- a/frontend/app/knowledge/page.tsx+++ b/frontend/app/knowledge/page.tsx@@@ -30,9 -30,11 +31,13 @@@ importTooltipContent,TooltipTrigger,} from "@/components/ui/tooltip";+import { useIsCloudBrand } from "@/contexts/brand-context";+ import {+ buildKnowledgeTableRows,+ getKnowledgeFileIdentity,+ } from "@/lib/knowledge-table-state";import { parseTimestampMs } from "@/lib/time-utils";+import { cn } from "@/lib/utils";import {DeleteConfirmationDialog,formatFilesToDelete,@@@ -397,45 -382,44 +390,62 @@@ function SearchPage(){field: "size",headerName: "Size",+ ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),+ sortable: true,+ comparator: (valueA?: number, valueB?: number) =>+ (valueA || 0) - (valueB || 0),valueFormatter: (params: ValueFormatterParams<File>) =>params.value ? `${Math.round(params.value / 1024)} KB` : "-",+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,},{field: "mimetype",headerName: "Type",+ ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,+ sortable: true,},{field: "owner",headerName: "Owner",+ ...(isCloudBrand ? { flex: 1.4, minWidth: 180 } : {}),+ valueFormatter: (params: ValueFormatterParams<File>) =>+ params.data?.owner_name || params.data?.owner_email || "—",+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,+ sortable: true,+ valueGetter: (params: ValueGetterParams<File>) =>+ getOwnerLabel(params.data),+ comparator: (valueA?: string, valueB?: string) =>+ (valueA || "—").localeCompare(valueB || "—", undefined, {+ sensitivity: "base",+ }),},{field: "chunkCount",headerName: "Chunks",+ ...(isCloudBrand ? { flex: 0.9, minWidth: 95 } : {}),+ sortable: true,+ comparator: (valueA?: number, valueB?: number) =>+ (valueA || 0) - (valueB || 0),valueFormatter: (params: ValueFormatterParams<File>) =>params.data?.chunkCount?.toString() || "-",+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,},{field: "avgScore",headerName: "Avg score",+ ...(isCloudBrand ? { flex: 1, minWidth: 120 } : {}),+ sortable: true,+ comparator: (valueA?: number, valueB?: number) =>+ (valueA || 0) - (valueB || 0),cellRenderer: ({ value }: CustomCellRendererProps<File>) => {+ if (isCloudBrand) {+ return (+ <span className="text-muted-foreground">+ {typeof value === "number" ? value.toFixed(2) : "-"}+ </span>+ );+ }return (<span className="text-xs text-accent-emerald-foreground bg-accent-emerald px-2 py-1 rounded">{value?.toFixed(2) ?? "-"}@@@ -446,7 -430,7 +456,8 @@@{field: "embedding_model",headerName: "Embedding model",+ ...(isCloudBrand ? { flex: 1.4 } : {}),+ sortable: true,minWidth: 200,cellRenderer: ({ data }: CustomCellRendererProps<File>) => (<span className="text-xs text-muted-foreground">@@@ -457,7 -441,10 +468,10 @@@{field: "embedding_dimensions",headerName: "Dimensions",+ ...(isCloudBrand ? { flex: 0.9, minWidth: 110 } : { width: 110 }),+ sortable: true,+ comparator: (valueA?: number, valueB?: number) =>+ (valueA || 0) - (valueB || 0),- width: 110,cellRenderer: ({ data }: CustomCellRendererProps<File>) => (<span className="text-xs text-muted-foreground">{typeof data?.embedding_dimensions === "number"@@@ -469,7 -456,11 +483,12 @@@{field: "status",headerName: "Status",+ ...(isCloudBrand ? { flex: 1, minWidth: 130 } : {}),+ sortable: true,+ valueGetter: (params: ValueGetterParams<File>) =>+ params.data?.status || "active",+ comparator: (valueA?: File["status"], valueB?: File["status"]) =>+ getStatusSortRank(valueA) - getStatusSortRank(valueB),cellRenderer: ({ data }: CustomCellRendererProps<File>) => {const status = data?.status || "active";const showOpenragRefreshCue =@@@ -634,170 -609,127 +654,170 @@@<><div className="flex flex-col h-full"><div className="flex items-center justify-between mb-6">- <h2 className="text-lg font-semibold">Project Knowledge</h2>+ <h2+ className={cn(+ "text-lg font-semibold",+ isCloudBrand && "ibm-section-title",+ )}+ >+ Project knowledge+ </h2></div>+ {isCloudBrand ? (+ <KnowledgeSearchBar />+ ) : (+ /* Search Input Area */+ <div className="flex-1 flex items-center flex-shrink-0 flex-wrap-reverse gap-3 mb-6">+ <KnowledgeSearchInput />- {/* Search Input Area */}- <div className="flex-1 flex items-center flex-shrink-0 flex-wrap-reverse gap-3 mb-6">- <KnowledgeSearchInput />-- <Button- type="button"- variant="outline"- className="rounded-lg flex-shrink-0"- disabled={syncAllConnectorsMutation.isPending}- onClick={async () => {- try {- toast.info("Syncing all cloud connectors...");- const result = await syncAllConnectorsMutation.mutateAsync();- if (result.status === "no_files") {- toast.info(- result.message ||- "No cloud files to sync. Add files from cloud connectors first.",- );- } else if (- result.synced_connectors &&- result.synced_connectors.length > 0- ) {- toast.success(- `Sync started for ${result.synced_connectors.join(", ")}. Check task notifications for progress.`,+ <Button+ type="button"+ variant="outline"+ className="rounded-lg flex-shrink-0"+ disabled={syncAllConnectorsMutation.isPending}+ onClick={async () => {+ try {+ toast.info("Syncing all cloud connectors...");+ const result = await syncAllConnectorsMutation.mutateAsync();+ if (result.status === "no_files") {+ toast.info(+ result.message ||+ "No cloud files to sync. Add files from cloud connectors first.",+ );+ } else if (+ result.synced_connectors &&+ result.synced_connectors.length > 0+ ) {+ toast.success(+ `Sync started for ${result.synced_connectors.join(", ")}. Check task notifications for progress.`,+ );+ } else if (result.errors && result.errors.length > 0) {+ toast.error("Some connectors failed to sync");+ }+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : "Failed to sync connectors",);- } else if (result.errors && result.errors.length > 0) {- toast.error("Some connectors failed to sync");}- } catch (error) {- toast.error(- error instanceof Error- ? error.message- : "Failed to sync connectors",- );- }- }}- >- {syncAllConnectorsMutation.isPending ? (- <>- <RefreshCw className="h-4 w-4 mr-2 animate-spin" />- Syncing...- </>- ) : (- <>- <RefreshCw className="h-4 w-4 mr-2" />- Sync- </>- )}- </Button>- <Button- type="button"- variant="outline"- className="rounded-lg flex-shrink-0"- disabled={refreshOpenragDocsMutation.isPending}- onClick={async () => {- try {- toast.info("Refreshing OpenRAG docs...");- const result = await refreshOpenragDocsMutation.mutateAsync();- toast.success(result.message);- } catch (error) {- toast.error(- error instanceof Error- ? error.message- : "Failed to refresh OpenRAG docs",- );- }- }}- >- {refreshOpenragDocsMutation.isPending ? (- <>Refreshing docs...</>- ) : (- <>Fetch latest docs</>- )}- </Button>- {selectedRows.length > 0 && (+ }}+ >+ {syncAllConnectorsMutation.isPending ? (+ <>+ <RefreshCw className="h-4 w-4 mr-2 animate-spin" />+ Syncing...+ </>+ ) : (+ <>+ <RefreshCw className="h-4 w-4 mr-2" />+ Sync+ </>+ )}+ </Button><Buttontype="button"- variant="destructive"+ variant="outline"className="rounded-lg flex-shrink-0"- onClick={() => setShowBulkDeleteDialog(true)}+ disabled={refreshOpenragDocsMutation.isPending}+ onClick={async () => {+ try {+ toast.info("Refreshing OpenRAG docs...");+ const result = await refreshOpenragDocsMutation.mutateAsync();+ toast.success(result.message);+ } catch (error) {+ toast.error(+ error instanceof Error+ ? error.message+ : "Failed to refresh OpenRAG docs",+ );+ }+ }}>- Delete+ {refreshOpenragDocsMutation.isPending ? (+ <>Refreshing docs...</>+ ) : (+ <>Fetch latest docs</>+ )}</Button>- )}- <div className="ml-auto">- <KnowledgeDropdown />+ {selectedRows.length > 0 && (+ <Button+ type="button"+ variant="destructive"+ className="rounded-lg flex-shrink-0"+ onClick={() => setShowBulkDeleteDialog(true)}+ >+ Delete+ </Button>+ )}+ <div className="ml-auto">+ <KnowledgeDropdown />+ </div></div>- </div>- <AgGridReact- className="w-full overflow-auto"- columnDefs={columnDefs as ColDef<File>[]}- defaultColDef={defaultColDef}- loading={isSearchLoading || deleteDocumentMutation.isPending}- ref={gridRef}- theme={themeQuartz.withParams({ browserColorScheme: "inherit" })}- rowData={gridRows}- rowSelection="multiple"- rowMultiSelectWithClick={false}- suppressRowClickSelection={true}- getRowId={(params: GetRowIdParams<File>) =>- getFileIdentity(params.data)- }- domLayout="normal"- onSelectionChanged={onSelectionChanged}- pagination={pagination}- paginationPageSize={paginationPageSize}- paginationPageSizeSelector={paginationPageSizeSelector}- noRowsOverlayComponent={() => (- <div className="text-center pb-[45px]">- <div className="text-lg text-primary font-semibold">- No knowledge+ )}+ {isCloudBrand ? (+ <AgGridReact+ className="w-full overflow-auto border"+ columnDefs={columnDefs as ColDef<File>[]}+ defaultColDef={defaultColDef}- loading={isFetching}++ loading={isSearchLoading || deleteDocumentMutation.isPending}+ ref={gridRef}+ theme={themeQuartz.withParams({ browserColorScheme: "inherit" })}+ rowData={gridRows}+ rowSelection="multiple"+ getRowId={(params: GetRowIdParams<File>) =>+ getFileIdentity(params.data)+ }+ domLayout="normal"+ onSelectionChanged={onSelectionChanged}+ pagination={pagination}+ paginationPageSize={paginationPageSize}+ paginationPageSizeSelector={paginationPageSizeSelector}+ headerHeight={64}+ rowHeight={64}+ noRowsOverlayComponent={() => (+ <div className="text-center pb-[45px]">+ <div className="text-lg text-primary font-semibold">+ No knowledge+ </div>+ <div className="text-sm mt-1 text-muted-foreground">+ Add files from local or your preferred cloud.+ </div></div>- <div className="text-sm mt-1 text-muted-foreground">- Add files from local or your preferred cloud.+ )}+ />+ ) : (+ <AgGridReact+ className="w-full overflow-auto"+ columnDefs={columnDefs as ColDef<File>[]}+ defaultColDef={defaultColDef}- loading={isFetching}++ loading={isSearchLoading || deleteDocumentMutation.isPending}+ ref={gridRef}+ theme={themeQuartz.withParams({ browserColorScheme: "inherit" })}+ rowData={gridRows}+ rowSelection="multiple"+ rowMultiSelectWithClick={false}+ suppressRowClickSelection={true}+ getRowId={(params: GetRowIdParams<File>) =>+ getFileIdentity(params.data)+ }+ domLayout="normal"+ onSelectionChanged={onSelectionChanged}+ pagination={pagination}+ paginationPageSize={paginationPageSize}+ paginationPageSizeSelector={paginationPageSizeSelector}+ noRowsOverlayComponent={() => (+ <div className="text-center pb-[45px]">+ <div className="text-lg text-primary font-semibold">+ No knowledge+ </div>+ <div className="text-sm mt-1 text-muted-foreground">+ Add files from local or your preferred cloud.+ </div></div>- </div>- )}- />+ )}+ />+ )}</div>{/* Bulk Delete Confirmation Dialog */}diff --cc frontend/components/navigation.tsxindex 5ba58e758,6c1157645..b9a622d99--- a/frontend/components/navigation.tsx+++ b/frontend/components/navigation.tsx@@@ -315,43 -313,45 +315,58 @@@ export function Navigation(<div className="flex flex-col h-full bg-background"><div className="px-4 py-2 flex-shrink-0"><div className="space-y-1">- {routes.map((route) => (- <div key={route.href}>- <Link- href={route.href}- className={cn(- "text-[13px] group flex p-3 w-full justify-start font-medium cursor-pointer transition-all",- isCloudBrand- ? route.active- ? "border-l-[3px] border-l-primary bg-[var(--layered-select-bg)] text-foreground rounded-r-lg"- : "border-l-[3px] border-l-transparent text-foreground hover:bg-accent hover:text-accent-foreground rounded-lg"- : cn(- "hover:bg-accent hover:text-accent-foreground rounded-lg",- route.active- ? "bg-accent text-accent-foreground shadow-sm"- : "text-foreground hover:text-accent-foreground",- ),+ {routes.map((route) => {+ const isDisabled = loading && !route.active;+ const tabClassName = cn(- "text-[13px] group flex p-3 w-full justify-start font-medium rounded-lg transition-all",- isDisabled- ? "opacity-50 cursor-not-allowed text-foreground"- : "cursor-pointer hover:bg-accent hover:text-accent-foreground",- route.active- ? "bg-accent text-accent-foreground shadow-sm"- : "text-foreground",++ "text-[13px] group flex p-3 w-full justify-start font-medium transition-all",++ isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",++ isCloudBrand++ ? route.active++ ? "border-l-[3px] border-l-primary bg-[var(--layered-select-bg)] text-foreground rounded-r-lg"++ : cn(++ "border-l-[3px] border-l-transparent text-foreground rounded-lg",++ !isDisabled &&++ "hover:bg-accent hover:text-accent-foreground",++ )++ : cn(++ "rounded-lg",++ route.active++ ? "bg-accent text-accent-foreground shadow-sm"++ : "text-foreground",++ !isDisabled &&++ "hover:bg-accent hover:text-accent-foreground",++ ),+ );+ const tabContent = (+ <div className="flex items-center flex-1">+ <route.icon+ className={cn(+ "h-[18px] w-[18px] mr-2 shrink-0",- route.active- ? "text-muted-foreground"- : "text-muted-foreground group-hover:text-muted-foreground",++ isCloudBrand++ ? "text-foreground"++ : route.active++ ? "text-muted-foreground"++ : "text-muted-foreground group-hover:text-muted-foreground",+ )}+ />+ {route.label}+ </div>+ );+ return (+ <div key={route.href}>+ {isDisabled ? (+ <div className={tabClassName}>{tabContent}</div>+ ) : (+ <Link href={route.href} className={tabClassName}>+ {tabContent}+ </Link>)}- >- <div className="flex items-center flex-1">- <route.icon- className={cn(- "h-[18px] w-[18px] mr-2 shrink-0",- isCloudBrand- ? "text-foreground"- : route.active- ? "text-muted-foreground"- : "text-muted-foreground group-hover:text-muted-foreground",- )}- />- {route.label}- </div>- </Link>- {route.label === "Settings" && (- <div className="my-2 border-t border-border" />- )}- </div>- ))}+ {route.label === "Settings" && (+ <div className="my-2 border-t border-border" />+ )}+ </div>+ );+ })}</div></div>