1515from azure .search .documents import SearchClient
1616from azure .search .documents .indexes import SearchIndexClient
1717from azure .storage .filedatalake import DataLakeServiceClient
18- # Removed: from azure.ai.projects import AIProjectClient
18+ # Removed: from openai import AzureOpenAI (migrated to Azure AI Foundry)
19+ from azure .ai .projects import AIProjectClient
1920from content_understanding_client import AzureContentUnderstandingClient
2021from azure_credential_utils import get_azure_credential
2122
@@ -61,7 +62,7 @@ def __init__(self, endpoint: str, credential, project_name: str):
6162
6263 def _get_headers (self ) -> Dict [str , str ]:
6364 """Get authorization headers for API calls."""
64- token = self .credential .get_token ('https://ai .azure.com/.default' ).token
65+ token = self .credential .get_token ('https://ml .azure.com/.default' ).token
6566 return {
6667 'Authorization' : f'Bearer { token } ' ,
6768 'Content-Type' : 'application/json'
@@ -613,4 +614,20 @@ def get_mined_topic_mapping(input_text, list_of_topics):
613614conn .close ()
614615logger .info ("=== COMPLETED 03_cu_process_data_text.py SUCCESSFULLY ===" )
615616logger .info ("All steps completed. SQL connection closed." )
616- print ("All steps completed. Connection closed." )
617+ print ("All steps completed. Connection closed." )
618+
619+ # Initialize Azure AI Foundry Client (Fixed Initialization)
620+ try :
621+ from azure .ai .projects import AIProjectClient
622+ from azure .identity import DefaultAzureCredential
623+
624+ credential = DefaultAzureCredential ()
625+ ai_project_client = AIProjectClient (
626+ endpoint = ai_foundry_endpoint ,
627+ credential = credential ,
628+ project_name = ai_foundry_project_name
629+ )
630+ logger .info ("✅ Azure AI Foundry client initialized successfully." )
631+ except Exception as e :
632+ logger .error (f"❌ Failed to initialize AI Foundry client: { e } " )
633+ ai_project_client = None
0 commit comments