diff --git a/app/api/ollama/models/route.ts b/app/api/ollama/models/route.ts index b4c28d9..1cefac7 100644 --- a/app/api/ollama/models/route.ts +++ b/app/api/ollama/models/route.ts @@ -438,7 +438,7 @@ async function probeWindowsPowerShellCandidate(candidate: OllamaProbeCandidate): "-ExecutionPolicy", "Bypass", "-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), tagsUrl(candidate.baseUrl), ], { diff --git a/app/components/InferenceEndpointPanel.tsx b/app/components/InferenceEndpointPanel.tsx index efadac4..6a241f9 100644 --- a/app/components/InferenceEndpointPanel.tsx +++ b/app/components/InferenceEndpointPanel.tsx @@ -28,6 +28,7 @@ type OllamaModel = { id?: string name: string model: string + baseUrl?: string | null modifiedAt: string | null sizeLabel: 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(" + ") : "" } +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({ model, port, @@ -500,11 +510,12 @@ export default function InferenceEndpointPanel() { return () => window.clearInterval(interval) }, [loadOllamaModels]) - function applyOllamaModelPreset(modelName: string) { - setName(OLLAMA_PROVIDER_NAME) + function applyOllamaModelPreset(item: OllamaModel) { + const modelName = item.name + setName(ollamaProviderName(item)) setType("openai") setModel(modelName) - setBaseUrl(OLLAMA_BASE_URL) + setBaseUrl(ollamaOpenAiBaseUrl(item)) setCredentialKey("OPENAI_API_KEY") setApiKey("") setRoute("gateway") @@ -649,7 +660,7 @@ export default function InferenceEndpointPanel() { {ollamaModels.length > 0 ? (