55
66from azure .ai .projects .aio import AIProjectClient
77from azure .cosmos .aio import CosmosClient
8- from azure . identity import DefaultAzureCredential
8+ from helpers . azure_credential_utils import get_azure_credential
99from dotenv import load_dotenv
1010from semantic_kernel .kernel import Kernel
1111
@@ -106,23 +106,6 @@ def _get_bool(self, name: str) -> bool:
106106 """
107107 return name in os .environ and os .environ [name ].lower () in ["true" , "1" ]
108108
109- def get_azure_credentials (self ):
110- """Get Azure credentials using DefaultAzureCredential.
111-
112- Returns:
113- DefaultAzureCredential instance for Azure authentication
114- """
115- # Cache the credentials object
116- if self ._azure_credentials is not None :
117- return self ._azure_credentials
118-
119- try :
120- self ._azure_credentials = DefaultAzureCredential ()
121- return self ._azure_credentials
122- except Exception as exc :
123- logging .warning ("Failed to create DefaultAzureCredential: %s" , exc )
124- return None
125-
126109 def get_cosmos_database_client (self ):
127110 """Get a Cosmos DB client for the configured database.
128111
@@ -132,7 +115,7 @@ def get_cosmos_database_client(self):
132115 try :
133116 if self ._cosmos_client is None :
134117 self ._cosmos_client = CosmosClient (
135- self .COSMOSDB_ENDPOINT , credential = self . get_azure_credentials ()
118+ self .COSMOSDB_ENDPOINT , credential = get_azure_credential ()
136119 )
137120
138121 if self ._cosmos_database is None :
@@ -169,10 +152,10 @@ def get_ai_project_client(self):
169152 return self ._ai_project_client
170153
171154 try :
172- credential = self . get_azure_credentials ()
155+ credential = get_azure_credential ()
173156 if credential is None :
174157 raise RuntimeError (
175- "Unable to acquire Azure credentials; ensure DefaultAzureCredential is configured"
158+ "Unable to acquire Azure credentials; ensure Managed Identity is configured"
176159 )
177160
178161 endpoint = self .AZURE_AI_AGENT_ENDPOINT
@@ -183,6 +166,22 @@ def get_ai_project_client(self):
183166 logging .error ("Failed to create AIProjectClient: %s" , exc )
184167 raise
185168
169+ def get_user_local_browser_language (self ) -> str :
170+ """Get the user's local browser language from environment variables.
171+
172+ Returns:
173+ The user's local browser language or 'en-US' if not set
174+ """
175+ return self ._get_optional ("USER_LOCAL_BROWSER_LANGUAGE" , "en-US" )
176+
177+ def set_user_local_browser_language (self , language : str ):
178+ """Set the user's local browser language in environment variables.
179+
180+ Args:
181+ language: The language code to set (e.g., 'en-US')
182+ """
183+ os .environ ["USER_LOCAL_BROWSER_LANGUAGE" ] = language
184+
186185
187186# Create a global instance of AppConfig
188187config = AppConfig ()
0 commit comments