@@ -134,7 +134,7 @@ import {
134134import { MEDIA_PROVIDERS } from '../media/models' ;
135135import { useByokImageModelOptions , useByokVideoModelOptions , useByokSpeechModelOptions } from '../media/aihubmix-image-models' ;
136136import { isVisualStabilityMode } from '../utils/visualStability' ;
137- import { byokProviderRequiresApiKey } from '../utils/byokProvider' ;
137+ import { byokProviderRequiresApiKey , isLocalOllamaBaseUrl } from '../utils/byokProvider' ;
138138import { XaiOAuthControl } from './XaiOAuthControl' ;
139139import type { MediaProvider } from '../media/models' ;
140140import { Toast } from './Toast' ;
@@ -698,11 +698,11 @@ export function canFetchProviderModels(
698698 config : Pick < AppConfig , 'apiKey' | 'baseUrl' > ,
699699 protocol : ApiProtocol ,
700700) : boolean {
701+ const isLocalOllama = protocol === 'ollama' && isLocalOllamaBaseUrl ( config . baseUrl ) ;
701702 return (
702703 ! isProviderModelDiscoveryUnsupported ( protocol , config . baseUrl ) &&
703704 protocol !== 'azure' &&
704- protocol !== 'ollama' &&
705- ( protocol === 'bedrock' || Boolean ( config . apiKey . trim ( ) ) ) &&
705+ ( protocol === 'bedrock' || isLocalOllama || Boolean ( config . apiKey . trim ( ) ) ) &&
706706 Boolean ( config . baseUrl . trim ( ) ) &&
707707 isValidApiBaseUrl ( config . baseUrl )
708708 ) ;
@@ -712,7 +712,10 @@ export function isProviderModelDiscoveryUnsupported(
712712 protocol : ApiProtocol ,
713713 baseUrl : string ,
714714) : boolean {
715- if ( protocol === 'azure' || protocol === 'ollama' ) return true ;
715+ if ( protocol === 'azure' ) return true ;
716+ // Ollama model discovery (GET /api/tags) is a local-only capability; Ollama
717+ // Cloud (ollama.com) does not expose it.
718+ if ( protocol === 'ollama' ) return ! isLocalOllamaBaseUrl ( baseUrl ) ;
716719 try {
717720 const host = new URL ( baseUrl ) . hostname . toLowerCase ( ) ;
718721 return host === 'token-plan-cn.xiaomimimo.com' ;
@@ -1842,7 +1845,7 @@ export function SettingsDialog({
18421845 if (
18431846 initial . mode !== 'api' ||
18441847 protocol === 'azure' ||
1845- protocol === 'ollama' ||
1848+ ( protocol === 'ollama' && ! isLocalOllamaBaseUrl ( initial . baseUrl ) ) ||
18461849 missingByokModelFetchFields ( initial , protocol ) . length > 0 ||
18471850 ! isValidApiBaseUrl ( initial . baseUrl )
18481851 ) {
@@ -2733,7 +2736,7 @@ export function SettingsDialog({
27332736 }
27342737 return ;
27352738 }
2736- if ( apiProtocol === 'ollama' ) {
2739+ if ( apiProtocol === 'ollama' && ! isLocalOllamaBaseUrl ( cfg . baseUrl ) ) {
27372740 trackModelsFetchResult ( {
27382741 result : 'failed' ,
27392742 error_code : 'unsupported_ollama' ,
@@ -3514,11 +3517,9 @@ export function SettingsDialog({
35143517 ) ;
35153518 const providerModelDiscoveryUnavailable =
35163519 apiProtocol !== 'azure' &&
3517- apiProtocol !== 'ollama' &&
35183520 isProviderModelDiscoveryUnsupported ( apiProtocol , cfg . baseUrl ) ;
35193521 const providerModelDiscoverySupported =
35203522 apiProtocol !== 'azure' &&
3521- apiProtocol !== 'ollama' &&
35223523 ! providerModelDiscoveryUnavailable ;
35233524 const fetchedApiModelOptions =
35243525 providerModelDiscoveryUnavailable
0 commit comments