@@ -79,10 +79,7 @@ def get_secrets_from_kv(kv_name, secret_name):
7979ANALYZER_ID = "ckm-json"
8080print ("Content Understanding client initialized." )
8181
82- # ---------- Azure AI Foundry (Inference) clients (Managed Identity) ----------
83- # Project endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/api/projects/your-project-name
84- # Inference endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/models
85- # Strip the "/api/projects/your-project-name" part and replace with "/models":
82+ # Azure AI Foundry (Inference) clients (Managed Identity)
8683inference_endpoint = f"https://{ urlparse (ai_project_endpoint ).netloc } /models"
8784
8885chat_client = ChatCompletionsClient (
@@ -96,11 +93,9 @@ def get_secrets_from_kv(kv_name, secret_name):
9693 credential = credential ,
9794 credential_scopes = ["https://ai.azure.com/.default" ],
9895)
99- # -----------------------------------------------------------------------------
10096
10197# Utility functions
10298def get_embeddings (text : str ):
103- # Uses Azure AI Inference EmbeddingsClient with the AI Foundry project inference endpoint.
10499 try :
105100 resp = embeddings_client .embed (model = embedding_deployment , input = [text ])
106101 return resp .data [0 ].embedding
@@ -296,7 +291,7 @@ def call_gpt4(topics_str1, client):
296291 Return the topics and their labels in JSON format.Always add 'topics' node and 'label', 'description' attributes in json.
297292 Do not return anything else.
298293 """
299- # Inference client: Chat completions with model deployment name
294+
300295 response = client .complete (
301296 model = deployment ,
302297 messages = [
@@ -308,7 +303,6 @@ def call_gpt4(topics_str1, client):
308303 res = response .choices [0 ].message .content
309304 return json .loads (res .replace ("```json" , '' ).replace ("```" , '' ))
310305
311- # --- REPLACED: AzureOpenAI(...) with ChatCompletionsClient (already created as `chat_client`) ---
312306max_tokens = 3096
313307
314308res = call_gpt4 (topics_str , chat_client )
0 commit comments