mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 21:05:17 +02:00
Enable removal of reranking + navigate back to search settings (#2674)
* k * nit
This commit is contained in:
@@ -79,7 +79,12 @@ const RerankingDetailsForm = forwardRef<
|
|||||||
>
|
>
|
||||||
{({ values, setFieldValue, resetForm }) => {
|
{({ values, setFieldValue, resetForm }) => {
|
||||||
const resetRerankingValues = () => {
|
const resetRerankingValues = () => {
|
||||||
setRerankingDetails(originalRerankingDetails);
|
setRerankingDetails({
|
||||||
|
rerank_api_key: null,
|
||||||
|
rerank_provider_type: null,
|
||||||
|
rerank_model_name: null,
|
||||||
|
rerank_api_url: null,
|
||||||
|
});
|
||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ import {
|
|||||||
} from "@/components/embedding/interfaces";
|
} from "@/components/embedding/interfaces";
|
||||||
import { errorHandlingFetcher } from "@/lib/fetcher";
|
import { errorHandlingFetcher } from "@/lib/fetcher";
|
||||||
import { ErrorCallout } from "@/components/ErrorCallout";
|
import { ErrorCallout } from "@/components/ErrorCallout";
|
||||||
import useSWR, { mutate } from "swr";
|
import useSWR from "swr";
|
||||||
import { ThreeDotsLoader } from "@/components/Loading";
|
import { ThreeDotsLoader } from "@/components/Loading";
|
||||||
import AdvancedEmbeddingFormPage from "./AdvancedEmbeddingFormPage";
|
import AdvancedEmbeddingFormPage from "./AdvancedEmbeddingFormPage";
|
||||||
import {
|
import {
|
||||||
@@ -173,10 +173,9 @@ export default function EmbeddingForm() {
|
|||||||
const response = await updateSearchSettings(values);
|
const response = await updateSearchSettings(values);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: "Updated search settings succesffuly",
|
message: "Updated search settings successfully",
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
mutate("/api/search-settings/get-current-search-settings");
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
setPopup({ message: "Failed to update search settings", type: "error" });
|
setPopup({ message: "Failed to update search settings", type: "error" });
|
||||||
@@ -184,6 +183,17 @@ export default function EmbeddingForm() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 () => {
|
const onConfirm = async () => {
|
||||||
if (!selectedProvider) {
|
if (!selectedProvider) {
|
||||||
return;
|
return;
|
||||||
@@ -227,14 +237,7 @@ export default function EmbeddingForm() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
setPopup({
|
navigateToEmbeddingPage("embedding model");
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
setPopup({ message: "Failed to update embedding model", type: "error" });
|
setPopup({ message: "Failed to update embedding model", type: "error" });
|
||||||
|
|
||||||
@@ -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"
|
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 () => {
|
onClick={async () => {
|
||||||
updateSearch();
|
updateSearch();
|
||||||
|
navigateToEmbeddingPage("search settings");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Update Search
|
Update Search
|
||||||
@@ -405,7 +409,6 @@ export default function EmbeddingForm() {
|
|||||||
<div className="flex w-full justify-end">
|
<div className="flex w-full justify-end">
|
||||||
<button
|
<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`}
|
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={() => {
|
onClick={() => {
|
||||||
nextFormStep();
|
nextFormStep();
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user