Warn users of gpu-sensitive operation (#2488)

* warn users of gpu-sensitive operation

* update copy
This commit is contained in:
pablodanswer
2024-09-17 14:59:43 -07:00
committed by GitHub
parent 75c9b1cafe
commit 18fbe9d7e8
5 changed files with 57 additions and 1 deletions

View File

@@ -1,9 +1,16 @@
import React, { Dispatch, forwardRef, SetStateAction, useState } from "react";
import React, {
Dispatch,
forwardRef,
SetStateAction,
useContext,
useState,
} from "react";
import { Formik, Form, FormikProps } from "formik";
import * as Yup from "yup";
import {
RerankerProvider,
RerankingDetails,
RerankingModel,
rerankingModels,
} from "./interfaces";
import { FiExternalLink } from "react-icons/fi";
@@ -15,6 +22,7 @@ import {
import { Modal } from "@/components/Modal";
import { Button } from "@tremor/react";
import { TextFormField } from "@/components/admin/connectors/Field";
import { SettingsContext } from "@/components/settings/SettingsProvider";
interface RerankingDetailsFormProps {
setRerankingDetails: Dispatch<SetStateAction<RerankingDetails>>;
@@ -38,10 +46,15 @@ const RerankingDetailsForm = forwardRef<
},
ref
) => {
const [showGpuWarningModalModel, setShowGpuWarningModalModel] =
useState<RerankingModel | null>(null);
const [isApiKeyModalOpen, setIsApiKeyModalOpen] = useState(false);
const [showLiteLLMConfigurationModal, setShowLiteLLMConfigurationModal] =
useState(false);
const combinedSettings = useContext(SettingsContext);
const gpuEnabled = combinedSettings?.settings.gpu_enabled;
return (
<Formik
innerRef={ref}
@@ -169,6 +182,11 @@ const RerankingDetailsForm = forwardRef<
RerankerProvider.LITELLM
) {
setShowLiteLLMConfigurationModal(true);
} else if (
!card.rerank_provider_type &&
!gpuEnabled
) {
setShowGpuWarningModalModel(card);
}
if (!isSelected) {
@@ -225,6 +243,33 @@ const RerankingDetailsForm = forwardRef<
})}
</div>
{showGpuWarningModalModel && (
<Modal
onOutsideClick={() => setShowGpuWarningModalModel(null)}
width="w-[500px] flex flex-col"
title="GPU Not Enabled"
>
<>
<p className="text-error font-semibold">Warning:</p>
<p>
Local reranking models require significant computational
resources and may perform slowly without GPU
acceleration. Consider switching to GPU-enabled
infrastructure or using a cloud-based alternative for
better performance.
</p>
<div className="flex justify-end">
<Button
onClick={() => setShowGpuWarningModalModel(null)}
color="blue"
size="xs"
>
Understood
</Button>
</div>
</>
</Modal>
)}
{showLiteLLMConfigurationModal && (
<Modal
onOutsideClick={() => {

View File

@@ -5,6 +5,7 @@ export interface Settings {
maximum_chat_retention_days: number | null;
notifications: Notification[];
needs_reindexing: boolean;
gpu_enabled: boolean;
}
export interface Notification {

View File

@@ -42,6 +42,7 @@ export async function fetchSettingsSS(): Promise<CombinedSettings | null> {
if (!results[0].ok) {
if (results[0].status === 403) {
settings = {
gpu_enabled: false,
chat_page_enabled: true,
search_page_enabled: true,
default_page: "search",