Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix(sampling): restrict sampler UI and params to local/custom providers
Akarshan7c7d0e2b480b
diff --git a/web-app/src/containers/SamplerPopover.tsx b/web-app/src/containers/SamplerPopover.tsxindex c19dd4536..e002c154d 100644--- a/web-app/src/containers/SamplerPopover.tsx+++ b/web-app/src/containers/SamplerPopover.tsx@@ -32,6 +32,7 @@ import { ParametersSection } from '@/containers/ParametersSection'import { useAssistant } from '@/hooks/useAssistant'import { useModelProvider } from '@/hooks/useModelProvider'import { paramsSettings, type ParamDef } from '@/lib/predefinedParams'+import { isPredefinedRemoteProvider } from '@/lib/providerCaps'import { cn } from '@/lib/utils'interface SamplerPopoverProps {@@ -116,6 +117,8 @@ export function SamplerPopover({writeParams(next)}+ if (isPredefinedRemoteProvider(providerId)) return null+const triggerLabel = currentAssistant? `Sampling — ${currentAssistant.name}`: 'Sampling'diff --git a/web-app/src/lib/custom-chat-transport.ts b/web-app/src/lib/custom-chat-transport.tsindex 1939d1114..76b45f56d 100644--- a/web-app/src/lib/custom-chat-transport.ts+++ b/web-app/src/lib/custom-chat-transport.ts@@ -36,6 +36,8 @@ import { mcpOrchestrator } from '@/lib/mcp-orchestrator'import { isRouterModelSelectable } from '@/lib/mcp-router-model-filter'import { encodeAudioSentinel, parseAudioDataUrl } from '@/lib/audio-sentinel'import { extractFilesFromPrompt, type FileMetadata } from '@/lib/fileMetadata'+import { isPredefinedRemoteProvider } from '@/lib/providerCaps'+import { paramsSettings } from '@/lib/predefinedParams'export type TokenUsageCallback = (usage: LanguageModelUsage,@@ -864,14 +866,18 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {// Create the model before refreshing tools so the MCP orchestrator can run// structured LLM routing when many servers are connected.+ const mergedParams: Record<string, unknown> = {+ ...modelSamplingDefaults,+ ...(inferenceParams ?? {}),+ ...reasoningParams,+ }+ if (isPredefinedRemoteProvider(effectiveProviderName)) {+ for (const key of Object.keys(paramsSettings)) delete mergedParams[key]+ }this.model = await ModelFactory.createModel(modelId,updatedProvider ?? provider,- {- ...modelSamplingDefaults,- ...(inferenceParams ?? {}),- ...reasoningParams,- }+ mergedParams)useAppState.getState().updateLoadingModel(false)useAppState.getState().updateThreadLoadingModel(threadId, false)diff --git a/web-app/src/lib/providerCaps.ts b/web-app/src/lib/providerCaps.tsindex 5211ac320..6a2790588 100644--- a/web-app/src/lib/providerCaps.ts+++ b/web-app/src/lib/providerCaps.ts@@ -164,6 +164,22 @@ export function resolveProviderCaps(return BUILTIN_CAPS[id] ?? CUSTOM_PERMISSIVE}+const LOCAL_PROVIDER_IDS = new Set<string>(['llamacpp', 'mlx'])++/**+ * Predefined remote providers ship locked base_urls and expose only a fixed+ * sampling surface — exposing the in-app sampler UI for them invites silent+ * 400s. Local engines and user-added custom OpenAI-compatible providers keep+ * the sampler UI.+ */+export function isPredefinedRemoteProvider(+ provider: Pick<ProviderObject, 'provider'> | string | undefined+): boolean {+ if (!provider) return false+ const id = typeof provider === 'string' ? provider : provider.provider+ return id in BUILTIN_CAPS && !LOCAL_PROVIDER_IDS.has(id)+}+/*** Sampler keys that some model families reject outright even when the* provider's API surface accepts them. Indexed by sampler capability — the