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

Enable removal of reranking + navigate back to search settings #2674

Merged
merged 2 commits into from
Oct 6, 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
7 changes: 6 additions & 1 deletion web/src/app/admin/embeddings/RerankingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ const RerankingDetailsForm = forwardRef<
>
{({ values, setFieldValue, resetForm }) => {
const resetRerankingValues = () => {
setRerankingDetails(originalRerankingDetails);
setRerankingDetails({
rerank_api_key: null,
rerank_provider_type: null,
rerank_model_name: null,
rerank_api_url: null,
});
resetForm();
};

Expand Down
27 changes: 15 additions & 12 deletions web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "@/components/embedding/interfaces";
import { errorHandlingFetcher } from "@/lib/fetcher";
import { ErrorCallout } from "@/components/ErrorCallout";
import useSWR, { mutate } from "swr";
import useSWR from "swr";
import { ThreeDotsLoader } from "@/components/Loading";
import AdvancedEmbeddingFormPage from "./AdvancedEmbeddingFormPage";
import {
Expand Down Expand Up @@ -173,17 +173,27 @@ export default function EmbeddingForm() {
const response = await updateSearchSettings(values);
if (response.ok) {
setPopup({
message: "Updated search settings succesffuly",
message: "Updated search settings successfully",
type: "success",
});
mutate("/api/search-settings/get-current-search-settings");
return true;
} else {
setPopup({ message: "Failed to update search settings", type: "error" });
return false;
}
};

const navigateToEmbeddingPage = (changedResource: string) => {
setPopup({
message: `Changed ${changedResource} successfully. Redirecting to embedding page`,
type: "success",
});

setTimeout(() => {
window.open("/admin/configuration/search", "_self");
}, 2000);
};

const onConfirm = async () => {
if (!selectedProvider) {
return;
Expand Down Expand Up @@ -227,14 +237,7 @@ export default function EmbeddingForm() {
);

if (response.ok) {
setPopup({
message: "Changed provider successfully. Redirecting to embedding page",
type: "success",
});
mutate("/api/search-settings/get-secondary-search-settings");
setTimeout(() => {
window.open("/admin/configuration/search", "_self");
}, 2000);
navigateToEmbeddingPage("embedding model");
} else {
setPopup({ message: "Failed to update embedding model", type: "error" });

Expand Down Expand Up @@ -286,6 +289,7 @@ export default function EmbeddingForm() {
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
Expand Down Expand Up @@ -405,7 +409,6 @@ export default function EmbeddingForm() {
<div className="flex w-full justify-end">
<button
className={`enabled:cursor-pointer enabled:hover:underline disabled:cursor-not-allowed mt-auto enabled:text-text-600 disabled:text-text-400 ml-auto flex gap-x-1 items-center py-2.5 px-3.5 text-sm font-regular rounded-sm`}
// disabled={!isFormValid}
onClick={() => {
nextFormStep();
}}
Expand Down
Loading