Merge branch 'main' into feat-google-drive-folder-select
This commit is contained in:
commit
653825527a
24 changed files with 2662 additions and 2324 deletions
|
|
@ -103,7 +103,7 @@ export function KnowledgeDropdown() {
|
|||
const connections = statusData.connections || [];
|
||||
const activeConnection = connections.find(
|
||||
(conn: { is_active: boolean; connection_id: string }) =>
|
||||
conn.is_active,
|
||||
conn.is_active
|
||||
);
|
||||
const isConnected = activeConnection !== undefined;
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ export function KnowledgeDropdown() {
|
|||
// Check token availability
|
||||
try {
|
||||
const tokenRes = await fetch(
|
||||
`/api/connectors/${type}/token?connection_id=${activeConnection.connection_id}`,
|
||||
`/api/connectors/${type}/token?connection_id=${activeConnection.connection_id}`
|
||||
);
|
||||
if (tokenRes.ok) {
|
||||
const tokenData = await tokenRes.json();
|
||||
|
|
@ -175,7 +175,9 @@ export function KnowledgeDropdown() {
|
|||
// Check if filename already exists (using ORIGINAL filename)
|
||||
console.log("[Duplicate Check] Checking file:", file.name);
|
||||
const checkResponse = await fetch(
|
||||
`/api/documents/check-filename?filename=${encodeURIComponent(file.name)}`,
|
||||
`/api/documents/check-filename?filename=${encodeURIComponent(
|
||||
file.name
|
||||
)}`
|
||||
);
|
||||
|
||||
console.log("[Duplicate Check] Response status:", checkResponse.status);
|
||||
|
|
@ -184,7 +186,7 @@ export function KnowledgeDropdown() {
|
|||
const errorText = await checkResponse.text();
|
||||
console.error("[Duplicate Check] Error response:", errorText);
|
||||
throw new Error(
|
||||
`Failed to check duplicates: ${checkResponse.statusText}`,
|
||||
`Failed to check duplicates: ${checkResponse.statusText}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +230,7 @@ export function KnowledgeDropdown() {
|
|||
window.dispatchEvent(
|
||||
new CustomEvent("fileUploadStart", {
|
||||
detail: { filename: file.name },
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
@ -269,7 +271,7 @@ export function KnowledgeDropdown() {
|
|||
) {
|
||||
const errorMsg = runJson.error || "Ingestion pipeline failed";
|
||||
throw new Error(
|
||||
`Ingestion failed: ${errorMsg}. Try setting DISABLE_INGEST_WITH_LANGFLOW=true if you're experiencing Langflow component issues.`,
|
||||
`Ingestion failed: ${errorMsg}. Try setting DISABLE_INGEST_WITH_LANGFLOW=true if you're experiencing Langflow component issues.`
|
||||
);
|
||||
}
|
||||
// Log deletion status if provided
|
||||
|
|
@ -277,12 +279,12 @@ export function KnowledgeDropdown() {
|
|||
if (deleteResult.status === "deleted") {
|
||||
console.log(
|
||||
"File successfully cleaned up from Langflow:",
|
||||
deleteResult.file_id,
|
||||
deleteResult.file_id
|
||||
);
|
||||
} else if (deleteResult.status === "delete_failed") {
|
||||
console.warn(
|
||||
"Failed to cleanup file from Langflow:",
|
||||
deleteResult.error,
|
||||
deleteResult.error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +301,7 @@ export function KnowledgeDropdown() {
|
|||
unified: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
refetchTasks();
|
||||
|
|
@ -310,7 +312,7 @@ export function KnowledgeDropdown() {
|
|||
filename: file.name,
|
||||
error: error instanceof Error ? error.message : "Upload failed",
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
} finally {
|
||||
window.dispatchEvent(new CustomEvent("fileUploadComplete"));
|
||||
|
|
@ -325,7 +327,7 @@ export function KnowledgeDropdown() {
|
|||
if (!oldData) return oldData;
|
||||
// Filter out the file that's being overwritten
|
||||
return oldData.filter(
|
||||
(file: SearchFile) => file.filename !== pendingFile.name,
|
||||
(file: SearchFile) => file.filename !== pendingFile.name
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -494,11 +496,8 @@ export function KnowledgeDropdown() {
|
|||
onClick={() => !isLoading && setIsOpen(!isOpen)}
|
||||
disabled={isLoading}
|
||||
>
|
||||
|
||||
<>
|
||||
{isLoading &&
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
}
|
||||
{isLoading && <Loader2 className="h-4 w-4 animate-spin" />}
|
||||
<span>
|
||||
{isLoading
|
||||
? fileUploading
|
||||
|
|
@ -516,7 +515,7 @@ export function KnowledgeDropdown() {
|
|||
<ChevronDown
|
||||
className={cn(
|
||||
"h-4 w-4 transition-transform",
|
||||
isOpen && "rotate-180",
|
||||
isOpen && "rotate-180"
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -537,7 +536,7 @@ export function KnowledgeDropdown() {
|
|||
"w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground",
|
||||
"disabled" in item &&
|
||||
item.disabled &&
|
||||
"opacity-50 cursor-not-allowed hover:bg-transparent hover:text-current",
|
||||
"opacity-50 cursor-not-allowed hover:bg-transparent hover:text-current"
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
|
|
@ -576,7 +575,7 @@ export function KnowledgeDropdown() {
|
|||
type="text"
|
||||
placeholder="/path/to/documents"
|
||||
value={folderPath}
|
||||
onChange={(e) => setFolderPath(e.target.value)}
|
||||
onChange={e => setFolderPath(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
|
|
@ -618,7 +617,7 @@ export function KnowledgeDropdown() {
|
|||
type="text"
|
||||
placeholder="s3://bucket/path"
|
||||
value={bucketUrl}
|
||||
onChange={(e) => setBucketUrl(e.target.value)}
|
||||
onChange={e => setBucketUrl(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export function KnowledgeFilterList({
|
|||
<div className="flex-1 min-h-0 flex flex-col">
|
||||
<div className="px-3 flex-1 min-h-0 flex flex-col">
|
||||
<div className="flex-shrink-0">
|
||||
<div className="flex items-center justify-between mb-3 ml-3 mr-2">
|
||||
<div className="flex items-center justify-between mb-3 mr-2 ml-4">
|
||||
<h3 className="text-xs font-medium text-muted-foreground">
|
||||
Knowledge Filters
|
||||
</h3>
|
||||
|
|
@ -82,11 +82,11 @@ export function KnowledgeFilterList({
|
|||
</div>
|
||||
<div className="overflow-y-auto scrollbar-hide space-y-1">
|
||||
{loading ? (
|
||||
<div className="text-[13px] text-muted-foreground p-2 ml-1">
|
||||
<div className="text-[13px] text-muted-foreground p-2 ml-2">
|
||||
Loading...
|
||||
</div>
|
||||
) : filters.length === 0 ? (
|
||||
<div className="text-[13px] text-muted-foreground p-2 ml-1">
|
||||
<div className="text-[13px] text-muted-foreground pb-2 pt-3 ml-4">
|
||||
{searchQuery ? "No filters found" : "No saved filters"}
|
||||
</div>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export function KnowledgeFilterPanel() {
|
|||
// Load available facets using search aggregations hook
|
||||
const { data: aggregations } = useGetSearchAggregations("*", 1, 0, {
|
||||
enabled: isPanelOpen,
|
||||
placeholderData: (prev) => prev,
|
||||
placeholderData: prev => prev,
|
||||
staleTime: 60_000,
|
||||
gcTime: 5 * 60_000,
|
||||
});
|
||||
|
|
@ -214,7 +214,7 @@ export function KnowledgeFilterPanel() {
|
|||
facetType: keyof typeof selectedFilters,
|
||||
newValues: string[]
|
||||
) => {
|
||||
setSelectedFilters((prev) => ({
|
||||
setSelectedFilters(prev => ({
|
||||
...prev,
|
||||
[facetType]: newValues,
|
||||
}));
|
||||
|
|
@ -234,7 +234,7 @@ export function KnowledgeFilterPanel() {
|
|||
return (
|
||||
<div className="h-full bg-background border-l">
|
||||
<Card className="h-full rounded-none border-0 flex flex-col">
|
||||
<CardHeader className="pb-3">
|
||||
<CardHeader className="pb-3 pt-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="text-lg flex items-center gap-2">
|
||||
Knowledge Filter
|
||||
|
|
@ -271,7 +271,7 @@ export function KnowledgeFilterPanel() {
|
|||
<Input
|
||||
id="filter-name"
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
onChange={e => {
|
||||
const v = e.target.value;
|
||||
setName(v);
|
||||
if (nameError && v.trim()) {
|
||||
|
|
@ -302,7 +302,7 @@ export function KnowledgeFilterPanel() {
|
|||
<Textarea
|
||||
id="filter-description"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
onChange={e => setDescription(e.target.value)}
|
||||
placeholder="Provide a brief description of your knowledge filter..."
|
||||
rows={3}
|
||||
/>
|
||||
|
|
@ -319,7 +319,7 @@ export function KnowledgeFilterPanel() {
|
|||
placeholder="Enter your search query..."
|
||||
value={query}
|
||||
className="font-mono placeholder:font-mono"
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onChange={e => setQuery(e.target.value)}
|
||||
rows={2}
|
||||
disabled={!!queryOverride && !createMode}
|
||||
/>
|
||||
|
|
@ -329,13 +329,13 @@ export function KnowledgeFilterPanel() {
|
|||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<MultiSelect
|
||||
options={(availableFacets.data_sources || []).map((bucket) => ({
|
||||
options={(availableFacets.data_sources || []).map(bucket => ({
|
||||
value: bucket.key,
|
||||
label: bucket.key,
|
||||
count: bucket.count,
|
||||
}))}
|
||||
value={selectedFilters.data_sources}
|
||||
onValueChange={(values) =>
|
||||
onValueChange={values =>
|
||||
handleFilterChange("data_sources", values)
|
||||
}
|
||||
placeholder="Select sources..."
|
||||
|
|
@ -345,15 +345,13 @@ export function KnowledgeFilterPanel() {
|
|||
|
||||
<div className="space-y-2">
|
||||
<MultiSelect
|
||||
options={(availableFacets.document_types || []).map(
|
||||
(bucket) => ({
|
||||
options={(availableFacets.document_types || []).map(bucket => ({
|
||||
value: bucket.key,
|
||||
label: bucket.key,
|
||||
count: bucket.count,
|
||||
})
|
||||
)}
|
||||
}))}
|
||||
value={selectedFilters.document_types}
|
||||
onValueChange={(values) =>
|
||||
onValueChange={values =>
|
||||
handleFilterChange("document_types", values)
|
||||
}
|
||||
placeholder="Select types..."
|
||||
|
|
@ -363,13 +361,13 @@ export function KnowledgeFilterPanel() {
|
|||
|
||||
<div className="space-y-2">
|
||||
<MultiSelect
|
||||
options={(availableFacets.owners || []).map((bucket) => ({
|
||||
options={(availableFacets.owners || []).map(bucket => ({
|
||||
value: bucket.key,
|
||||
label: bucket.key,
|
||||
count: bucket.count,
|
||||
}))}
|
||||
value={selectedFilters.owners}
|
||||
onValueChange={(values) => handleFilterChange("owners", values)}
|
||||
onValueChange={values => handleFilterChange("owners", values)}
|
||||
placeholder="Select owners..."
|
||||
allOptionLabel="All Owners"
|
||||
/>
|
||||
|
|
@ -378,14 +376,14 @@ export function KnowledgeFilterPanel() {
|
|||
<div className="space-y-2">
|
||||
<MultiSelect
|
||||
options={(availableFacets.connector_types || []).map(
|
||||
(bucket) => ({
|
||||
bucket => ({
|
||||
value: bucket.key,
|
||||
label: bucket.key,
|
||||
count: bucket.count,
|
||||
})
|
||||
)}
|
||||
value={selectedFilters.connector_types}
|
||||
onValueChange={(values) =>
|
||||
onValueChange={values =>
|
||||
handleFilterChange("connector_types", values)
|
||||
}
|
||||
placeholder="Select connectors..."
|
||||
|
|
@ -405,7 +403,7 @@ export function KnowledgeFilterPanel() {
|
|||
min="1"
|
||||
max="1000"
|
||||
value={resultLimit}
|
||||
onChange={(e) => {
|
||||
onChange={e => {
|
||||
const newLimit = Math.max(
|
||||
1,
|
||||
Math.min(1000, parseInt(e.target.value) || 1)
|
||||
|
|
@ -418,7 +416,7 @@ export function KnowledgeFilterPanel() {
|
|||
</div>
|
||||
<Slider
|
||||
value={[resultLimit]}
|
||||
onValueChange={(values) => setResultLimit(values[0])}
|
||||
onValueChange={values => setResultLimit(values[0])}
|
||||
max={1000}
|
||||
min={1}
|
||||
step={1}
|
||||
|
|
@ -438,7 +436,7 @@ export function KnowledgeFilterPanel() {
|
|||
max="5"
|
||||
step="0.1"
|
||||
value={scoreThreshold}
|
||||
onChange={(e) =>
|
||||
onChange={e =>
|
||||
setScoreThreshold(parseFloat(e.target.value) || 0)
|
||||
}
|
||||
className="h-6 text-xs text-right px-2 bg-muted/30 !border-0 rounded ml-auto focus:ring-0 focus:outline-none"
|
||||
|
|
@ -447,7 +445,7 @@ export function KnowledgeFilterPanel() {
|
|||
</div>
|
||||
<Slider
|
||||
value={[scoreThreshold]}
|
||||
onValueChange={(values) => setScoreThreshold(values[0])}
|
||||
onValueChange={values => setScoreThreshold(values[0])}
|
||||
max={5}
|
||||
min={0}
|
||||
step={0.1}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|||
import * as React from "react";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none disabled:select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none disabled:select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
|
|
|
|||
62
frontend/components/ui/inputs/embedding-model.tsx
Normal file
62
frontend/components/ui/inputs/embedding-model.tsx
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { ModelOption } from "@/app/api/queries/useGetModelsQuery";
|
||||
import {
|
||||
getFallbackModels,
|
||||
ModelProvider,
|
||||
} from "@/app/settings/helpers/model-helpers";
|
||||
import { ModelSelectItems } from "@/app/settings/helpers/model-select-item";
|
||||
import { LabelWrapper } from "@/components/label-wrapper";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@radix-ui/react-select";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@radix-ui/react-tooltip";
|
||||
|
||||
interface EmbeddingModelInputProps {
|
||||
disabled?: boolean;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
modelsData?: {
|
||||
embedding_models: ModelOption[];
|
||||
};
|
||||
currentProvider?: ModelProvider;
|
||||
}
|
||||
|
||||
export const EmbeddingModelInput = ({
|
||||
disabled,
|
||||
value,
|
||||
onChange,
|
||||
modelsData,
|
||||
currentProvider = "openai",
|
||||
}: EmbeddingModelInputProps) => {
|
||||
return (
|
||||
<LabelWrapper
|
||||
helperText="Model used for knowledge ingest and retrieval"
|
||||
id="embedding-model-select"
|
||||
label="Embedding model"
|
||||
>
|
||||
<Select disabled={disabled} value={value} onValueChange={onChange}>
|
||||
<Tooltip delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<SelectTrigger disabled id="embedding-model-select">
|
||||
<SelectValue placeholder="Select an embedding model" />
|
||||
</SelectTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Locked to keep embeddings consistent</TooltipContent>
|
||||
</Tooltip>
|
||||
<SelectContent>
|
||||
<ModelSelectItems
|
||||
models={modelsData?.embedding_models}
|
||||
fallbackModels={getFallbackModels(currentProvider).embedding}
|
||||
provider={currentProvider}
|
||||
/>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</LabelWrapper>
|
||||
);
|
||||
};
|
||||
74
frontend/components/ui/inputs/number-input.tsx
Normal file
74
frontend/components/ui/inputs/number-input.tsx
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { LabelWrapper } from "@/components/label-wrapper";
|
||||
import { Button } from "../button";
|
||||
import { Input } from "../input";
|
||||
import { Minus, Plus } from "lucide-react";
|
||||
|
||||
interface NumberInputProps {
|
||||
id: string;
|
||||
label: string;
|
||||
value: number;
|
||||
onChange: (value: number) => void;
|
||||
unit: string;
|
||||
min?: number;
|
||||
max?: number;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export const NumberInput = ({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
min = 1,
|
||||
max,
|
||||
disabled,
|
||||
unit,
|
||||
}: NumberInputProps) => {
|
||||
return (
|
||||
<LabelWrapper id={id} label={label}>
|
||||
<div className="relative">
|
||||
<Input
|
||||
id="chunk-size"
|
||||
type="number"
|
||||
disabled={disabled}
|
||||
max={max}
|
||||
min={min}
|
||||
value={value}
|
||||
onChange={(e) => onChange(parseInt(e.target.value) || 0)}
|
||||
className="w-full pr-20 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
|
||||
/>
|
||||
<div className="absolute inset-y-0 right-0 top-0 p-[1px] py-[1.5px] flex items-center ">
|
||||
<span className="text-sm text-placeholder-foreground mr-4 pointer-events-none">
|
||||
{unit}
|
||||
</span>
|
||||
<div className="flex flex-col mt-[2px] mb-[2px]">
|
||||
<Button
|
||||
aria-label={`Increase ${label} value`}
|
||||
className="h-5 rounded-l-none rounded-br-none border-input border-t-transparent border-r-transparent border-b-[0.5px] hover:border-t-[.5px] hover:border-foreground"
|
||||
variant="outline"
|
||||
size="iconSm"
|
||||
onClick={() => onChange(value + 1)}
|
||||
>
|
||||
<Plus
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
size={8}
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
aria-label={`Decrease ${label} value`}
|
||||
className="h-5 rounded-l-none rounded-tr-none border-input border-b-transparent border-r-transparent hover:border-b-1 hover:border-b-[.5px] hover:border-foreground"
|
||||
variant="outline"
|
||||
size="iconSm"
|
||||
onClick={() => onChange(value - 1)}
|
||||
>
|
||||
<Minus
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
size={8}
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</LabelWrapper>
|
||||
);
|
||||
};
|
||||
|
|
@ -6,8 +6,7 @@ import {
|
|||
|
||||
type Nudge = string;
|
||||
|
||||
const DEFAULT_NUDGES = [
|
||||
];
|
||||
const DEFAULT_NUDGES: Nudge[] = [];
|
||||
|
||||
export const useGetNudgesQuery = (
|
||||
chatId?: string | null,
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ function ChatPage() {
|
|||
content: `🔄 Starting upload of **${file.name}**...`,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, uploadStartMessage]);
|
||||
setMessages(prev => [...prev, uploadStartMessage]);
|
||||
|
||||
try {
|
||||
const formData = new FormData();
|
||||
|
|
@ -282,7 +282,7 @@ function ChatPage() {
|
|||
content: `⏳ Upload initiated for **${file.name}**. Processing in background... (Task ID: ${taskId})`,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev.slice(0, -1), pollingMessage]);
|
||||
setMessages(prev => [...prev.slice(0, -1), pollingMessage]);
|
||||
} else if (response.ok) {
|
||||
// Original flow: Direct response
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ function ChatPage() {
|
|||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
setMessages((prev) => [...prev.slice(0, -1), uploadMessage]);
|
||||
setMessages(prev => [...prev.slice(0, -1), uploadMessage]);
|
||||
|
||||
// Add file to conversation docs
|
||||
if (result.filename) {
|
||||
|
|
@ -305,7 +305,7 @@ function ChatPage() {
|
|||
|
||||
// Update the response ID for this endpoint
|
||||
if (result.response_id) {
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[endpoint]: result.response_id,
|
||||
}));
|
||||
|
|
@ -329,7 +329,7 @@ function ChatPage() {
|
|||
content: `❌ Failed to process document. Please try again.`,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev.slice(0, -1), errorMessage]);
|
||||
setMessages(prev => [...prev.slice(0, -1), errorMessage]);
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
setLoading(false);
|
||||
|
|
@ -620,7 +620,7 @@ function ChatPage() {
|
|||
lastLoadedConversationRef.current = conversationData.response_id;
|
||||
|
||||
// Set the previous response ID for this conversation
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[conversationData.endpoint]: conversationData.response_id,
|
||||
}));
|
||||
|
|
@ -662,7 +662,7 @@ function ChatPage() {
|
|||
content: `🔄 Starting upload of **${filename}**...`,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, uploadStartMessage]);
|
||||
setMessages(prev => [...prev, uploadStartMessage]);
|
||||
};
|
||||
|
||||
const handleFileUploaded = (event: CustomEvent) => {
|
||||
|
|
@ -680,11 +680,11 @@ function ChatPage() {
|
|||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
setMessages((prev) => [...prev.slice(0, -1), uploadMessage]);
|
||||
setMessages(prev => [...prev.slice(0, -1), uploadMessage]);
|
||||
|
||||
// Update the response ID for this endpoint
|
||||
if (result.response_id) {
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[endpoint]: result.response_id,
|
||||
}));
|
||||
|
|
@ -711,7 +711,7 @@ function ChatPage() {
|
|||
content: `❌ Upload failed for **${filename}**: ${error}`,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev.slice(0, -1), errorMessage]);
|
||||
setMessages(prev => [...prev.slice(0, -1), errorMessage]);
|
||||
};
|
||||
|
||||
window.addEventListener(
|
||||
|
|
@ -1007,7 +1007,7 @@ function ChatPage() {
|
|||
if (chunk.delta.finish_reason) {
|
||||
console.log("Finish reason:", chunk.delta.finish_reason);
|
||||
// Mark any pending function calls as completed
|
||||
currentFunctionCalls.forEach((fc) => {
|
||||
currentFunctionCalls.forEach(fc => {
|
||||
if (fc.status === "pending" && fc.argumentsString) {
|
||||
try {
|
||||
fc.arguments = JSON.parse(fc.argumentsString);
|
||||
|
|
@ -1040,13 +1040,13 @@ function ChatPage() {
|
|||
|
||||
// Try to find an existing pending call to update (created by earlier deltas)
|
||||
let existing = currentFunctionCalls.find(
|
||||
(fc) => fc.id === chunk.item.id
|
||||
fc => fc.id === chunk.item.id
|
||||
);
|
||||
if (!existing) {
|
||||
existing = [...currentFunctionCalls]
|
||||
.reverse()
|
||||
.find(
|
||||
(fc) =>
|
||||
fc =>
|
||||
fc.status === "pending" &&
|
||||
!fc.id &&
|
||||
fc.name === (chunk.item.tool_name || chunk.item.name)
|
||||
|
|
@ -1077,7 +1077,7 @@ function ChatPage() {
|
|||
currentFunctionCalls.push(functionCall);
|
||||
console.log(
|
||||
"🟢 Function calls now:",
|
||||
currentFunctionCalls.map((fc) => ({
|
||||
currentFunctionCalls.map(fc => ({
|
||||
id: fc.id,
|
||||
name: fc.name,
|
||||
}))
|
||||
|
|
@ -1150,7 +1150,7 @@ function ChatPage() {
|
|||
);
|
||||
console.log(
|
||||
"🔵 Looking for existing function calls:",
|
||||
currentFunctionCalls.map((fc) => ({
|
||||
currentFunctionCalls.map(fc => ({
|
||||
id: fc.id,
|
||||
name: fc.name,
|
||||
}))
|
||||
|
|
@ -1158,7 +1158,7 @@ function ChatPage() {
|
|||
|
||||
// Find existing function call by ID or name
|
||||
const functionCall = currentFunctionCalls.find(
|
||||
(fc) =>
|
||||
fc =>
|
||||
fc.id === chunk.item.id ||
|
||||
fc.name === chunk.item.tool_name ||
|
||||
fc.name === chunk.item.name
|
||||
|
|
@ -1206,7 +1206,7 @@ function ChatPage() {
|
|||
|
||||
// Find existing function call by ID, or by name/type if ID not available
|
||||
const functionCall = currentFunctionCalls.find(
|
||||
(fc) =>
|
||||
fc =>
|
||||
fc.id === chunk.item.id ||
|
||||
fc.name === chunk.item.tool_name ||
|
||||
fc.name === chunk.item.name ||
|
||||
|
|
@ -1261,13 +1261,13 @@ function ChatPage() {
|
|||
|
||||
// Dedupe by id or pending with same name
|
||||
let existing = currentFunctionCalls.find(
|
||||
(fc) => fc.id === chunk.item.id
|
||||
fc => fc.id === chunk.item.id
|
||||
);
|
||||
if (!existing) {
|
||||
existing = [...currentFunctionCalls]
|
||||
.reverse()
|
||||
.find(
|
||||
(fc) =>
|
||||
fc =>
|
||||
fc.status === "pending" &&
|
||||
!fc.id &&
|
||||
fc.name ===
|
||||
|
|
@ -1306,7 +1306,7 @@ function ChatPage() {
|
|||
currentFunctionCalls.push(functionCall);
|
||||
console.log(
|
||||
"🟡 Function calls now:",
|
||||
currentFunctionCalls.map((fc) => ({
|
||||
currentFunctionCalls.map(fc => ({
|
||||
id: fc.id,
|
||||
name: fc.name,
|
||||
type: fc.type,
|
||||
|
|
@ -1404,7 +1404,7 @@ function ChatPage() {
|
|||
};
|
||||
|
||||
if (!controller.signal.aborted && thisStreamId === streamIdRef.current) {
|
||||
setMessages((prev) => [...prev, finalMessage]);
|
||||
setMessages(prev => [...prev, finalMessage]);
|
||||
setStreamingMessage(null);
|
||||
if (previousResponseIds[endpoint]) {
|
||||
cancelNudges();
|
||||
|
|
@ -1417,7 +1417,7 @@ function ChatPage() {
|
|||
!controller.signal.aborted &&
|
||||
thisStreamId === streamIdRef.current
|
||||
) {
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[endpoint]: newResponseId,
|
||||
}));
|
||||
|
|
@ -1445,7 +1445,7 @@ function ChatPage() {
|
|||
"Sorry, I couldn't connect to the chat service. Please try again.",
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, errorMessage]);
|
||||
setMessages(prev => [...prev, errorMessage]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1458,7 +1458,7 @@ function ChatPage() {
|
|||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
setMessages((prev) => [...prev, userMessage]);
|
||||
setMessages(prev => [...prev, userMessage]);
|
||||
setInput("");
|
||||
setLoading(true);
|
||||
setIsFilterHighlighted(false);
|
||||
|
|
@ -1524,14 +1524,14 @@ function ChatPage() {
|
|||
content: result.response,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, assistantMessage]);
|
||||
setMessages(prev => [...prev, assistantMessage]);
|
||||
if (result.response_id) {
|
||||
cancelNudges();
|
||||
}
|
||||
|
||||
// Store the response ID if present for this endpoint
|
||||
if (result.response_id) {
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[endpoint]: result.response_id,
|
||||
}));
|
||||
|
|
@ -1552,7 +1552,7 @@ function ChatPage() {
|
|||
content: "Sorry, I encountered an error. Please try again.",
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, errorMessage]);
|
||||
setMessages(prev => [...prev, errorMessage]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Chat error:", error);
|
||||
|
|
@ -1562,7 +1562,7 @@ function ChatPage() {
|
|||
"Sorry, I couldn't connect to the chat service. Please try again.",
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages((prev) => [...prev, errorMessage]);
|
||||
setMessages(prev => [...prev, errorMessage]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1575,7 +1575,7 @@ function ChatPage() {
|
|||
};
|
||||
|
||||
const toggleFunctionCall = (functionCallId: string) => {
|
||||
setExpandedFunctionCalls((prev) => {
|
||||
setExpandedFunctionCalls(prev => {
|
||||
const newSet = new Set(prev);
|
||||
if (newSet.has(functionCallId)) {
|
||||
newSet.delete(functionCallId);
|
||||
|
|
@ -1632,7 +1632,7 @@ function ChatPage() {
|
|||
|
||||
// Set the response_id we want to continue from as the previous response ID
|
||||
// This tells the backend to continue the conversation from this point
|
||||
setPreviousResponseIds((prev) => ({
|
||||
setPreviousResponseIds(prev => ({
|
||||
...prev,
|
||||
[endpoint]: responseIdToForkFrom,
|
||||
}));
|
||||
|
|
@ -1903,7 +1903,7 @@ function ChatPage() {
|
|||
}
|
||||
|
||||
if (isFilterDropdownOpen) {
|
||||
const filteredFilters = availableFilters.filter((filter) =>
|
||||
const filteredFilters = availableFilters.filter(filter =>
|
||||
filter.name.toLowerCase().includes(filterSearchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
|
|
@ -1921,7 +1921,7 @@ function ChatPage() {
|
|||
|
||||
if (e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
setSelectedFilterIndex((prev) =>
|
||||
setSelectedFilterIndex(prev =>
|
||||
prev < filteredFilters.length - 1 ? prev + 1 : 0
|
||||
);
|
||||
return;
|
||||
|
|
@ -1929,7 +1929,7 @@ function ChatPage() {
|
|||
|
||||
if (e.key === "ArrowUp") {
|
||||
e.preventDefault();
|
||||
setSelectedFilterIndex((prev) =>
|
||||
setSelectedFilterIndex(prev =>
|
||||
prev > 0 ? prev - 1 : filteredFilters.length - 1
|
||||
);
|
||||
return;
|
||||
|
|
@ -2159,7 +2159,7 @@ function ChatPage() {
|
|||
{endpoint === "chat" && (
|
||||
<div className="flex-shrink-0 ml-2">
|
||||
<button
|
||||
onClick={(e) => handleForkConversation(index, e)}
|
||||
onClick={e => handleForkConversation(index, e)}
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity p-1 hover:bg-accent rounded text-muted-foreground hover:text-foreground"
|
||||
title="Fork conversation from here"
|
||||
>
|
||||
|
|
@ -2223,8 +2223,8 @@ function ChatPage() {
|
|||
)}
|
||||
|
||||
{/* Input Area - Fixed at bottom */}
|
||||
<div className="flex-shrink-0 p-6 pb-8 pt-4 flex justify-center">
|
||||
<div className="w-full max-w-[75%]">
|
||||
<div className="pb-8 pt-4 flex px-6">
|
||||
<div className="w-full">
|
||||
<form onSubmit={handleSubmit} className="relative">
|
||||
<div className="relative w-full bg-muted/20 rounded-lg border border-border/50 focus-within:ring-1 focus-within:ring-ring">
|
||||
{selectedFilter && (
|
||||
|
|
@ -2257,7 +2257,7 @@ function ChatPage() {
|
|||
value={input}
|
||||
onChange={onChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
onHeightChange={(height) => setTextareaHeight(height)}
|
||||
onHeightChange={height => setTextareaHeight(height)}
|
||||
maxRows={7}
|
||||
minRows={2}
|
||||
placeholder="Type to ask a question..."
|
||||
|
|
@ -2286,7 +2286,7 @@ function ChatPage() {
|
|||
variant="outline"
|
||||
size="iconSm"
|
||||
className="absolute bottom-3 left-3 h-8 w-8 p-0 rounded-full hover:bg-muted/50"
|
||||
onMouseDown={(e) => {
|
||||
onMouseDown={e => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
onClick={onAtClick}
|
||||
|
|
@ -2296,7 +2296,7 @@ function ChatPage() {
|
|||
</Button>
|
||||
<Popover
|
||||
open={isFilterDropdownOpen}
|
||||
onOpenChange={(open) => {
|
||||
onOpenChange={open => {
|
||||
setIsFilterDropdownOpen(open);
|
||||
}}
|
||||
>
|
||||
|
|
@ -2321,7 +2321,7 @@ function ChatPage() {
|
|||
align="start"
|
||||
sideOffset={6}
|
||||
alignOffset={-18}
|
||||
onOpenAutoFocus={(e) => {
|
||||
onOpenAutoFocus={e => {
|
||||
// Prevent auto focus on the popover content
|
||||
e.preventDefault();
|
||||
// Keep focus on the input
|
||||
|
|
@ -2354,7 +2354,7 @@ function ChatPage() {
|
|||
</button>
|
||||
)}
|
||||
{availableFilters
|
||||
.filter((filter) =>
|
||||
.filter(filter =>
|
||||
filter.name
|
||||
.toLowerCase()
|
||||
.includes(filterSearchTerm.toLowerCase())
|
||||
|
|
@ -2383,7 +2383,7 @@ function ChatPage() {
|
|||
)}
|
||||
</button>
|
||||
))}
|
||||
{availableFilters.filter((filter) =>
|
||||
{availableFilters.filter(filter =>
|
||||
filter.name
|
||||
.toLowerCase()
|
||||
.includes(filterSearchTerm.toLowerCase())
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ export default function ConnectorsPage() {
|
|||
selectedFiles={selectedFiles}
|
||||
isAuthenticated={false} // This would come from auth context in real usage
|
||||
accessToken={undefined} // This would come from connected account
|
||||
isIngesting={isSyncing}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -351,4 +351,17 @@
|
|||
.discord-error {
|
||||
@apply text-xs opacity-70;
|
||||
}
|
||||
|
||||
.box-shadow-inner::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(to top, hsl(var(--background)), transparent);
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function ChunksPageContent() {
|
|||
() =>
|
||||
chunks.reduce((acc, chunk) => acc + chunk.text.length, 0) /
|
||||
chunks.length || 0,
|
||||
[chunks],
|
||||
[chunks]
|
||||
);
|
||||
|
||||
// const [selectAll, setSelectAll] = useState(false);
|
||||
|
|
@ -67,7 +67,7 @@ function ChunksPageContent() {
|
|||
}, []);
|
||||
|
||||
const fileData = (data as File[]).find(
|
||||
(file: File) => file.filename === filename,
|
||||
(file: File) => file.filename === filename
|
||||
);
|
||||
|
||||
// Extract chunks for the specific file
|
||||
|
|
@ -78,18 +78,18 @@ function ChunksPageContent() {
|
|||
}
|
||||
|
||||
setChunks(
|
||||
fileData?.chunks?.map((chunk, i) => ({ ...chunk, index: i + 1 })) || [],
|
||||
fileData?.chunks?.map((chunk, i) => ({ ...chunk, index: i + 1 })) || []
|
||||
);
|
||||
}, [data, filename]);
|
||||
|
||||
// Set selected state for all checkboxes when selectAll changes
|
||||
useEffect(() => {
|
||||
if (selectAll) {
|
||||
setSelectedChunks(new Set(chunks.map((_, index) => index)));
|
||||
} else {
|
||||
setSelectedChunks(new Set());
|
||||
}
|
||||
}, [selectAll, setSelectedChunks, chunks]);
|
||||
// useEffect(() => {
|
||||
// if (selectAll) {
|
||||
// setSelectedChunks(new Set(chunks.map((_, index) => index)));
|
||||
// } else {
|
||||
// setSelectedChunks(new Set());
|
||||
// }
|
||||
// }, [selectAll, setSelectedChunks, chunks]);
|
||||
|
||||
const handleBack = useCallback(() => {
|
||||
router.push("/knowledge");
|
||||
|
|
@ -149,7 +149,7 @@ function ChunksPageContent() {
|
|||
<Checkbox
|
||||
id="selectAllChunks"
|
||||
checked={selectAll}
|
||||
onCheckedChange={(handleSelectAll) =>
|
||||
onCheckedChange={handleSelectAll =>
|
||||
setSelectAll(!!handleSelectAll)
|
||||
}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ function SearchPage() {
|
|||
parsedFilterData
|
||||
);
|
||||
// Convert TaskFiles to File format and merge with backend results
|
||||
const taskFilesAsFiles: File[] = taskFiles.map((taskFile) => {
|
||||
const taskFilesAsFiles: File[] = taskFiles.map(taskFile => {
|
||||
return {
|
||||
filename: taskFile.filename,
|
||||
mimetype: taskFile.mimetype,
|
||||
|
|
@ -82,12 +82,12 @@ function SearchPage() {
|
|||
|
||||
// Create a map of task files by filename for quick lookup
|
||||
const taskFileMap = new Map(
|
||||
taskFilesAsFiles.map((file) => [file.filename, file])
|
||||
taskFilesAsFiles.map(file => [file.filename, file])
|
||||
);
|
||||
|
||||
// Override backend files with task file status if they exist
|
||||
const backendFiles = (searchData as File[])
|
||||
.map((file) => {
|
||||
.map(file => {
|
||||
const taskFile = taskFileMap.get(file.filename);
|
||||
if (taskFile) {
|
||||
// Override backend file with task file data (includes status)
|
||||
|
|
@ -95,17 +95,17 @@ function SearchPage() {
|
|||
}
|
||||
return file;
|
||||
})
|
||||
.filter((file) => {
|
||||
.filter(file => {
|
||||
// Only filter out files that are currently processing AND in taskFiles
|
||||
const taskFile = taskFileMap.get(file.filename);
|
||||
return !taskFile || taskFile.status !== "processing";
|
||||
});
|
||||
|
||||
const filteredTaskFiles = taskFilesAsFiles.filter((taskFile) => {
|
||||
const filteredTaskFiles = taskFilesAsFiles.filter(taskFile => {
|
||||
return (
|
||||
taskFile.status !== "active" &&
|
||||
!backendFiles.some(
|
||||
(backendFile) => backendFile.filename === taskFile.filename
|
||||
backendFile => backendFile.filename === taskFile.filename
|
||||
)
|
||||
);
|
||||
});
|
||||
|
|
@ -184,7 +184,6 @@ function SearchPage() {
|
|||
{
|
||||
field: "avgScore",
|
||||
headerName: "Avg score",
|
||||
initialFlex: 0.5,
|
||||
cellRenderer: ({ value }: CustomCellRendererProps<File>) => {
|
||||
return (
|
||||
<span className="text-xs text-accent-emerald-foreground bg-accent-emerald px-2 py-1 rounded">
|
||||
|
|
@ -246,7 +245,7 @@ function SearchPage() {
|
|||
|
||||
try {
|
||||
// Delete each file individually since the API expects one filename at a time
|
||||
const deletePromises = selectedRows.map((row) =>
|
||||
const deletePromises = selectedRows.map(row =>
|
||||
deleteDocumentMutation.mutateAsync({ filename: row.filename })
|
||||
);
|
||||
|
||||
|
|
@ -345,7 +344,7 @@ function SearchPage() {
|
|||
}? This will remove all chunks and data associated with these documents. This action cannot be undone.
|
||||
|
||||
Documents to be deleted:
|
||||
${selectedRows.map((row) => `• ${row.filename}`).join("\n")}`}
|
||||
${selectedRows.map(row => `• ${row.filename}`).join("\n")}`}
|
||||
confirmText="Delete All"
|
||||
onConfirm={handleBulkDelete}
|
||||
isLoading={deleteDocumentMutation.isPending}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { ArrowUpRight, Loader2, Minus, Plus } from "lucide-react";
|
||||
import { ArrowUpRight, Loader2, Minus, PlugZap, Plus } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Suspense, useCallback, useEffect, useState } from "react";
|
||||
|
|
@ -85,6 +85,7 @@ interface Connector {
|
|||
connectionId?: string;
|
||||
access_token?: string;
|
||||
selectedFiles?: GoogleDriveFile[] | OneDriveFile[];
|
||||
available?: boolean;
|
||||
}
|
||||
|
||||
interface SyncResult {
|
||||
|
|
@ -101,34 +102,6 @@ interface Connection {
|
|||
created_at: string;
|
||||
last_sync?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_CONNECTORS: Connector[] = [
|
||||
{
|
||||
id: "google_drive",
|
||||
name: "Google Drive",
|
||||
description: "Google Drive is not configured.",
|
||||
icon: <GoogleDriveIcon />,
|
||||
status: "not_connected",
|
||||
type: "google_drive",
|
||||
},
|
||||
{
|
||||
id: "one_drive",
|
||||
name: "OneDrive",
|
||||
description: "OneDrive is not configured.",
|
||||
icon: <OneDriveIcon />,
|
||||
status: "not_connected",
|
||||
type: "one_drive",
|
||||
},
|
||||
{
|
||||
id: "amazon_s3",
|
||||
name: "SharePoint",
|
||||
description: "SharePoint is not configured.",
|
||||
icon: <SharePointIcon />,
|
||||
status: "not_connected",
|
||||
type: "sharepoint",
|
||||
},
|
||||
];
|
||||
|
||||
function KnowledgeSourcesPage() {
|
||||
const { isAuthenticated, isNoAuthMode } = useAuth();
|
||||
const { addTask, tasks } = useTask();
|
||||
|
|
@ -169,7 +142,7 @@ function KnowledgeSourcesPage() {
|
|||
{
|
||||
enabled:
|
||||
(isAuthenticated || isNoAuthMode) && currentProvider === "openai",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const { data: ollamaModelsData } = useGetOllamaModelsQuery(
|
||||
|
|
@ -177,7 +150,7 @@ function KnowledgeSourcesPage() {
|
|||
{
|
||||
enabled:
|
||||
(isAuthenticated || isNoAuthMode) && currentProvider === "ollama",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const { data: ibmModelsData } = useGetIBMModelsQuery(
|
||||
|
|
@ -185,7 +158,7 @@ function KnowledgeSourcesPage() {
|
|||
{
|
||||
enabled:
|
||||
(isAuthenticated || isNoAuthMode) && currentProvider === "watsonx",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// Select the appropriate models data based on provider
|
||||
|
|
@ -213,7 +186,7 @@ function KnowledgeSourcesPage() {
|
|||
(variables: Parameters<typeof updateFlowSettingMutation.mutate>[0]) => {
|
||||
updateFlowSettingMutation.mutate(variables);
|
||||
},
|
||||
500,
|
||||
500
|
||||
);
|
||||
|
||||
// Sync system prompt state with settings data
|
||||
|
|
@ -304,16 +277,8 @@ function KnowledgeSourcesPage() {
|
|||
const getConnectorIcon = useCallback((iconName: string) => {
|
||||
const iconMap: { [key: string]: React.ReactElement } = {
|
||||
"google-drive": <GoogleDriveIcon />,
|
||||
sharepoint: (
|
||||
<div className="w-8 h-8 bg-blue-700 rounded flex items-center justify-center text-white font-bold leading-none shrink-0">
|
||||
SP
|
||||
</div>
|
||||
),
|
||||
onedrive: (
|
||||
<div className="w-8 h-8 bg-white border border-gray-300 rounded flex items-center justify-center">
|
||||
<OneDriveIcon />
|
||||
</div>
|
||||
),
|
||||
sharepoint: <SharePointIcon />,
|
||||
onedrive: <OneDriveIcon />,
|
||||
};
|
||||
return (
|
||||
iconMap[iconName] || (
|
||||
|
|
@ -346,6 +311,7 @@ function KnowledgeSourcesPage() {
|
|||
icon: getConnectorIcon(connectorsResult.connectors[type].icon),
|
||||
status: "not_connected" as const,
|
||||
type: type,
|
||||
available: connectorsResult.connectors[type].available,
|
||||
}));
|
||||
|
||||
setConnectors(initialConnectors);
|
||||
|
|
@ -358,7 +324,7 @@ function KnowledgeSourcesPage() {
|
|||
const data = await response.json();
|
||||
const connections = data.connections || [];
|
||||
const activeConnection = connections.find(
|
||||
(conn: Connection) => conn.is_active,
|
||||
(conn: Connection) => conn.is_active
|
||||
);
|
||||
const isConnected = activeConnection !== undefined;
|
||||
|
||||
|
|
@ -370,8 +336,8 @@ function KnowledgeSourcesPage() {
|
|||
status: isConnected ? "connected" : "not_connected",
|
||||
connectionId: activeConnection?.connection_id,
|
||||
}
|
||||
: c,
|
||||
),
|
||||
: c
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -414,7 +380,7 @@ function KnowledgeSourcesPage() {
|
|||
`response_type=code&` +
|
||||
`scope=${result.oauth_config.scopes.join(" ")}&` +
|
||||
`redirect_uri=${encodeURIComponent(
|
||||
result.oauth_config.redirect_uri,
|
||||
result.oauth_config.redirect_uri
|
||||
)}&` +
|
||||
`access_type=offline&` +
|
||||
`prompt=consent&` +
|
||||
|
|
@ -547,7 +513,7 @@ function KnowledgeSourcesPage() {
|
|||
|
||||
const handleEditInLangflow = (
|
||||
flowType: "chat" | "ingest",
|
||||
closeDialog: () => void,
|
||||
closeDialog: () => void
|
||||
) => {
|
||||
// Select the appropriate flow ID and edit URL based on flow type
|
||||
const targetFlowId =
|
||||
|
|
@ -735,13 +701,9 @@ function KnowledgeSourcesPage() {
|
|||
// </div>
|
||||
// </div>
|
||||
}
|
||||
|
||||
{/* Connectors Grid */}
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{DEFAULT_CONNECTORS.map((connector) => {
|
||||
const actualConnector = connectors.find(
|
||||
(c) => c.id === connector.id,
|
||||
);
|
||||
{connectors.map((connector) => {
|
||||
return (
|
||||
<Card key={connector.id} className="relative flex flex-col">
|
||||
<CardHeader>
|
||||
|
|
@ -750,7 +712,7 @@ function KnowledgeSourcesPage() {
|
|||
<div className="mb-1">
|
||||
<div
|
||||
className={`w-8 h-8 ${
|
||||
actualConnector ? "bg-white" : "bg-muted grayscale"
|
||||
connector ? "bg-white" : "bg-muted grayscale"
|
||||
} rounded flex items-center justify-center`}
|
||||
>
|
||||
{connector.icon}
|
||||
|
|
@ -758,20 +720,21 @@ function KnowledgeSourcesPage() {
|
|||
</div>
|
||||
<CardTitle className="flex flex-row items-center gap-2">
|
||||
{connector.name}
|
||||
{actualConnector &&
|
||||
getStatusBadge(actualConnector.status)}
|
||||
{connector && getStatusBadge(connector.status)}
|
||||
</CardTitle>
|
||||
<CardDescription className="text-[13px]">
|
||||
{actualConnector?.description
|
||||
? `${actualConnector.name} is configured.`
|
||||
{connector?.description
|
||||
? `${connector.name} is configured.`
|
||||
: connector.description}
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="flex-1 flex flex-col justify-end space-y-4">
|
||||
{actualConnector?.status === "connected" ? (
|
||||
{connector?.available ? (
|
||||
<div className="space-y-3">
|
||||
{connector?.status === "connected" ? (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => navigateToKnowledgePage(connector)}
|
||||
disabled={isSyncing === connector.id}
|
||||
|
|
@ -781,7 +744,6 @@ function KnowledgeSourcesPage() {
|
|||
<Plus className="h-4 w-4" />
|
||||
Add Knowledge
|
||||
</Button>
|
||||
|
||||
{syncResults[connector.id] && (
|
||||
<div className="text-xs text-muted-foreground bg-muted/50 p-2 rounded">
|
||||
<div>
|
||||
|
|
@ -798,6 +760,27 @@ function KnowledgeSourcesPage() {
|
|||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => handleConnect(connector)}
|
||||
disabled={isConnecting === connector.id}
|
||||
className="w-full cursor-pointer"
|
||||
size="sm"
|
||||
>
|
||||
{isConnecting === connector.id ? (
|
||||
<>
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Connecting...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<PlugZap className="mr-2 h-4 w-4" />
|
||||
Connect
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-[13px] text-muted-foreground">
|
||||
|
|
@ -822,13 +805,8 @@ function KnowledgeSourcesPage() {
|
|||
{/* Agent Behavior Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle className="text-lg mb-4">Agent</CardTitle>
|
||||
<CardDescription>
|
||||
Quick Agent settings. Edit in Langflow for full control.
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<CardTitle className="text-lg">Agent</CardTitle>
|
||||
<div className="flex gap-2">
|
||||
<ConfirmationDialog
|
||||
trigger={
|
||||
|
|
@ -836,7 +814,7 @@ function KnowledgeSourcesPage() {
|
|||
Restore flow
|
||||
</Button>
|
||||
}
|
||||
title="Restore default Retrieval flow"
|
||||
title="Restore default Agent flow"
|
||||
description="This restores defaults and discards all custom settings and overrides. This can’t be undone."
|
||||
confirmText="Restore"
|
||||
variant="destructive"
|
||||
|
|
@ -870,12 +848,12 @@ function KnowledgeSourcesPage() {
|
|||
Edit in Langflow
|
||||
</Button>
|
||||
}
|
||||
title="Edit Retrieval flow in Langflow"
|
||||
title="Edit Agent flow in Langflow"
|
||||
description={
|
||||
<>
|
||||
<p className="mb-2">
|
||||
You're entering Langflow. You can edit the{" "}
|
||||
<b>Retrieval flow</b> and other underlying flows. Manual
|
||||
<b>Agent flow</b> and other underlying flows. Manual
|
||||
changes to components, wiring, or I/O can break this
|
||||
experience.
|
||||
</p>
|
||||
|
|
@ -891,6 +869,9 @@ function KnowledgeSourcesPage() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<CardDescription>
|
||||
This Agent retrieves from your knowledge and generates chat responses. Edit in Langflow for full control.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-6">
|
||||
|
|
@ -903,7 +884,11 @@ function KnowledgeSourcesPage() {
|
|||
>
|
||||
<ModelSelector
|
||||
options={modelsData?.language_models || []}
|
||||
noOptionsPlaceholder={modelsData ? "No language models detected." : "Loading models..."}
|
||||
noOptionsPlaceholder={
|
||||
modelsData
|
||||
? "No language models detected."
|
||||
: "Loading models..."
|
||||
}
|
||||
icon={<OpenAILogo className="w-4 h-4" />}
|
||||
value={modelsData ? settings.agent?.llm_model || "" : ""}
|
||||
onValueChange={handleModelChange}
|
||||
|
|
@ -965,15 +950,10 @@ function KnowledgeSourcesPage() {
|
|||
{/* Knowledge Ingest Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle className="text-lg mb-4">
|
||||
Knowledge ingestion and retrieval
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<CardTitle className="text-lg">
|
||||
Knowledge Ingest
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Quick knowledge settings. Edit in Langflow for full control.
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<ConfirmationDialog
|
||||
trigger={
|
||||
|
|
@ -1036,6 +1016,9 @@ function KnowledgeSourcesPage() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<CardDescription>
|
||||
Configure how files are ingested and stored for retrieval. Edit in Langflow for full control.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-6">
|
||||
|
|
@ -1145,7 +1128,7 @@ function KnowledgeSourcesPage() {
|
|||
size="iconSm"
|
||||
onClick={() =>
|
||||
handleChunkOverlapChange(
|
||||
(chunkOverlap + 1).toString(),
|
||||
(chunkOverlap + 1).toString()
|
||||
)
|
||||
}
|
||||
>
|
||||
|
|
@ -1158,7 +1141,7 @@ function KnowledgeSourcesPage() {
|
|||
size="iconSm"
|
||||
onClick={() =>
|
||||
handleChunkOverlapChange(
|
||||
(chunkOverlap - 1).toString(),
|
||||
(chunkOverlap - 1).toString()
|
||||
)
|
||||
}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -6,8 +6,12 @@ import { useEffect, useState } from "react";
|
|||
import { type CloudFile, UnifiedCloudPicker } from "@/components/cloud-picker";
|
||||
import type { IngestSettings } from "@/components/cloud-picker/types";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Toast } from "@/components/ui/toast";
|
||||
import { useTask } from "@/contexts/task-context";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
|
||||
// CloudFile interface is now imported from the unified cloud picker
|
||||
|
||||
|
|
@ -36,7 +40,7 @@ export default function UploadProviderPage() {
|
|||
const [selectedFiles, setSelectedFiles] = useState<CloudFile[]>([]);
|
||||
const [isIngesting, setIsIngesting] = useState<boolean>(false);
|
||||
const [currentSyncTaskId, setCurrentSyncTaskId] = useState<string | null>(
|
||||
null,
|
||||
null
|
||||
);
|
||||
const [ingestSettings, setIngestSettings] = useState<IngestSettings>({
|
||||
chunkSize: 1000,
|
||||
|
|
@ -63,14 +67,14 @@ export default function UploadProviderPage() {
|
|||
|
||||
if (!providerInfo || !providerInfo.available) {
|
||||
setError(
|
||||
`Cloud provider "${provider}" is not available or configured.`,
|
||||
`Cloud provider "${provider}" is not available or configured.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check connector status
|
||||
const statusResponse = await fetch(
|
||||
`/api/connectors/${provider}/status`,
|
||||
`/api/connectors/${provider}/status`
|
||||
);
|
||||
if (!statusResponse.ok) {
|
||||
throw new Error(`Failed to check ${provider} status`);
|
||||
|
|
@ -80,7 +84,7 @@ export default function UploadProviderPage() {
|
|||
const connections = statusData.connections || [];
|
||||
const activeConnection = connections.find(
|
||||
(conn: { is_active: boolean; connection_id: string }) =>
|
||||
conn.is_active,
|
||||
conn.is_active
|
||||
);
|
||||
const isConnected = activeConnection !== undefined;
|
||||
|
||||
|
|
@ -91,7 +95,7 @@ export default function UploadProviderPage() {
|
|||
if (isConnected && activeConnection) {
|
||||
try {
|
||||
const tokenResponse = await fetch(
|
||||
`/api/connectors/${provider}/token?connection_id=${activeConnection.connection_id}`,
|
||||
`/api/connectors/${provider}/token?connection_id=${activeConnection.connection_id}`
|
||||
);
|
||||
if (tokenResponse.ok) {
|
||||
const tokenData = await tokenResponse.json();
|
||||
|
|
@ -126,7 +130,7 @@ export default function UploadProviderPage() {
|
|||
setError(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Failed to load connector information",
|
||||
: "Failed to load connector information"
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
|
@ -143,7 +147,7 @@ export default function UploadProviderPage() {
|
|||
if (!currentSyncTaskId) return;
|
||||
|
||||
const currentTask = tasks.find(
|
||||
(task) => task.task_id === currentSyncTaskId,
|
||||
(task) => task.task_id === currentSyncTaskId
|
||||
);
|
||||
|
||||
if (currentTask && currentTask.status === "completed") {
|
||||
|
|
@ -326,13 +330,15 @@ export default function UploadProviderPage() {
|
|||
);
|
||||
}
|
||||
|
||||
const hasSelectedFiles = selectedFiles.length > 0;
|
||||
|
||||
return (
|
||||
<div className="container mx-auto max-w-3xl p-6">
|
||||
<div className="mb-6 flex gap-2 items-center">
|
||||
<Button variant="ghost" onClick={() => router.back()}>
|
||||
<ArrowLeft className="h-4 w-4 scale-125" />
|
||||
<div className="container mx-auto max-w-3xl px-6">
|
||||
<div className="mb-8 flex gap-2 items-center">
|
||||
<Button variant="ghost" onClick={() => router.back()} size="icon">
|
||||
<ArrowLeft size={18} />
|
||||
</Button>
|
||||
<h2 className="text-2xl font-bold">
|
||||
<h2 className="text-xl text-[18px] font-semibold">
|
||||
Add from {getProviderDisplayName()}
|
||||
</h2>
|
||||
</div>
|
||||
|
|
@ -345,13 +351,14 @@ export default function UploadProviderPage() {
|
|||
onFileSelected={handleFileSelected}
|
||||
selectedFiles={selectedFiles}
|
||||
isAuthenticated={true}
|
||||
isIngesting={isIngesting}
|
||||
accessToken={accessToken || undefined}
|
||||
clientId={connector.clientId}
|
||||
onSettingsChange={setIngestSettings}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="max-w-3xl mx-auto mt-6">
|
||||
<div className="max-w-3xl mx-auto mt-6 sticky bottom-0 left-0 right-0 pb-6 bg-background pt-4">
|
||||
<div className="flex justify-between gap-3 mb-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
|
@ -360,17 +367,31 @@ export default function UploadProviderPage() {
|
|||
>
|
||||
Back
|
||||
</Button>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="bg-foreground text-background hover:bg-foreground/90 font-semibold"
|
||||
variant={!hasSelectedFiles ? "secondary" : undefined}
|
||||
onClick={() => handleSync(connector)}
|
||||
disabled={selectedFiles.length === 0 || isIngesting}
|
||||
loading={isIngesting}
|
||||
disabled={!hasSelectedFiles || isIngesting}
|
||||
>
|
||||
{isIngesting ? (
|
||||
<>Ingesting {selectedFiles.length} Files...</>
|
||||
{!hasSelectedFiles ? (
|
||||
<>Ingest files</>
|
||||
) : (
|
||||
<>Start ingest</>
|
||||
<>
|
||||
Ingest {selectedFiles.length} file
|
||||
{selectedFiles.length > 1 ? "s" : ""}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
{!hasSelectedFiles ? (
|
||||
<TooltipContent side="left">
|
||||
Select at least one file before ingesting
|
||||
</TooltipContent>
|
||||
) : null}
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ export function CloudConnectorsDialog({
|
|||
accessToken={connectorAccessTokens[connector.type]}
|
||||
onPickerStateChange={() => {}}
|
||||
clientId={connector.clientId}
|
||||
isIngesting={false}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
"use client";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { FileText, Folder, Trash } from "lucide-react";
|
||||
import { FileText, Folder, Trash2 } from "lucide-react";
|
||||
import { CloudFile } from "./types";
|
||||
import GoogleDriveIcon from "@/app/settings/icons/google-drive-icon";
|
||||
import SharePointIcon from "@/app/settings/icons/share-point-icon";
|
||||
import OneDriveIcon from "@/app/settings/icons/one-drive-icon";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
interface FileItemProps {
|
||||
provider: string;
|
||||
file: CloudFile;
|
||||
shouldDisableActions: boolean;
|
||||
onRemove: (fileId: string) => void;
|
||||
}
|
||||
|
||||
|
|
@ -41,27 +46,43 @@ const formatFileSize = (bytes?: number) => {
|
|||
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
export const FileItem = ({ file, onRemove }: FileItemProps) => (
|
||||
const getProviderIcon = (provider: string) => {
|
||||
switch (provider) {
|
||||
case "google_drive":
|
||||
return <GoogleDriveIcon />;
|
||||
case "onedrive":
|
||||
return <OneDriveIcon />;
|
||||
case "sharepoint":
|
||||
return <SharePointIcon />;
|
||||
default:
|
||||
return <FileText className="h-6 w-6" />;
|
||||
}
|
||||
};
|
||||
|
||||
export const FileItem = ({ file, onRemove, provider }: FileItemProps) => (
|
||||
<div
|
||||
key={file.id}
|
||||
className="flex items-center justify-between p-2 rounded-md text-xs"
|
||||
className="flex items-center justify-between p-1.5 rounded-md text-xs"
|
||||
>
|
||||
<div className="flex items-center gap-2 flex-1 min-w-0">
|
||||
{getFileIcon(file.mimeType)}
|
||||
{provider ? getProviderIcon(provider) : getFileIcon(file.mimeType)}
|
||||
<span className="truncate font-medium text-sm mr-2">{file.name}</span>
|
||||
<Badge variant="secondary" className="text-xs px-1 py-0.5 h-auto">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{getMimeTypeLabel(file.mimeType)}
|
||||
</Badge>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-xs text-muted-foreground mr-4" title="file size">
|
||||
{formatFileSize(file.size) || "—"}
|
||||
</span>
|
||||
|
||||
<Trash
|
||||
className="text-muted-foreground w-5 h-5 cursor-pointer hover:text-destructive"
|
||||
<Button
|
||||
className="text-muted-foreground hover:text-destructive"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={() => onRemove(file.id)}
|
||||
/>
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,38 +5,51 @@ import { CloudFile } from "./types";
|
|||
import { FileItem } from "./file-item";
|
||||
|
||||
interface FileListProps {
|
||||
provider: string;
|
||||
files: CloudFile[];
|
||||
onClearAll: () => void;
|
||||
onRemoveFile: (fileId: string) => void;
|
||||
shouldDisableActions: boolean;
|
||||
}
|
||||
|
||||
export const FileList = ({
|
||||
provider,
|
||||
files,
|
||||
onClearAll,
|
||||
onRemoveFile,
|
||||
shouldDisableActions,
|
||||
}: FileListProps) => {
|
||||
if (files.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-2 relative">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-sm font-medium">Added files</p>
|
||||
<p className="text-sm font-medium">Added files ({files.length})</p>
|
||||
<Button
|
||||
ignoreTitleCase={true}
|
||||
onClick={onClearAll}
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="text-sm text-muted-foreground"
|
||||
>
|
||||
Clear all
|
||||
Remove all
|
||||
</Button>
|
||||
</div>
|
||||
<div className="max-h-64 overflow-y-auto space-y-1">
|
||||
{files.map(file => (
|
||||
<FileItem key={file.id} file={file} onRemove={onRemoveFile} />
|
||||
<div className="box-shadow-inner">
|
||||
<div className="max-h-[calc(100vh-720px)] overflow-y-auto space-y-1 pr-1 pb-4 relative">
|
||||
{files.map((file) => (
|
||||
<FileItem
|
||||
key={file.id}
|
||||
file={file}
|
||||
onRemove={onRemoveFile}
|
||||
provider={provider}
|
||||
shouldDisableActions={shouldDisableActions}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +1,28 @@
|
|||
"use client";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleContent,
|
||||
CollapsibleTrigger,
|
||||
} from "@/components/ui/collapsible";
|
||||
import { ChevronRight, Info } from "lucide-react";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { IngestSettings as IngestSettingsType } from "./types";
|
||||
import { LabelWrapper } from "@/components/label-wrapper";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { ModelSelectItems } from "@/app/settings/helpers/model-select-item";
|
||||
import { getFallbackModels } from "@/app/settings/helpers/model-helpers";
|
||||
import { NumberInput } from "@/components/ui/inputs/number-input";
|
||||
|
||||
interface IngestSettingsProps {
|
||||
isOpen: boolean;
|
||||
|
|
@ -44,7 +58,7 @@ export const IngestSettings = ({
|
|||
<Collapsible
|
||||
open={isOpen}
|
||||
onOpenChange={onOpenChange}
|
||||
className="border rounded-md p-4 border-muted-foreground/20"
|
||||
className="border rounded-xl p-4 border-border"
|
||||
>
|
||||
<CollapsibleTrigger className="flex items-center gap-2 justify-between w-full -m-4 p-4 rounded-md transition-colors">
|
||||
<div className="flex items-center gap-2">
|
||||
|
|
@ -58,35 +72,85 @@ export const IngestSettings = ({
|
|||
</CollapsibleTrigger>
|
||||
|
||||
<CollapsibleContent className="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-up-2 data-[state=open]:slide-down-2">
|
||||
<div className="pt-5 space-y-5">
|
||||
<div className="flex items-center gap-4 w-full">
|
||||
<div className="mt-6">
|
||||
{/* Embedding model selection - currently disabled */}
|
||||
<LabelWrapper
|
||||
helperText="Model used for knowledge ingest and retrieval"
|
||||
id="embedding-model-select"
|
||||
label="Embedding model"
|
||||
>
|
||||
<Select
|
||||
// Disabled until API supports multiple embedding models
|
||||
disabled={true}
|
||||
value={currentSettings.embeddingModel}
|
||||
onValueChange={() => {}}
|
||||
>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<SelectTrigger disabled id="embedding-model-select">
|
||||
<SelectValue placeholder="Select an embedding model" />
|
||||
</SelectTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
Locked to keep embeddings consistent
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<SelectContent>
|
||||
<ModelSelectItems
|
||||
models={[
|
||||
{
|
||||
value: "text-embedding-3-small",
|
||||
label: "text-embedding-3-small",
|
||||
},
|
||||
]}
|
||||
fallbackModels={getFallbackModels("openai").embedding}
|
||||
provider={"openai"}
|
||||
/>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</LabelWrapper>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<div className="flex items-center gap-4 w-full mb-6">
|
||||
<div className="w-full">
|
||||
<div className="text-sm mb-2 font-semibold">Chunk size</div>
|
||||
<Input
|
||||
type="number"
|
||||
<NumberInput
|
||||
id="chunk-size"
|
||||
label="Chunk size"
|
||||
value={currentSettings.chunkSize}
|
||||
onChange={e =>
|
||||
handleSettingsChange({
|
||||
chunkSize: parseInt(e.target.value) || 0,
|
||||
})
|
||||
}
|
||||
onChange={(value) => handleSettingsChange({ chunkSize: value })}
|
||||
unit="characters"
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<div className="text-sm mb-2 font-semibold">Chunk overlap</div>
|
||||
<Input
|
||||
type="number"
|
||||
<NumberInput
|
||||
id="chunk-overlap"
|
||||
label="Chunk overlap"
|
||||
value={currentSettings.chunkOverlap}
|
||||
onChange={e =>
|
||||
handleSettingsChange({
|
||||
chunkOverlap: parseInt(e.target.value) || 0,
|
||||
})
|
||||
onChange={(value) =>
|
||||
handleSettingsChange({ chunkOverlap: value })
|
||||
}
|
||||
unit="characters"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 items-center justify-between">
|
||||
{/* <div className="flex gap-2 items-center justify-between">
|
||||
<div>
|
||||
<div className="text-sm font-semibold pb-2">Table Structure</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Capture table structure during ingest.
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
id="table-structure"
|
||||
checked={currentSettings.tableStructure}
|
||||
onCheckedChange={(checked) =>
|
||||
handleSettingsChange({ tableStructure: checked })
|
||||
}
|
||||
/>
|
||||
</div> */}
|
||||
|
||||
<div className="flex items-center justify-between border-b pb-3 mb-3">
|
||||
<div>
|
||||
<div className="text-sm font-semibold pb-2">OCR</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
|
|
@ -95,13 +159,13 @@ export const IngestSettings = ({
|
|||
</div>
|
||||
<Switch
|
||||
checked={currentSettings.ocr}
|
||||
onCheckedChange={checked =>
|
||||
onCheckedChange={(checked) =>
|
||||
handleSettingsChange({ ocr: checked })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 items-center justify-between">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<div className="text-sm pb-2 font-semibold">
|
||||
Picture descriptions
|
||||
|
|
@ -112,26 +176,11 @@ export const IngestSettings = ({
|
|||
</div>
|
||||
<Switch
|
||||
checked={currentSettings.pictureDescriptions}
|
||||
onCheckedChange={checked =>
|
||||
onCheckedChange={(checked) =>
|
||||
handleSettingsChange({ pictureDescriptions: checked })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="text-sm font-semibold pb-2 flex items-center">
|
||||
Embedding model
|
||||
<Info className="w-3.5 h-3.5 text-muted-foreground ml-2" />
|
||||
</div>
|
||||
<Input
|
||||
disabled
|
||||
value={currentSettings.embeddingModel}
|
||||
onChange={e =>
|
||||
handleSettingsChange({ embeddingModel: e.target.value })
|
||||
}
|
||||
placeholder="text-embedding-3-small"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
|
|
|||
|
|
@ -51,19 +51,13 @@ export const PickerHeader = ({
|
|||
Select files from {getProviderName(provider)} to ingest.
|
||||
</p>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={onAddFiles}
|
||||
disabled={!isPickerLoaded || isPickerOpen || !accessToken}
|
||||
className="bg-foreground text-background hover:bg-foreground/90 font-semibold"
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
Add Files
|
||||
{isPickerOpen ? "Opening picker..." : "Add files"}
|
||||
</Button>
|
||||
<div className="text-xs text-muted-foreground pt-4">
|
||||
csv, json, pdf,{" "}
|
||||
<a className="underline dark:text-pink-400 text-pink-600">+16 more</a>{" "}
|
||||
<b>150 MB</b> max
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export interface UnifiedCloudPickerProps {
|
|||
baseUrl?: string;
|
||||
// Ingest settings
|
||||
onSettingsChange?: (settings: IngestSettings) => void;
|
||||
isIngesting: boolean;
|
||||
}
|
||||
|
||||
export interface GoogleAPI {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export const UnifiedCloudPicker = ({
|
|||
onFileSelected,
|
||||
selectedFiles = [],
|
||||
isAuthenticated,
|
||||
isIngesting,
|
||||
accessToken,
|
||||
onPickerStateChange,
|
||||
clientId,
|
||||
|
|
@ -116,7 +117,7 @@ export const UnifiedCloudPicker = ({
|
|||
const handler = createProviderHandler(
|
||||
provider,
|
||||
accessToken,
|
||||
isOpen => {
|
||||
(isOpen) => {
|
||||
setIsPickerOpen(isOpen);
|
||||
onPickerStateChange?.(isOpen);
|
||||
},
|
||||
|
|
@ -126,8 +127,8 @@ export const UnifiedCloudPicker = ({
|
|||
|
||||
handler.openPicker((files: CloudFile[]) => {
|
||||
// Merge new files with existing ones, avoiding duplicates
|
||||
const existingIds = new Set(selectedFiles.map(f => f.id));
|
||||
const newFiles = files.filter(f => !existingIds.has(f.id));
|
||||
const existingIds = new Set(selectedFiles.map((f) => f.id));
|
||||
const newFiles = files.filter((f) => !existingIds.has(f.id));
|
||||
onFileSelected([...selectedFiles, ...newFiles]);
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
@ -138,7 +139,7 @@ export const UnifiedCloudPicker = ({
|
|||
};
|
||||
|
||||
const handleRemoveFile = (fileId: string) => {
|
||||
const updatedFiles = selectedFiles.filter(file => file.id !== fileId);
|
||||
const updatedFiles = selectedFiles.filter((file) => file.id !== fileId);
|
||||
onFileSelected(updatedFiles);
|
||||
};
|
||||
|
||||
|
|
@ -168,7 +169,8 @@ export const UnifiedCloudPicker = ({
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<PickerHeader
|
||||
provider={provider}
|
||||
onAddFiles={handleAddFiles}
|
||||
|
|
@ -177,11 +179,14 @@ export const UnifiedCloudPicker = ({
|
|||
accessToken={accessToken}
|
||||
isAuthenticated={isAuthenticated}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FileList
|
||||
provider={provider}
|
||||
files={selectedFiles}
|
||||
onClearAll={handleClearAll}
|
||||
onRemoveFile={handleRemoveFile}
|
||||
shouldDisableActions={isIngesting}
|
||||
/>
|
||||
|
||||
<IngestSettings
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
|
|||
const isOnKnowledgePage = pathname.startsWith("/knowledge");
|
||||
|
||||
// List of paths with smaller max-width
|
||||
const smallWidthPaths = ["/settings", "/settings/connector/new"];
|
||||
const smallWidthPaths = ["/settings/connector/new"];
|
||||
const isSmallWidthPath = smallWidthPaths.includes(pathname);
|
||||
|
||||
// Calculate active tasks for the bell icon
|
||||
const activeTasks = tasks.filter(
|
||||
(task) =>
|
||||
task =>
|
||||
task.status === "pending" ||
|
||||
task.status === "running" ||
|
||||
task.status === "processing"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import {
|
|||
import { useAuth } from "@/contexts/auth-context";
|
||||
|
||||
// Task interface is now imported from useGetTasksQuery
|
||||
export type { Task };
|
||||
|
||||
export interface TaskFile {
|
||||
filename: string;
|
||||
|
|
|
|||
104
src/api/docling.py
Normal file
104
src/api/docling.py
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
"""Docling service proxy endpoints."""
|
||||
|
||||
import socket
|
||||
import struct
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from utils.container_utils import (
|
||||
detect_container_environment,
|
||||
get_container_host,
|
||||
guess_host_ip_for_containers,
|
||||
)
|
||||
from utils.logging_config import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def _get_gateway_ip_from_route() -> str | None:
|
||||
"""Return the default gateway IP visible from the current network namespace."""
|
||||
try:
|
||||
with Path("/proc/net/route").open() as route_table:
|
||||
next(route_table) # Skip header
|
||||
for line in route_table:
|
||||
fields = line.strip().split()
|
||||
min_fields = 3 # interface, destination, gateway
|
||||
if len(fields) >= min_fields and fields[1] == "00000000":
|
||||
gateway_hex = fields[2]
|
||||
gw_int = int(gateway_hex, 16)
|
||||
gateway_ip = socket.inet_ntoa(struct.pack("<L", gw_int))
|
||||
return gateway_ip
|
||||
except (FileNotFoundError, PermissionError, IndexError, ValueError) as err:
|
||||
logger.warning("Could not read routing table: %s", err)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def determine_docling_host() -> str:
|
||||
"""Determine the host address used for docling health checks."""
|
||||
container_type = detect_container_environment()
|
||||
if container_type:
|
||||
container_host = get_container_host()
|
||||
if container_host:
|
||||
logger.info("Using container-aware host '%s'", container_host)
|
||||
return container_host
|
||||
|
||||
gateway_ip = _get_gateway_ip_from_route()
|
||||
if gateway_ip:
|
||||
logger.info("Detected host gateway IP: %s", gateway_ip)
|
||||
return gateway_ip
|
||||
|
||||
# Either we're not inside a container or gateway detection failed.
|
||||
fallback_ip = guess_host_ip_for_containers(logger=logger)
|
||||
if container_type:
|
||||
logger.info("Falling back to container bridge host %s", fallback_ip)
|
||||
else:
|
||||
logger.info("Running outside a container; using host %s", fallback_ip)
|
||||
return fallback_ip
|
||||
|
||||
|
||||
# Detect the host IP once at startup
|
||||
HOST_IP = determine_docling_host()
|
||||
DOCLING_SERVICE_URL = f"http://{HOST_IP}:5001"
|
||||
|
||||
|
||||
async def health(request: Request) -> JSONResponse:
|
||||
"""
|
||||
Proxy health check to docling-serve.
|
||||
This allows the frontend to check docling status via same-origin request.
|
||||
"""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(
|
||||
f"{DOCLING_SERVICE_URL}/health",
|
||||
timeout=2.0
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
return JSONResponse({
|
||||
"status": "healthy",
|
||||
"host": HOST_IP
|
||||
})
|
||||
else:
|
||||
return JSONResponse({
|
||||
"status": "unhealthy",
|
||||
"message": f"Health check failed with status: {response.status_code}",
|
||||
"host": HOST_IP
|
||||
}, status_code=503)
|
||||
|
||||
except httpx.TimeoutException:
|
||||
return JSONResponse({
|
||||
"status": "unhealthy",
|
||||
"message": "Connection timeout",
|
||||
"host": HOST_IP
|
||||
}, status_code=503)
|
||||
except Exception as e:
|
||||
logger.error("Docling health check failed", error=str(e))
|
||||
return JSONResponse({
|
||||
"status": "unhealthy",
|
||||
"message": str(e),
|
||||
"host": HOST_IP
|
||||
}, status_code=503)
|
||||
Loading…
Add table
Reference in a new issue