Fix Windows Ollama inference preset routing

This commit is contained in:
mmckeen-nv
2026-05-20 13:14:40 -07:00
parent 150169e5d5
commit 9d0e0e1a16
3 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -438,7 +438,7 @@ async function probeWindowsPowerShellCandidate(candidate: OllamaProbeCandidate):
"-ExecutionPolicy", "-ExecutionPolicy",
"Bypass", "Bypass",
"-Command", "-Command",
"$ProgressPreference = 'SilentlyContinue'; (Invoke-WebRequest -UseBasicParsing -TimeoutSec $args[0] -Uri $args[1]).Content", "& { param([int]$timeoutSec, [string]$uri) $ProgressPreference = 'SilentlyContinue'; (Invoke-WebRequest -UseBasicParsing -TimeoutSec $timeoutSec -Uri $uri).Content }",
String(WINDOWS_CURL_TIMEOUT_SECONDS), String(WINDOWS_CURL_TIMEOUT_SECONDS),
tagsUrl(candidate.baseUrl), tagsUrl(candidate.baseUrl),
], { ], {
+15 -4
View File
@@ -28,6 +28,7 @@ type OllamaModel = {
id?: string id?: string
name: string name: string
model: string model: string
baseUrl?: string | null
modifiedAt: string | null modifiedAt: string | null
sizeLabel: string | null sizeLabel: string | null
family: string | null family: string | null
@@ -92,6 +93,15 @@ function ollamaProbeSummary(labels: unknown) {
return Array.isArray(labels) ? labels.filter((item): item is string => typeof item === "string" && Boolean(item)).join(" + ") : "" return Array.isArray(labels) ? labels.filter((item): item is string => typeof item === "string" && Boolean(item)).join(" + ") : ""
} }
function ollamaOpenAiBaseUrl(item: OllamaModel) {
const baseUrl = typeof item.baseUrl === "string" ? item.baseUrl.trim().replace(/\/+$/, "") : ""
return baseUrl ? `${baseUrl}/v1` : OLLAMA_BASE_URL
}
function ollamaProviderName(item: OllamaModel) {
return item.hostKind === "win" ? "ollama-win" : OLLAMA_PROVIDER_NAME
}
function VllmAdvancedConfiguration({ function VllmAdvancedConfiguration({
model, model,
port, port,
@@ -500,11 +510,12 @@ export default function InferenceEndpointPanel() {
return () => window.clearInterval(interval) return () => window.clearInterval(interval)
}, [loadOllamaModels]) }, [loadOllamaModels])
function applyOllamaModelPreset(modelName: string) { function applyOllamaModelPreset(item: OllamaModel) {
setName(OLLAMA_PROVIDER_NAME) const modelName = item.name
setName(ollamaProviderName(item))
setType("openai") setType("openai")
setModel(modelName) setModel(modelName)
setBaseUrl(OLLAMA_BASE_URL) setBaseUrl(ollamaOpenAiBaseUrl(item))
setCredentialKey("OPENAI_API_KEY") setCredentialKey("OPENAI_API_KEY")
setApiKey("") setApiKey("")
setRoute("gateway") setRoute("gateway")
@@ -649,7 +660,7 @@ export default function InferenceEndpointPanel() {
{ollamaModels.length > 0 ? ( {ollamaModels.length > 0 ? (
<div className="mt-3 grid grid-cols-1 md:grid-cols-2 gap-2"> <div className="mt-3 grid grid-cols-1 md:grid-cols-2 gap-2">
{ollamaModels.map((item) => ( {ollamaModels.map((item) => (
<button key={ollamaModelKey(item)} type="button" onClick={() => applyOllamaModelPreset(item.name)} className={`rounded-sm border p-3 text-left ${isOllamaEndpoint && model === item.name ? "border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]" : "border-[var(--border-subtle)] bg-[var(--background)] hover:border-[var(--nvidia-green)]"}`}> <button key={ollamaModelKey(item)} type="button" onClick={() => applyOllamaModelPreset(item)} className={`rounded-sm border p-3 text-left ${isOllamaEndpoint && model === item.name ? "border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]" : "border-[var(--border-subtle)] bg-[var(--background)] hover:border-[var(--nvidia-green)]"}`}>
<div className="flex min-w-0 items-center gap-2 text-xs font-mono text-[var(--foreground)]"><span className="truncate">{item.name}</span><OllamaHostBadge label={item.hostLabel} /></div> <div className="flex min-w-0 items-center gap-2 text-xs font-mono text-[var(--foreground)]"><span className="truncate">{item.name}</span><OllamaHostBadge label={item.hostLabel} /></div>
<div className="mt-1 text-[11px] text-[var(--foreground-dim)]"> <div className="mt-1 text-[11px] text-[var(--foreground-dim)]">
{[item.parameterSize, item.quantization, item.sizeLabel].filter(Boolean).join(" · ") || item.family || "local model"} {[item.parameterSize, item.quantization, item.sizeLabel].filter(Boolean).join(" · ") || item.family || "local model"}
+6 -4
View File
@@ -234,10 +234,12 @@ assert.doesNotMatch(inferencePanelSource, /nvidia\/NVIDIA-Nemotron-3-Super-120B-
assert.match(inferencePanelSource, /method: "DELETE"/, 'settings UI must expose provider deletion') assert.match(inferencePanelSource, /method: "DELETE"/, 'settings UI must expose provider deletion')
assert.match(inferencePanelSource, /\/api\/ollama\/models/, 'settings UI must poll local Ollama models') assert.match(inferencePanelSource, /\/api\/ollama\/models/, 'settings UI must poll local Ollama models')
assert.match(inferencePanelSource, /window\.setInterval\(\(\) => loadOllamaModels\(\{ silent: true \}\), 10000\)/, 'settings UI must autopoll Ollama while the endpoint panel is open') assert.match(inferencePanelSource, /window\.setInterval\(\(\) => loadOllamaModels\(\{ silent: true \}\), 10000\)/, 'settings UI must autopoll Ollama while the endpoint panel is open')
assert.match(inferencePanelSource, /function applyOllamaModelPreset\(modelName: string\)/, 'settings UI must provide a click preset for local Ollama models') assert.match(inferencePanelSource, /function applyOllamaModelPreset\(item: OllamaModel\)/, 'settings UI must provide a click preset for local Ollama models')
assert.match(inferencePanelSource, /setName\(OLLAMA_PROVIDER_NAME\)[\s\S]*setType\("openai"\)[\s\S]*setModel\(modelName\)[\s\S]*setBaseUrl\(OLLAMA_BASE_URL\)/, 'Ollama model preset must fill provider name, provider type, model, and endpoint URL') assert.match(inferencePanelSource, /function ollamaOpenAiBaseUrl\(item: OllamaModel\)[\s\S]*item\.baseUrl[\s\S]*`\$\{baseUrl\}\/v1`/, 'Ollama preset must derive the OpenAI-compatible endpoint from the discovered model source')
assert.match(inferencePanelSource, /onClick=\{\(\) => applyOllamaModelPreset\(item\.name\)\}/, 'clicking an Ollama model must load the endpoint preset') assert.match(inferencePanelSource, /function ollamaProviderName\(item: OllamaModel\)[\s\S]*item\.hostKind === "win" \? "ollama-win" : OLLAMA_PROVIDER_NAME/, 'Ollama preset must distinguish Windows-host Ollama from local Ollama')
assert.match(inferencePanelSource, /const OLLAMA_BASE_URL = "http:\/\/host\.docker\.internal:11434\/v1"/, 'Ollama preset must use the host-reachable OpenAI-compatible endpoint') assert.match(inferencePanelSource, /setName\(ollamaProviderName\(item\)\)[\s\S]*setType\("openai"\)[\s\S]*setModel\(modelName\)[\s\S]*setBaseUrl\(ollamaOpenAiBaseUrl\(item\)\)/, 'Ollama model preset must fill provider name, provider type, model, and discovered endpoint URL')
assert.match(inferencePanelSource, /onClick=\{\(\) => applyOllamaModelPreset\(item\)\}/, 'clicking an Ollama model must load the endpoint preset')
assert.match(inferencePanelSource, /const OLLAMA_BASE_URL = "http:\/\/host\.docker\.internal:11434\/v1"/, 'Ollama preset must keep a fallback host-reachable OpenAI-compatible endpoint')
assert.match(ollamaModelsRouteSource, /\/api\/tags/, 'Ollama models route must query the Ollama tags API') assert.match(ollamaModelsRouteSource, /\/api\/tags/, 'Ollama models route must query the Ollama tags API')
assert.match(ollamaModelsRouteSource, /OLLAMA_BASE_URL/, 'Ollama models route must support a configurable Ollama base URL') assert.match(ollamaModelsRouteSource, /OLLAMA_BASE_URL/, 'Ollama models route must support a configurable Ollama base URL')
assert.match(sandboxInferenceRouteSource, /parseRoutes/, 'sandbox inference route must accept multiple provider/model routes') assert.match(sandboxInferenceRouteSource, /parseRoutes/, 'sandbox inference route must accept multiple provider/model routes')