mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-28 13:53:28 +02:00
Add ingestion as a "Source" for the FE + improve typing (#2312)
This commit is contained in:
@@ -22,7 +22,7 @@ import AdvancedFormPage from "./pages/Advanced";
|
|||||||
import DynamicConnectionForm from "./pages/DynamicConnectorCreationForm";
|
import DynamicConnectionForm from "./pages/DynamicConnectorCreationForm";
|
||||||
import CreateCredential from "@/components/credentials/actions/CreateCredential";
|
import CreateCredential from "@/components/credentials/actions/CreateCredential";
|
||||||
import ModifyCredential from "@/components/credentials/actions/ModifyCredential";
|
import ModifyCredential from "@/components/credentials/actions/ModifyCredential";
|
||||||
import { ValidSources } from "@/lib/types";
|
import { ConfigurableSources, ValidSources } from "@/lib/types";
|
||||||
import { Credential, credentialTemplates } from "@/lib/connectors/credentials";
|
import { Credential, credentialTemplates } from "@/lib/connectors/credentials";
|
||||||
import {
|
import {
|
||||||
ConnectionConfiguration,
|
ConnectionConfiguration,
|
||||||
@@ -54,7 +54,7 @@ export type AdvancedConfigFinal = {
|
|||||||
export default function AddConnector({
|
export default function AddConnector({
|
||||||
connector,
|
connector,
|
||||||
}: {
|
}: {
|
||||||
connector: ValidSources;
|
connector: ConfigurableSources;
|
||||||
}) {
|
}) {
|
||||||
const [currentCredential, setCurrentCredential] =
|
const [currentCredential, setCurrentCredential] =
|
||||||
useState<Credential<any> | null>(null);
|
useState<Credential<any> | null>(null);
|
||||||
@@ -195,7 +195,7 @@ export default function AddConnector({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// google sites-specific handling
|
// google sites-specific handling
|
||||||
if (connector == "google_site") {
|
if (connector == "google_sites") {
|
||||||
const response = await submitGoogleSite(
|
const response = await submitGoogleSite(
|
||||||
selectedFiles,
|
selectedFiles,
|
||||||
formValues?.base_url,
|
formValues?.base_url,
|
||||||
@@ -443,7 +443,10 @@ export default function AddConnector({
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!(connector == "google_drive") && createConnectorToggle && (
|
{/* NOTE: connector will never be google_drive, since the ternary above will
|
||||||
|
prevent that, but still keeping this here for safety in case the above changes. */}
|
||||||
|
{(connector as ValidSources) !== "google_drive" &&
|
||||||
|
createConnectorToggle && (
|
||||||
<Modal
|
<Modal
|
||||||
className="max-w-3xl rounded-lg"
|
className="max-w-3xl rounded-lg"
|
||||||
onOutsideClick={() => setCreateConnectorToggle(false)}
|
onOutsideClick={() => setCreateConnectorToggle(false)}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ValidSources } from "@/lib/types";
|
import { ConfigurableSources, ValidSources } from "@/lib/types";
|
||||||
import AddConnector from "./AddConnectorPage";
|
import AddConnector from "./AddConnectorPage";
|
||||||
import { FormProvider } from "@/components/context/FormContext";
|
import { FormProvider } from "@/components/context/FormContext";
|
||||||
import Sidebar from "./Sidebar";
|
import Sidebar from "./Sidebar";
|
||||||
@@ -8,7 +8,11 @@ import { HeaderTitle } from "@/components/header/HeaderTitle";
|
|||||||
import { Button } from "@tremor/react";
|
import { Button } from "@tremor/react";
|
||||||
import { isValidSource } from "@/lib/sources";
|
import { isValidSource } from "@/lib/sources";
|
||||||
|
|
||||||
export default function ConnectorWrapper({ connector }: { connector: string }) {
|
export default function ConnectorWrapper({
|
||||||
|
connector,
|
||||||
|
}: {
|
||||||
|
connector: ConfigurableSources;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<FormProvider connector={connector}>
|
<FormProvider connector={connector}>
|
||||||
<div className="flex justify-center w-full h-full">
|
<div className="flex justify-center w-full h-full">
|
||||||
@@ -28,7 +32,7 @@ export default function ConnectorWrapper({ connector }: { connector: string }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<AddConnector connector={connector as ValidSources} />
|
<AddConnector connector={connector} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { ConfigurableSources } from "@/lib/types";
|
||||||
import ConnectorWrapper from "./ConnectorWrapper";
|
import ConnectorWrapper from "./ConnectorWrapper";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
@@ -5,5 +6,9 @@ export default async function Page({
|
|||||||
}: {
|
}: {
|
||||||
params: { connector: string };
|
params: { connector: string };
|
||||||
}) {
|
}) {
|
||||||
return <ConnectorWrapper connector={params.connector.replace("-", "_")} />;
|
return (
|
||||||
|
<ConnectorWrapper
|
||||||
|
connector={params.connector.replace("-", "_") as ConfigurableSources}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -465,7 +465,10 @@ export function CCPairIndexingStatusTable({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{sortedSources
|
{sortedSources
|
||||||
.filter((source) => source != "not_applicable")
|
.filter(
|
||||||
|
(source) =>
|
||||||
|
source != "not_applicable" && source != "ingestion_api"
|
||||||
|
)
|
||||||
.map((source, ind) => {
|
.map((source, ind) => {
|
||||||
const sourceMatches = source
|
const sourceMatches = source
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
|
@@ -1,30 +1,9 @@
|
|||||||
import { getSourceMetadataForSources, listSourceMetadata } from "@/lib/sources";
|
import { getSourceMetadataForSources } from "@/lib/sources";
|
||||||
import { ValidSources } from "@/lib/types";
|
import { ValidSources } from "@/lib/types";
|
||||||
import Image from "next/image";
|
|
||||||
import { Persona } from "../admin/assistants/interfaces";
|
import { Persona } from "../admin/assistants/interfaces";
|
||||||
import { Divider } from "@tremor/react";
|
import { Divider } from "@tremor/react";
|
||||||
import { FiBookmark, FiCpu, FiInfo, FiX, FiZoomIn } from "react-icons/fi";
|
import { FiBookmark, FiInfo } from "react-icons/fi";
|
||||||
import { HoverPopup } from "@/components/HoverPopup";
|
import { HoverPopup } from "@/components/HoverPopup";
|
||||||
import { Modal } from "@/components/Modal";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { Logo } from "@/components/Logo";
|
|
||||||
|
|
||||||
const MAX_PERSONAS_TO_DISPLAY = 4;
|
|
||||||
|
|
||||||
function HelperItemDisplay({
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
}: {
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="cursor-pointer hover:bg-hover-light border border-border rounded py-2 px-4">
|
|
||||||
<div className="text-emphasis font-bold text-lg flex">{title}</div>
|
|
||||||
<div className="text-sm">{description}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ChatIntro({
|
export function ChatIntro({
|
||||||
availableSources,
|
availableSources,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ValidInputTypes, ValidSources } from "../types";
|
import { ConfigurableSources, ValidInputTypes, ValidSources } from "../types";
|
||||||
|
|
||||||
export type InputType =
|
export type InputType =
|
||||||
| "list"
|
| "list"
|
||||||
@@ -76,7 +76,10 @@ export interface ConnectionConfiguration {
|
|||||||
overrideDefaultFreq?: number;
|
overrideDefaultFreq?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const connectorConfigs: Record<ValidSources, ConnectionConfiguration> = {
|
export const connectorConfigs: Record<
|
||||||
|
ConfigurableSources,
|
||||||
|
ConnectionConfiguration
|
||||||
|
> = {
|
||||||
web: {
|
web: {
|
||||||
description: "Configure Web connector",
|
description: "Configure Web connector",
|
||||||
values: [
|
values: [
|
||||||
|
@@ -288,6 +288,7 @@ export const credentialTemplates: Record<ValidSources, any> = {
|
|||||||
mediawiki: null,
|
mediawiki: null,
|
||||||
web: null,
|
web: null,
|
||||||
not_applicable: null,
|
not_applicable: null,
|
||||||
|
ingestion_api: null,
|
||||||
|
|
||||||
// NOTE: These are Special Cases
|
// NOTE: These are Special Cases
|
||||||
google_drive: { google_drive_tokens: "" } as GoogleDriveCredentialJson,
|
google_drive: { google_drive_tokens: "" } as GoogleDriveCredentialJson,
|
||||||
|
@@ -272,6 +272,11 @@ const SOURCE_METADATA_MAP: SourceMap = {
|
|||||||
category: SourceCategory.Storage,
|
category: SourceCategory.Storage,
|
||||||
docs: "https://docs.danswer.dev/connectors/google_storage",
|
docs: "https://docs.danswer.dev/connectors/google_storage",
|
||||||
},
|
},
|
||||||
|
ingestion_api: {
|
||||||
|
icon: GlobeIcon,
|
||||||
|
displayName: "Ingestion",
|
||||||
|
category: SourceCategory.Other,
|
||||||
|
},
|
||||||
// currently used for the Internet Search tool docs, which is why
|
// currently used for the Internet Search tool docs, which is why
|
||||||
// a globe is used
|
// a globe is used
|
||||||
not_applicable: {
|
not_applicable: {
|
||||||
@@ -302,8 +307,12 @@ export function getSourceMetadata(sourceType: ValidSources): SourceMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function listSourceMetadata(): SourceMetadata[] {
|
export function listSourceMetadata(): SourceMetadata[] {
|
||||||
|
/* This gives back all the viewable / common sources, primarily for
|
||||||
|
display in the Add Connector page */
|
||||||
const entries = Object.entries(SOURCE_METADATA_MAP)
|
const entries = Object.entries(SOURCE_METADATA_MAP)
|
||||||
.filter(([source, _]) => source !== "not_applicable")
|
.filter(
|
||||||
|
([source, _]) => source !== "not_applicable" && source != "ingestion_api"
|
||||||
|
)
|
||||||
.map(([source, metadata]) => {
|
.map(([source, metadata]) => {
|
||||||
return fillSourceMetadata(metadata, source as ValidSources);
|
return fillSourceMetadata(metadata, source as ValidSources);
|
||||||
});
|
});
|
||||||
|
@@ -237,6 +237,12 @@ const validSources = [
|
|||||||
"google_cloud_storage",
|
"google_cloud_storage",
|
||||||
"oci_storage",
|
"oci_storage",
|
||||||
"not_applicable",
|
"not_applicable",
|
||||||
];
|
"ingestion_api",
|
||||||
|
] as const;
|
||||||
|
|
||||||
export type ValidSources = (typeof validSources)[number];
|
export type ValidSources = (typeof validSources)[number];
|
||||||
|
// The valid sources that are actually valid to select in the UI
|
||||||
|
export type ConfigurableSources = Exclude<
|
||||||
|
ValidSources,
|
||||||
|
"not_applicable" | "ingestion_api"
|
||||||
|
>;
|
||||||
|
Reference in New Issue
Block a user