Skip to content

Commit 4680343

Browse files
updated script test v3
1 parent 91fb0f8 commit 4680343

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

infra/scripts/index_scripts/03_cu_process_data_text.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from azure.search.documents import SearchClient
1616
from azure.search.documents.indexes import SearchIndexClient
1717
from 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
1920
from content_understanding_client import AzureContentUnderstandingClient
2021
from 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):
613614
conn.close()
614615
logger.info("=== COMPLETED 03_cu_process_data_text.py SUCCESSFULLY ===")
615616
logger.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

Comments
 (0)