Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update google sites + formik #2834

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export default function AddConnector({
advancedConfiguration.pruneFreq,
advancedConfiguration.indexingStart,
values.access_type == "public",
groups,
name
);
if (response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useField } from "formik";
import { FileUpload } from "@/components/admin/connectors/FileUpload";
import CredentialSubText from "@/components/credentials/CredentialFields";

Expand All @@ -6,18 +7,16 @@ interface FileInputProps {
label: string;
optional?: boolean;
description?: string;
selectedFiles: File[];
setSelectedFiles: (files: File[]) => void;
}

export default function FileInput({
name,
label,
optional = false,
description,
selectedFiles,
setSelectedFiles,
}: FileInputProps) {
const [field, meta, helpers] = useField(name);

return (
<>
<label
Expand All @@ -29,9 +28,14 @@ export default function FileInput({
</label>
{description && <CredentialSubText>{description}</CredentialSubText>}
<FileUpload
selectedFiles={selectedFiles}
setSelectedFiles={setSelectedFiles}
selectedFiles={field.value ? [field.value] : []}
setSelectedFiles={(files: File[]) => {
helpers.setValue(files[0] || null);
}}
/>
{meta.touched && meta.error && (
<div className="text-red-500 text-sm mt-1">{meta.error}</div>
)}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const DynamicConnectionForm: FC<DynamicConnectionFormProps> = ({
label={field.label}
optional={field.optional}
description={field.description}
selectedFiles={selectedFiles}
setSelectedFiles={setSelectedFiles}
/>
) : field.type === "list" ? (
<ListInput field={field} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const submitGoogleSite = async (
pruneFreq: number,
indexingStart: Date,
is_public: boolean,
groups: number[],
name?: string
) => {
const uploadCreateAndTriggerConnector = async () => {
Expand Down Expand Up @@ -56,7 +57,13 @@ export const submitGoogleSite = async (
return false;
}

const credentialResponse = await linkCredential(connector.id, 0, base_url);
const credentialResponse = await linkCredential(
connector.id,
0,
base_url,
undefined,
groups
);
if (!credentialResponse.ok) {
const credentialResponseJson = await credentialResponse.json();
setPopup({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const DocumentSetCreationForm = ({
placeholder="Describe what the document set represents"
autoCompleteDisabled={true}
/>

{isPaidEnterpriseFeaturesEnabled && (
<IsPublicGroupSelector
formikProps={props}
Expand Down
123 changes: 67 additions & 56 deletions web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usePopup } from "@/components/admin/connectors/Popup";
import { HealthCheckBanner } from "@/components/health/healthcheck";

import { EmbeddingModelSelection } from "../EmbeddingModelSelectionForm";
import { useEffect, useState } from "react";
import { useEffect, useMemo, useState } from "react";
import { Button, Card, Text } from "@tremor/react";
import { ArrowLeft, ArrowRight, WarningCircle } from "@phosphor-icons/react";
import {
Expand Down Expand Up @@ -152,6 +152,68 @@ export default function EmbeddingForm() {
}
}, [currentEmbeddingModel]);

const handleReindex = async () => {
const update = await updateSearch();
if (update) {
await onConfirm();
}
};

const needsReIndex =
currentEmbeddingModel != selectedProvider ||
searchSettings?.multipass_indexing !=
advancedEmbeddingDetails.multipass_indexing;

const ReIndexingButton = useMemo(() => {
const ReIndexingButtonComponent = ({
needsReIndex,
}: {
needsReIndex: boolean;
}) => {
return needsReIndex ? (
<div className="flex mx-auto gap-x-1 ml-auto items-center">
<button
className="enabled:cursor-pointer disabled:bg-accent/50 disabled:cursor-not-allowed bg-accent flex gap-x-1 items-center text-white py-2.5 px-3.5 text-sm font-regular rounded-sm"
onClick={handleReindex}
>
Re-index
</button>
<div className="relative group">
<WarningCircle
className="text-text-800 cursor-help"
size={20}
weight="fill"
/>
<div className="absolute z-10 invisible group-hover:visible bg-background-800 text-text-200 text-sm rounded-md shadow-md p-2 right-0 mt-1 w-64">
<p className="font-semibold mb-2">Needs re-indexing due to:</p>
<ul className="list-disc pl-5">
{currentEmbeddingModel != selectedProvider && (
<li>Changed embedding provider</li>
)}
{searchSettings?.multipass_indexing !=
advancedEmbeddingDetails.multipass_indexing && (
<li>Multipass indexing modification</li>
)}
</ul>
</div>
</div>
</div>
) : (
<button
className="enabled:cursor-pointer ml-auto disabled:bg-accent/50 disabled:cursor-not-allowed bg-accent flex mx-auto gap-x-1 items-center text-white py-2.5 px-3.5 text-sm font-regular rounded-sm"
onClick={async () => {
updateSearch();
navigateToEmbeddingPage("search settings");
}}
>
Update Search
</button>
);
};
ReIndexingButtonComponent.displayName = "ReIndexingButton";
return ReIndexingButtonComponent;
}, [needsReIndex]);

if (!selectedProvider) {
return <ThreeDotsLoader />;
}
Expand Down Expand Up @@ -196,12 +258,13 @@ export default function EmbeddingForm() {

// We use a spread operation to merge properties from multiple objects into a single object.
// Advanced embedding details may update default values.
// Do NOT modify the order unless you are positive the new hierarchy is correct.
if (selectedProvider.provider_type != null) {
// This is a cloud model
newModel = {
...selectedProvider,
...rerankingDetails,
...advancedEmbeddingDetails,
...selectedProvider,
provider_type:
(selectedProvider.provider_type
?.toLowerCase()
Expand All @@ -213,10 +276,10 @@ export default function EmbeddingForm() {
...selectedProvider,
...rerankingDetails,
...advancedEmbeddingDetails,
...selectedProvider,
provider_type: null,
};
}

newModel.index_name = null;

const response = await fetch(
Expand All @@ -239,58 +302,6 @@ export default function EmbeddingForm() {
}
};

const needsReIndex =
currentEmbeddingModel != selectedProvider ||
searchSettings?.multipass_indexing !=
advancedEmbeddingDetails.multipass_indexing;

const ReIndexingButton = ({ needsReIndex }: { needsReIndex: boolean }) => {
return needsReIndex ? (
<div className="flex mx-auto gap-x-1 ml-auto items-center">
<button
className="enabled:cursor-pointer disabled:bg-accent/50 disabled:cursor-not-allowed bg-accent flex gap-x-1 items-center text-white py-2.5 px-3.5 text-sm font-regular rounded-sm"
onClick={async () => {
const update = await updateSearch();
if (update) {
await onConfirm();
}
}}
>
Re-index
</button>
<div className="relative group">
<WarningCircle
className="text-text-800 cursor-help"
size={20}
weight="fill"
/>
<div className="absolute z-10 invisible group-hover:visible bg-background-800 text-text-200 text-sm rounded-md shadow-md p-2 right-0 mt-1 w-64">
<p className="font-semibold mb-2">Needs re-indexing due to:</p>
<ul className="list-disc pl-5">
{currentEmbeddingModel != selectedProvider && (
<li>Changed embedding provider</li>
)}
{searchSettings?.multipass_indexing !=
advancedEmbeddingDetails.multipass_indexing && (
<li>Multipass indexing modification</li>
)}
</ul>
</div>
</div>
</div>
) : (
<button
className="enabled:cursor-pointer ml-auto disabled:bg-accent/50 disabled:cursor-not-allowed bg-accent flex mx-auto gap-x-1 items-center text-white py-2.5 px-3.5 text-sm font-regular rounded-sm"
onClick={async () => {
updateSearch();
navigateToEmbeddingPage("search settings");
}}
>
Update Search
</button>
);
};

return (
<div className="mx-auto mb-8 w-full">
{popup}
Expand Down Expand Up @@ -391,7 +402,7 @@ export default function EmbeddingForm() {
/>
</Card>

<div className={` mt-4 w-full grid grid-cols-3`}>
<div className={`mt-4 w-full grid grid-cols-3`}>
<button
className="border-border-dark mr-auto border flex gap-x-1 items-center text-text p-2.5 text-sm font-regular rounded-sm "
onClick={() => prevFormStep()}
Expand Down