@@ -5,7 +5,7 @@ import { configuration } from '../../system/-webview/configuration';
55import type { AIActionType , AIModel } from './models/model' ;
66import type { AIChatMessage , AIRequestResult } from './models/provider' ;
77import { OpenAICompatibleProviderBase } from './openAICompatibleProviderBase' ;
8- import { ensureAccount } from './utils/-webview/ai.utils' ;
8+ import { ensureAccount , ensureOrgConfiguredUrl , getOrgAIProviderOfType } from './utils/-webview/ai.utils' ;
99
1010type OllamaModel = AIModel < typeof provider . id > ;
1111
@@ -20,8 +20,12 @@ export class OllamaProvider extends OpenAICompatibleProviderBase<typeof provider
2020 } ;
2121
2222 override async configured ( silent : boolean ) : Promise < boolean > {
23+ const url = await this . getOrPromptBaseUrl ( silent ) ;
24+ if ( url === undefined ) {
25+ return false ;
26+ }
2327 // Ollama doesn't require an API key, but we'll check if the base URL is reachable
24- return this . validateUrl ( await this . getOrPromptBaseUrl ( silent ) , silent ) ;
28+ return this . validateUrl ( url , silent ) ;
2529 }
2630
2731 override async getApiKey ( silent : boolean ) : Promise < string | undefined > {
@@ -77,7 +81,11 @@ export class OllamaProvider extends OpenAICompatibleProviderBase<typeof provider
7781 return [ ] ;
7882 }
7983
80- private async getOrPromptBaseUrl ( silent : boolean ) : Promise < string > {
84+ private async getOrPromptBaseUrl ( silent : boolean ) : Promise < string | undefined > {
85+ const orgConf = getOrgAIProviderOfType ( this . id ) ;
86+ if ( ! orgConf . enabled ) return undefined ;
87+ if ( orgConf . url ) return orgConf . url ;
88+
8189 let url = configuration . get ( 'ai.ollama.url' ) ?? undefined ;
8290 if ( url ) {
8391 if ( silent ) return url ;
@@ -169,13 +177,14 @@ export class OllamaProvider extends OpenAICompatibleProviderBase<typeof provider
169177 }
170178 }
171179
172- private getBaseUrl ( ) : string {
180+ private getBaseUrl ( ) : string | undefined {
173181 // Get base URL from configuration or use default
174- return configuration . get ( 'ai.ollama.url' ) || defaultBaseUrl ;
182+ return ensureOrgConfiguredUrl ( this . id , configuration . get ( 'ai.ollama.url' ) || defaultBaseUrl ) ;
175183 }
176184
177- protected getUrl ( _model : AIModel < typeof provider . id > ) : string {
178- return `${ this . getBaseUrl ( ) } /api/chat` ;
185+ protected getUrl ( _model : AIModel < typeof provider . id > ) : string | undefined {
186+ const url = this . getBaseUrl ( ) ;
187+ return url ? `${ url } /api/chat` : undefined ;
179188 }
180189
181190 protected override getHeaders < TAction extends AIActionType > (
0 commit comments