OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: Settings UX should let you remove a model provider
Mike Pawlowski89c6354aef7f
diff --git a/frontend/app/api/mutations/useUpdateSettingsMutation.ts b/frontend/app/api/mutations/useUpdateSettingsMutation.tsindex e1a7e9ddf..aa5d933aa 100644--- a/frontend/app/api/mutations/useUpdateSettingsMutation.ts+++ b/frontend/app/api/mutations/useUpdateSettingsMutation.ts@@ -34,6 +34,10 @@ export interface UpdateSettingsRequest {watsonx_endpoint?: string;watsonx_project_id?: string;ollama_endpoint?: string;+ remove_ollama_config?: boolean;+ remove_openai_config?: boolean;+ remove_anthropic_config?: boolean;+ remove_watsonx_config?: boolean;}export interface UpdateSettingsResponse {diff --git a/frontend/app/settings/_components/anthropic-settings-dialog.tsx b/frontend/app/settings/_components/anthropic-settings-dialog.tsxindex 2cc1e2232..55bc4d9a2 100644--- a/frontend/app/settings/_components/anthropic-settings-dialog.tsx+++ b/frontend/app/settings/_components/anthropic-settings-dialog.tsx@@ -6,6 +6,7 @@ import { FormProvider, useForm } from "react-hook-form";import { toast } from "sonner";import { useUpdateSettingsMutation } from "@/app/api/mutations/useUpdateSettingsMutation";import { useGetAnthropicModelsQuery } from "@/app/api/queries/useGetModelsQuery";+import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery";import type { ProviderHealthResponse } from "@/app/api/queries/useProviderHealthQuery";import AnthropicLogo from "@/components/icons/anthropic-logo";import { Button } from "@/components/ui/button";@@ -16,6 +17,13 @@ import {DialogHeader,DialogTitle,} from "@/components/ui/dialog";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { useAuth } from "@/contexts/auth-context";import {AnthropicSettingsForm,type AnthropicSettingsFormData,@@ -28,11 +36,26 @@ const AnthropicSettingsDialog = ({open: boolean;setOpen: (open: boolean) => void;}) => {+ const { isAuthenticated, isNoAuthMode } = useAuth();const queryClient = useQueryClient();const [isValidating, setIsValidating] = useState(false);const [validationError, setValidationError] = useState<Error | null>(null);+ const [showRemoveConfirm, setShowRemoveConfirm] = useState(false);const router = useRouter();+ const { data: settings = {} } = useGetSettingsQuery({+ enabled: isAuthenticated || isNoAuthMode,+ });++ const isAnthropicConfigured =+ settings.providers?.anthropic?.configured === true;++ const canRemoveAnthropic =+ isAnthropicConfigured &&+ (settings.providers?.openai?.configured === true ||+ settings.providers?.watsonx?.configured === true ||+ settings.providers?.ollama?.configured === true);+const methods = useForm<AnthropicSettingsFormData>({mode: "onSubmit",defaultValues: {@@ -78,6 +101,14 @@ const AnthropicSettingsDialog = ({},});+ const removeMutation = useUpdateSettingsMutation({+ onSuccess: () => {+ toast.success("Anthropic configuration removed");+ setShowRemoveConfirm(false);+ setOpen(false);+ },+ });+const onSubmit = async (data: AnthropicSettingsFormData) => {// Clear any previous validation errorssetValidationError(null);@@ -108,7 +139,7 @@ const AnthropicSettingsDialog = ({};return (- <Dialog open={open} onOpenChange={setOpen}>+ <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}><DialogContent className="max-w-2xl"><FormProvider {...methods}><form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">@@ -139,26 +170,89 @@ const AnthropicSettingsDialog = ({</p></motion.div>)}+ {removeMutation.isError && (+ <motion.div+ key="remove-error"+ initial={{ opacity: 0, y: 10 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: -10 }}+ >+ <p className="rounded-lg border border-destructive p-4">+ {removeMutation.error?.message}+ </p>+ </motion.div>+ )}</AnimatePresence>- <DialogFooter className="mt-4">- <Button- variant="outline"- type="button"- onClick={() => setOpen(false)}- >- Cancel- </Button>- <Button- type="submit"- disabled={settingsMutation.isPending || isValidating}- >- {settingsMutation.isPending- ? "Saving..."- : isValidating- ? "Validating..."- : "Save"}- </Button>- </DialogFooter>++ {showRemoveConfirm ? (+ <DialogFooter className="mt-4 flex items-center gap-2 rounded-lg border border-red-500/10 bg-red-500/5 px-4 py-3 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ <div className="border-l-2 border-destructive pl-3 mr-auto text-sm text-red-100">+ Remove configuration?+ </div>+ <Button+ variant="ghost"+ type="button"+ onClick={() => setShowRemoveConfirm(false)}+ >+ Cancel+ </Button>+ <Button+ type="button"+ variant="destructive"+ disabled={removeMutation.isPending}+ onClick={() =>+ removeMutation.mutate({ remove_anthropic_config: true })+ }+ >+ {removeMutation.isPending ? "Removing..." : "Confirm Remove"}+ </Button>+ </DialogFooter>+ ) : (+ <DialogFooter className="mt-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ {isAnthropicConfigured && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="mr-auto">+ <Button+ variant="ghost"+ type="button"+ className="text-destructive hover:text-destructive"+ disabled={!canRemoveAnthropic}+ onClick={() => setShowRemoveConfirm(true)}+ >+ Remove+ </Button>+ </span>+ </TooltipTrigger>+ {!canRemoveAnthropic && (+ <TooltipContent>+ Configure another model provider before removing+ Anthropic+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>+ )}+ <Button+ variant="outline"+ type="button"+ onClick={() => setOpen(false)}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ disabled={settingsMutation.isPending || isValidating}+ >+ {settingsMutation.isPending+ ? "Saving..."+ : isValidating+ ? "Validating..."+ : "Save"}+ </Button>+ </DialogFooter>+ )}</form></FormProvider></DialogContent>diff --git a/frontend/app/settings/_components/ollama-settings-dialog.tsx b/frontend/app/settings/_components/ollama-settings-dialog.tsxindex e0759600e..d079a0a9a 100644--- a/frontend/app/settings/_components/ollama-settings-dialog.tsx+++ b/frontend/app/settings/_components/ollama-settings-dialog.tsx@@ -17,6 +17,12 @@ import {DialogHeader,DialogTitle,} from "@/components/ui/dialog";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";import { useAuth } from "@/contexts/auth-context";import {OllamaSettingsForm,@@ -34,6 +40,7 @@ const OllamaSettingsDialog = ({const queryClient = useQueryClient();const [isValidating, setIsValidating] = useState(false);const [validationError, setValidationError] = useState<Error | null>(null);+ const [showRemoveConfirm, setShowRemoveConfirm] = useState(false);const router = useRouter();const { data: settings = {} } = useGetSettingsQuery({@@ -42,6 +49,13 @@ const OllamaSettingsDialog = ({const isOllamaConfigured = settings.providers?.ollama?.configured === true;+ const otherProviderConfigured =+ settings.providers?.openai?.configured === true ||+ settings.providers?.anthropic?.configured === true ||+ settings.providers?.watsonx?.configured === true;++ const canRemoveOllama = isOllamaConfigured && otherProviderConfigured;+const methods = useForm<OllamaSettingsFormData>({mode: "onSubmit",defaultValues: {@@ -90,6 +104,14 @@ const OllamaSettingsDialog = ({},});+ const removeMutation = useUpdateSettingsMutation({+ onSuccess: () => {+ toast.success("Ollama configuration removed");+ setShowRemoveConfirm(false);+ setOpen(false);+ },+ });+const onSubmit = async (data: OllamaSettingsFormData) => {// Clear any previous validation errorssetValidationError(null);@@ -110,7 +132,7 @@ const OllamaSettingsDialog = ({};return (- <Dialog open={open} onOpenChange={setOpen}>+ <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}><DialogContent className="max-w-2xl"><FormProvider {...methods}><form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">@@ -141,26 +163,89 @@ const OllamaSettingsDialog = ({</p></motion.div>)}+ {removeMutation.isError && (+ <motion.div+ key="remove-error"+ initial={{ opacity: 0, y: 10 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: -10 }}+ >+ <p className="rounded-lg border border-destructive p-4">+ {removeMutation.error?.message}+ </p>+ </motion.div>+ )}</AnimatePresence>- <DialogFooter className="mt-4">- <Button- variant="outline"- type="button"- onClick={() => setOpen(false)}- >- Cancel- </Button>- <Button- type="submit"- disabled={settingsMutation.isPending || isValidating}- >- {settingsMutation.isPending- ? "Saving..."- : isValidating- ? "Validating..."- : "Save"}- </Button>- </DialogFooter>++ {showRemoveConfirm ? (+ <DialogFooter className="mt-4 flex items-center gap-2 rounded-lg border border-red-500/10 bg-red-500/5 px-4 py-3 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ <div className="border-l-2 border-destructive pl-3 mr-auto text-sm text-red-100">+ Remove configuration?+ </div>+ <Button+ variant="ghost"+ type="button"+ onClick={() => setShowRemoveConfirm(false)}+ >+ Cancel+ </Button>+ <Button+ type="button"+ variant="destructive"+ disabled={removeMutation.isPending}+ onClick={() =>+ removeMutation.mutate({ remove_ollama_config: true })+ }+ >+ {removeMutation.isPending ? "Removing..." : "Confirm Remove"}+ </Button>+ </DialogFooter>+ ) : (+ <DialogFooter className="mt-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ {isOllamaConfigured && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="mr-auto">+ <Button+ variant="ghost"+ type="button"+ className="text-destructive hover:text-destructive"+ disabled={!canRemoveOllama}+ onClick={() => setShowRemoveConfirm(true)}+ >+ Remove+ </Button>+ </span>+ </TooltipTrigger>+ {!canRemoveOllama && (+ <TooltipContent>+ Configure another model provider before removing+ Ollama+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>+ )}+ <Button+ variant="outline"+ type="button"+ onClick={() => setOpen(false)}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ disabled={settingsMutation.isPending || isValidating}+ >+ {settingsMutation.isPending+ ? "Saving..."+ : isValidating+ ? "Validating..."+ : "Save"}+ </Button>+ </DialogFooter>+ )}</form></FormProvider></DialogContent>diff --git a/frontend/app/settings/_components/openai-settings-dialog.tsx b/frontend/app/settings/_components/openai-settings-dialog.tsxindex 6d2ba8736..5da4225d3 100644--- a/frontend/app/settings/_components/openai-settings-dialog.tsx+++ b/frontend/app/settings/_components/openai-settings-dialog.tsx@@ -6,6 +6,7 @@ import { FormProvider, useForm } from "react-hook-form";import { toast } from "sonner";import { useUpdateSettingsMutation } from "@/app/api/mutations/useUpdateSettingsMutation";import { useGetOpenAIModelsQuery } from "@/app/api/queries/useGetModelsQuery";+import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery";import type { ProviderHealthResponse } from "@/app/api/queries/useProviderHealthQuery";import OpenAILogo from "@/components/icons/openai-logo";import { Button } from "@/components/ui/button";@@ -16,6 +17,13 @@ import {DialogHeader,DialogTitle,} from "@/components/ui/dialog";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { useAuth } from "@/contexts/auth-context";import {OpenAISettingsForm,type OpenAISettingsFormData,@@ -28,11 +36,25 @@ const OpenAISettingsDialog = ({open: boolean;setOpen: (open: boolean) => void;}) => {+ const { isAuthenticated, isNoAuthMode } = useAuth();const queryClient = useQueryClient();const [isValidating, setIsValidating] = useState(false);const [validationError, setValidationError] = useState<Error | null>(null);+ const [showRemoveConfirm, setShowRemoveConfirm] = useState(false);const router = useRouter();+ const { data: settings = {} } = useGetSettingsQuery({+ enabled: isAuthenticated || isNoAuthMode,+ });++ const isOpenAIConfigured = settings.providers?.openai?.configured === true;++ const canRemoveOpenAI =+ isOpenAIConfigured &&+ (settings.providers?.anthropic?.configured === true ||+ settings.providers?.watsonx?.configured === true ||+ settings.providers?.ollama?.configured === true);+const methods = useForm<OpenAISettingsFormData>({mode: "onSubmit",defaultValues: {@@ -79,6 +101,14 @@ const OpenAISettingsDialog = ({},});+ const removeMutation = useUpdateSettingsMutation({+ onSuccess: () => {+ toast.success("OpenAI configuration removed");+ setShowRemoveConfirm(false);+ setOpen(false);+ },+ });+const onSubmit = async (data: OpenAISettingsFormData) => {// Clear any previous validation errorssetValidationError(null);@@ -109,7 +139,7 @@ const OpenAISettingsDialog = ({};return (- <Dialog open={open} onOpenChange={setOpen}>+ <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}><DialogContent className="max-w-2xl"><FormProvider {...methods}><form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">@@ -140,26 +170,89 @@ const OpenAISettingsDialog = ({</p></motion.div>)}+ {removeMutation.isError && (+ <motion.div+ key="remove-error"+ initial={{ opacity: 0, y: 10 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: -10 }}+ >+ <p className="rounded-lg border border-destructive p-4">+ {removeMutation.error?.message}+ </p>+ </motion.div>+ )}</AnimatePresence>- <DialogFooter className="mt-4">- <Button- variant="outline"- type="button"- onClick={() => setOpen(false)}- >- Cancel- </Button>- <Button- type="submit"- disabled={settingsMutation.isPending || isValidating}- >- {settingsMutation.isPending- ? "Saving..."- : isValidating- ? "Validating..."- : "Save"}- </Button>- </DialogFooter>++ {showRemoveConfirm ? (+ <DialogFooter className="mt-4 flex items-center gap-2 rounded-lg border border-red-500/10 bg-red-500/5 px-4 py-3 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ <div className="border-l-2 border-destructive pl-3 mr-auto text-sm text-red-100">+ Remove configuration?+ </div>+ <Button+ variant="ghost"+ type="button"+ onClick={() => setShowRemoveConfirm(false)}+ >+ Cancel+ </Button>+ <Button+ type="button"+ variant="destructive"+ disabled={removeMutation.isPending}+ onClick={() =>+ removeMutation.mutate({ remove_openai_config: true })+ }+ >+ {removeMutation.isPending ? "Removing..." : "Confirm Remove"}+ </Button>+ </DialogFooter>+ ) : (+ <DialogFooter className="mt-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ {isOpenAIConfigured && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="mr-auto">+ <Button+ variant="ghost"+ type="button"+ className="text-destructive hover:text-destructive"+ disabled={!canRemoveOpenAI}+ onClick={() => setShowRemoveConfirm(true)}+ >+ Remove+ </Button>+ </span>+ </TooltipTrigger>+ {!canRemoveOpenAI && (+ <TooltipContent>+ Configure another model provider before removing+ OpenAI+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>+ )}+ <Button+ variant="outline"+ type="button"+ onClick={() => setOpen(false)}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ disabled={settingsMutation.isPending || isValidating}+ >+ {settingsMutation.isPending+ ? "Saving..."+ : isValidating+ ? "Validating..."+ : "Save"}+ </Button>+ </DialogFooter>+ )}</form></FormProvider></DialogContent>diff --git a/frontend/app/settings/_components/watsonx-settings-dialog.tsx b/frontend/app/settings/_components/watsonx-settings-dialog.tsxindex 1c781272a..2c0e7d557 100644--- a/frontend/app/settings/_components/watsonx-settings-dialog.tsx+++ b/frontend/app/settings/_components/watsonx-settings-dialog.tsx@@ -6,6 +6,7 @@ import { FormProvider, useForm } from "react-hook-form";import { toast } from "sonner";import { useUpdateSettingsMutation } from "@/app/api/mutations/useUpdateSettingsMutation";import { useGetIBMModelsQuery } from "@/app/api/queries/useGetModelsQuery";+import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery";import type { ProviderHealthResponse } from "@/app/api/queries/useProviderHealthQuery";import IBMLogo from "@/components/icons/ibm-logo";import { Button } from "@/components/ui/button";@@ -16,6 +17,13 @@ import {DialogHeader,DialogTitle,} from "@/components/ui/dialog";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { useAuth } from "@/contexts/auth-context";import {WatsonxSettingsForm,type WatsonxSettingsFormData,@@ -28,11 +36,25 @@ const WatsonxSettingsDialog = ({open: boolean;setOpen: (open: boolean) => void;}) => {+ const { isAuthenticated, isNoAuthMode } = useAuth();const queryClient = useQueryClient();const [isValidating, setIsValidating] = useState(false);const [validationError, setValidationError] = useState<Error | null>(null);+ const [showRemoveConfirm, setShowRemoveConfirm] = useState(false);const router = useRouter();+ const { data: settings = {} } = useGetSettingsQuery({+ enabled: isAuthenticated || isNoAuthMode,+ });++ const isWatsonxConfigured = settings.providers?.watsonx?.configured === true;++ const canRemoveWatsonx =+ isWatsonxConfigured &&+ (settings.providers?.openai?.configured === true ||+ settings.providers?.anthropic?.configured === true ||+ settings.providers?.ollama?.configured === true);+const methods = useForm<WatsonxSettingsFormData>({mode: "onSubmit",defaultValues: {@@ -85,6 +107,14 @@ const WatsonxSettingsDialog = ({},});+ const removeMutation = useUpdateSettingsMutation({+ onSuccess: () => {+ toast.success("IBM watsonx.ai configuration removed");+ setShowRemoveConfirm(false);+ setOpen(false);+ },+ });+const onSubmit = async (data: WatsonxSettingsFormData) => {// Clear any previous validation errorssetValidationError(null);@@ -118,7 +148,7 @@ const WatsonxSettingsDialog = ({};return (- <Dialog open={open} onOpenChange={setOpen}>+ <Dialog open={open} onOpenChange={(o) => { setShowRemoveConfirm(false); setOpen(o); }}><DialogContent autoFocus={false} className="max-w-2xl"><FormProvider {...methods}><form onSubmit={handleSubmit(onSubmit)} className="grid gap-4">@@ -149,26 +179,89 @@ const WatsonxSettingsDialog = ({</p></motion.div>)}+ {removeMutation.isError && (+ <motion.div+ key="remove-error"+ initial={{ opacity: 0, y: 10 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: -10 }}+ >+ <p className="rounded-lg border border-destructive p-4">+ {removeMutation.error?.message}+ </p>+ </motion.div>+ )}</AnimatePresence>- <DialogFooter className="mt-4">- <Button- variant="outline"- type="button"- onClick={() => setOpen(false)}- >- Cancel- </Button>- <Button- type="submit"- disabled={settingsMutation.isPending || isValidating}- >- {settingsMutation.isPending- ? "Saving..."- : isValidating- ? "Validating..."- : "Save"}- </Button>- </DialogFooter>++ {showRemoveConfirm ? (+ <DialogFooter className="mt-4 flex items-center gap-2 rounded-lg border border-red-500/10 bg-red-500/5 px-4 py-3 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ <div className="border-l-2 border-destructive pl-3 mr-auto text-sm text-red-100">+ Remove configuration?+ </div>+ <Button+ variant="ghost"+ type="button"+ onClick={() => setShowRemoveConfirm(false)}+ >+ Cancel+ </Button>+ <Button+ type="button"+ variant="destructive"+ disabled={removeMutation.isPending}+ onClick={() =>+ removeMutation.mutate({ remove_watsonx_config: true })+ }+ >+ {removeMutation.isPending ? "Removing..." : "Confirm Remove"}+ </Button>+ </DialogFooter>+ ) : (+ <DialogFooter className="mt-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-150">+ {isWatsonxConfigured && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="mr-auto">+ <Button+ variant="ghost"+ type="button"+ className="text-destructive hover:text-destructive"+ disabled={!canRemoveWatsonx}+ onClick={() => setShowRemoveConfirm(true)}+ >+ Remove+ </Button>+ </span>+ </TooltipTrigger>+ {!canRemoveWatsonx && (+ <TooltipContent>+ Configure another model provider before removing IBM+ watsonx.ai+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>+ )}+ <Button+ variant="outline"+ type="button"+ onClick={() => setOpen(false)}+ >+ Cancel+ </Button>+ <Button+ type="submit"+ disabled={settingsMutation.isPending || isValidating}+ >+ {settingsMutation.isPending+ ? "Saving..."+ : isValidating+ ? "Validating..."+ : "Save"}+ </Button>+ </DialogFooter>+ )}</form></FormProvider></DialogContent>diff --git a/src/api/settings.py b/src/api/settings.pyindex 6b6c31607..c89695311 100644--- a/src/api/settings.py+++ b/src/api/settings.py@@ -55,6 +55,10 @@ class SettingsUpdateBody(BaseModel):watsonx_endpoint: Optional[str] = Field(None, min_length=1)watsonx_project_id: Optional[str] = Field(None, min_length=1)ollama_endpoint: Optional[str] = Field(None, min_length=1)+ remove_ollama_config: Optional[bool] = None+ remove_openai_config: Optional[bool] = None+ remove_anthropic_config: Optional[bool] = None+ remove_watsonx_config: Optional[bool] = Noneclass OnboardingBody(BaseModel):@@ -361,6 +365,22 @@ async def get_settings()+def _first_configured_llm_provider(config, excluding: str) -> str:+ """Return the first configured LLM provider that isn't `excluding`."""+ for p in ["openai", "anthropic", "watsonx", "ollama"]:+ if p != excluding and getattr(config.providers, p).configured:+ return p+ return "openai"+++def _first_configured_embedding_provider(config, excluding: str) -> str:+ """Return the first configured embedding provider (openai/watsonx/ollama) that isn't `excluding`."""+ for p in ["openai", "watsonx", "ollama"]:+ if p != excluding and getattr(config.providers, p).configured:+ return p+ return "openai"++async def update_settings(body: SettingsUpdateBody,session_manager=Depends(get_session_manager),@@ -673,6 +693,99 @@ async def update_settings(config_updated = Trueprovider_updated = True+ if body.remove_ollama_config:+ other_providers_configured = (+ current_config.providers.openai.configured+ or current_config.providers.anthropic.configured+ or current_config.providers.watsonx.configured+ )+ if not other_providers_configured:+ return JSONResponse(+ {"error": "Cannot remove Ollama configuration: configure another model provider first."},+ status_code=400,+ )+ current_config.providers.ollama.endpoint = ""+ current_config.providers.ollama.configured = False+ if current_config.agent.llm_provider == "ollama":+ current_config.agent.llm_provider = _first_configured_llm_provider(current_config, "ollama")+ current_config.agent.llm_model = ""+ if current_config.knowledge.embedding_provider == "ollama":+ current_config.knowledge.embedding_provider = _first_configured_embedding_provider(current_config, "ollama")+ current_config.knowledge.embedding_model = ""+ config_updated = True+ provider_updated = True++ if body.remove_openai_config:+ other_providers_configured = (+ current_config.providers.anthropic.configured+ or current_config.providers.watsonx.configured+ or current_config.providers.ollama.configured+ )+ if not other_providers_configured:+ return JSONResponse(+ {"error": "Cannot remove OpenAI configuration: configure another model provider first."},+ status_code=400,+ )+ current_config.providers.openai.api_key = ""+ current_config.providers.openai.configured = False+ if current_config.agent.llm_provider == "openai":+ fb = _first_configured_llm_provider(current_config, "openai")+ current_config.agent.llm_provider = fb+ current_config.agent.llm_model = ""+ if current_config.knowledge.embedding_provider == "openai":+ fb = _first_configured_embedding_provider(current_config, "openai")+ current_config.knowledge.embedding_provider = fb+ current_config.knowledge.embedding_model = ""+ config_updated = True+ provider_updated = True++ if body.remove_anthropic_config:+ other_providers_configured = (+ current_config.providers.openai.configured+ or current_config.providers.watsonx.configured+ or current_config.providers.ollama.configured+ )+ if not other_providers_configured:+ return JSONResponse(+ {"error": "Cannot remove Anthropic configuration: configure another model provider first."},+ status_code=400,+ )+ current_config.providers.anthropic.api_key = ""+ current_config.providers.anthropic.configured = False+ if current_config.agent.llm_provider == "anthropic":+ fb = _first_configured_llm_provider(current_config, "anthropic")+ current_config.agent.llm_provider = fb+ current_config.agent.llm_model = ""+ # Anthropic is not a valid embedding provider; no embedding reset needed+ config_updated = True+ provider_updated = True++ if body.remove_watsonx_config:+ other_providers_configured = (+ current_config.providers.openai.configured+ or current_config.providers.anthropic.configured+ or current_config.providers.ollama.configured+ )+ if not other_providers_configured:+ return JSONResponse(+ {"error": "Cannot remove IBM watsonx.ai configuration: configure another model provider first."},+ status_code=400,+ )+ current_config.providers.watsonx.api_key = ""+ current_config.providers.watsonx.endpoint = ""+ current_config.providers.watsonx.project_id = ""+ current_config.providers.watsonx.configured = False+ if current_config.agent.llm_provider == "watsonx":+ fb = _first_configured_llm_provider(current_config, "watsonx")+ current_config.agent.llm_provider = fb+ current_config.agent.llm_model = ""+ if current_config.knowledge.embedding_provider == "watsonx":+ fb = _first_configured_embedding_provider(current_config, "watsonx")+ current_config.knowledge.embedding_provider = fb+ current_config.knowledge.embedding_model = ""+ config_updated = True+ provider_updated = True+if provider_updated:await TelemetryClient.send_event(Category.SETTINGS_OPERATIONS,@@ -693,7 +806,7 @@ async def update_settings(# Update Langflow global variables and model values if provider settings changedawait clients.refresh_patched_client()- if should_validate:+ if should_validate or provider_updated:try:flows_service = _get_flows_service()@@ -706,8 +819,8 @@ async def update_settings(current_config, session_manager)- # Update model values if provider or model changed- if body.llm_provider is not None or body.llm_model is not None or body.embedding_provider is not None or body.embedding_model is not None:+ # Update model values if provider or model changed (including removals that trigger fallback)+ if body.llm_provider is not None or body.llm_model is not None or body.embedding_provider is not None or body.embedding_model is not None or provider_updated:await _update_langflow_model_values(current_config, flows_service)except Exception as e: