-
{getTitle()}
-
- {isAutoMode ? (
-
-
+ {/* Header */}
+
+
+
+
{getTitle()}
+ {isAutoMode && (
+
Recommended
- ) : isGlobal ? (
-
-
+ )}
+ {isGlobal && !isAutoMode && mode !== "create" && (
+
Global
- ) : null}
- {config && !isAutoMode && (
- {config.model_name}
)}
+
{getSubtitle()}
+ {config && !isAutoMode && mode !== "create" && (
+
{config.model_name}
+ )}
+
onOpenChange(false)}
+ className="absolute right-4 top-4 h-8 w-8 rounded-full text-muted-foreground hover:text-foreground"
+ >
+
+ Close
+
- onOpenChange(false)}
- className="h-8 w-8 rounded-full"
- >
-
- Close
-
-
- {/* Content */}
-
-
- {/* Auto mode */}
+ {/* Scrollable content */}
+
{isAutoMode && (
- <>
-
-
-
- Auto mode distributes image generation requests across all configured
- providers for optimal performance and rate limit protection.
-
-
-
- onOpenChange(false)}
- >
- Close
-
-
- {isSubmitting ? "Loading..." : "Use Auto Mode"}
-
-
- >
+
+
+ Auto mode distributes image generation requests across all configured
+ providers for optimal performance and rate limit protection.
+
+
)}
- {/* Global config (read-only) */}
{isGlobal && !isAutoMode && config && (
<>
-
+
Global configurations are read-only. To customize, create a new model.
@@ -372,29 +342,11 @@ export function ImageConfigSidebar({
-
- onOpenChange(false)}
- >
- Close
-
-
- {isSubmitting ? "Loading..." : "Use This Model"}
-
-
>
)}
- {/* Create / Edit form */}
{(mode === "create" || (mode === "edit" && !isGlobal)) && (
- {/* Name */}
Name *
- {/* Description */}
Description
- {/* Provider */}
Provider *
-
+
{IMAGE_GEN_PROVIDERS.map((p) => (
-
-
- {p.label}
- {p.example}
-
+
+ {p.label}
))}
- {/* Model Name */}
Model Name *
{suggestedModels.length > 0 ? (
@@ -452,14 +398,14 @@ export function ImageConfigSidebar({
{formData.model_name || "Select or type a model..."}
-
-
+
+
- {/* API Key */}
-
- API Key *
-
+ API Key *
- {/* API Base */}
API Base URL
- {/* Azure API Version */}
{formData.provider === "AZURE_OPENAI" && (
API Version (Azure)
@@ -549,28 +490,54 @@ export function ImageConfigSidebar({
/>
)}
-
- {/* Actions */}
-
- onOpenChange(false)}
- >
- Cancel
-
-
- {isSubmitting ? : null}
- {mode === "edit" ? "Save Changes" : "Create & Use"}
-
-
)}
+
+ {/* Fixed footer */}
+
+ onOpenChange(false)}
+ disabled={isSubmitting}
+ className="text-sm h-9"
+ >
+ Cancel
+
+ {(mode === "create" || (mode === "edit" && !isGlobal)) ? (
+
+ {isSubmitting ? (
+ <>
+
+ {mode === "edit" ? "Saving" : "Creating"}
+ >
+ ) : (
+ mode === "edit" ? "Save Changes" : "Create & Use"
+ )}
+
+ ) : isAutoMode ? (
+
+ {isSubmitting ? "Loading..." : "Use Auto Mode"}
+
+ ) : isGlobal && config ? (
+
+ {isSubmitting ? "Loading..." : "Use This Model"}
+
+ ) : null}
+
>
@@ -578,5 +545,5 @@ export function ImageConfigSidebar({
);
- return typeof document !== "undefined" ? createPortal(sidebarContent, document.body) : null;
+ return typeof document !== "undefined" ? createPortal(dialogContent, document.body) : null;
}
diff --git a/surfsense_web/components/new-chat/model-config-dialog.tsx b/surfsense_web/components/new-chat/model-config-dialog.tsx
index 0d58786be..6b91290c1 100644
--- a/surfsense_web/components/new-chat/model-config-dialog.tsx
+++ b/surfsense_web/components/new-chat/model-config-dialog.tsx
@@ -18,6 +18,7 @@ import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import type {
GlobalNewLLMConfig,
+ LiteLLMProvider,
NewLLMConfigPublic,
} from "@/contracts/types/new-llm-config.types";
import { cn } from "@/lib/utils";
@@ -408,10 +409,10 @@ export function ModelConfigDialog({
initialData={{
name: config.name,
description: config.description,
- provider: config.provider,
+ provider: config.provider as LiteLLMProvider,
custom_provider: config.custom_provider,
model_name: config.model_name,
- api_key: config.api_key,
+ api_key: "api_key" in config ? (config.api_key as string) : "",
api_base: config.api_base,
litellm_params: config.litellm_params,
system_instructions: config.system_instructions,
@@ -430,14 +431,14 @@ export function ModelConfigDialog({
{/* Fixed footer */}
- onOpenChange(false)}
- disabled={isSubmitting}
- className="text-sm h-9"
- >
- Cancel
+ onOpenChange(false)}
+ disabled={isSubmitting}
+ className="text-sm h-9"
+ >
+ Cancel
{(mode === "create" || (!isGlobal && !isAutoMode && config)) ? (
- {mode === "edit" ? "Saving..." : "Creating..."}
+ {mode === "edit" ? "Saving" : "Creating"}
>
) : (
mode === "edit" ? "Save Changes" : "Create & Use"