File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020import constants
2121from authentication import get_auth_dependency
2222from authentication .interface import AuthTuple
23+ from authorization .azure_token_manager import AzureEntraIDManager
2324from authorization .middleware import authorize
2425from client import AsyncLlamaStackClientHolder
2526from configuration import configuration
@@ -327,6 +328,16 @@ async def _call_llm(
327328 """
328329 client = AsyncLlamaStackClientHolder ().get_client ()
329330 resolved_model_id = model_id or await _get_default_model_id ()
331+
332+ # Handle Azure token refresh if needed
333+ if (
334+ resolved_model_id .startswith ("azure" )
335+ and AzureEntraIDManager ().is_entra_id_configured
336+ and AzureEntraIDManager ().is_token_expired
337+ and AzureEntraIDManager ().refresh_token ()
338+ ):
339+ client = await AsyncLlamaStackClientHolder ().update_azure_token ()
340+
330341 logger .debug ("Using model %s for rlsapi v1 inference" , resolved_model_id )
331342
332343 response = await client .responses .create (
Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ providers:
2222 - provider_id : azure
2323 provider_type : remote::azure
2424 config :
25- api_key : ${env.AZURE_API_KEY}
2625 base_url : https://ols-test.openai.azure.com/openai/v1
2726 api_version : 2024-02-15-preview
2827 allowed_models : ["gpt-4o-mini"]
28+ model_validation : false
2929 - provider_id : openai
3030 provider_type : remote::openai
3131 config :
You can’t perform that action at this time.
0 commit comments