@@ -43,7 +43,7 @@ import {
4343 CONDITIONS_KEY_NAME ,
4444 CLIENT_FILTERS_KEY_NAME
4545} from "./featureManagement/constants.js" ;
46- import { FM_PACKAGE_NAME , AI_MIME_PROFILE , AI_CHAT_COMPLETION_MIME_PROFILE } from "./requestTracing/constants.js" ;
46+ import { FM_PACKAGE_NAME , AI_MIME_PROFILE , AI_CHAT_COMPLETION_MIME_PROFILE , AZURE_AI_PACKAGE_NAMES } from "./requestTracing/constants.js" ;
4747import { parseContentType , isJsonContentType , isFeatureFlagContentType , isSecretReferenceContentType } from "./common/contentType.js" ;
4848import { AzureKeyVaultKeyValueAdapter } from "./keyvault/keyVaultKeyValueAdapter.js" ;
4949import { RefreshTimer } from "./refresh/refreshTimer.js" ;
@@ -86,6 +86,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
8686 #fmVersion: string | undefined ;
8787 #aiConfigurationTracing: AIConfigurationTracingOptions | undefined ;
8888 #useSnapshotReference: boolean = false ;
89+ #useAzureAI: boolean = false ;
8990
9091 // Refresh
9192 #refreshInProgress: boolean = false ;
@@ -218,7 +219,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
218219 featureFlagTracing : this . #featureFlagTracing,
219220 fmVersion : this . #fmVersion,
220221 aiConfigurationTracing : this . #aiConfigurationTracing,
221- useSnapshotReference : this . #useSnapshotReference
222+ useSnapshotReference : this . #useSnapshotReference,
223+ useAzureAI : this . #useAzureAI
222224 } ;
223225 }
224226
@@ -384,6 +386,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
384386 async #initializeWithRetryPolicy( abortSignal : AbortSignal ) : Promise < void > {
385387 if ( ! this . #isInitialLoadCompleted) {
386388 await this . #inspectFmPackage( ) ;
389+ await this . #inspectAzureAIPackages( ) ;
387390 const startTimestamp = Date . now ( ) ;
388391 let postAttempts = 0 ;
389392 do { // at least try to load once
@@ -437,6 +440,23 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
437440 }
438441 }
439442
443+ /**
444+ * Inspects whether Azure AI packages are installed.
445+ */
446+ async #inspectAzureAIPackages( ) {
447+ if ( this . #requestTracingEnabled && ! this . #useAzureAI) {
448+ for ( const packageName of AZURE_AI_PACKAGE_NAMES ) {
449+ try {
450+ await import ( /* @vite -ignore */ packageName ) ;
451+ this . #useAzureAI = true ;
452+ break ; // Found one package, no need to check others
453+ } catch {
454+ // Package not installed, continue checking
455+ }
456+ }
457+ }
458+ }
459+
440460 async #refreshTasks( ) : Promise < void > {
441461 const refreshTasks : Promise < boolean > [ ] = [ ] ;
442462 if ( this . #refreshEnabled || this . #secretRefreshEnabled) {
0 commit comments