Skip to content

Commit d261ba0

Browse files
code cleaning
1 parent eb43f1f commit d261ba0

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

infra/scripts/index_scripts/03_cu_process_data_text.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ def get_secrets_from_kv(kv_name, secret_name):
7979
ANALYZER_ID = "ckm-json"
8080
print("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)
8683
inference_endpoint = f"https://{urlparse(ai_project_endpoint).netloc}/models"
8784

8885
chat_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
10298
def 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`) ---
312306
max_tokens = 3096
313307

314308
res = call_gpt4(topics_str, chat_client)

infra/scripts/index_scripts/03_cu_process_data_text_manual.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ def get_secrets_from_kv(kv_name, secret_name):
8282
ANALYZER_ID = "ckm-json"
8383
print("Content Understanding client initialized.")
8484

85-
86-
# ---------- Azure AI Foundry (Inference) clients (Managed Identity) ----------
87-
# Project endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/api/projects/your-project-name
88-
# Inference endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/models
89-
# Strip the "/api/projects/your-project-name" part and replace with "/models":
85+
# Azure AI Foundry (Inference) clients (Managed Identity)
9086
inference_endpoint = f"https://{urlparse(ai_project_endpoint).netloc}/models"
9187

9288
chat_client = ChatCompletionsClient(
@@ -100,12 +96,9 @@ def get_secrets_from_kv(kv_name, secret_name):
10096
credential=credential,
10197
credential_scopes=["https://ai.azure.com/.default"],
10298
)
103-
# -----------------------------------------------------------------------------
104-
10599

106100
# Utility functions
107101
def get_embeddings(text: str):
108-
# Uses Azure AI Inference EmbeddingsClient with the AI Foundry project inference endpoint.
109102
try:
110103
resp = embeddings_client.embed(model=embedding_deployment, input=[text])
111104
return resp.data[0].embedding
@@ -301,7 +294,6 @@ def call_gpt4(topics_str1, client):
301294
Return the topics and their labels in JSON format.Always add 'topics' node and 'label', 'description' attributes in json.
302295
Do not return anything else.
303296
"""
304-
# Inference client: Chat completions with model deployment name
305297
response = client.complete(
306298
model=deployment,
307299
messages=[

infra/scripts/index_scripts/04_cu_process_data_new_data.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ def get_secrets_from_kv(kv_name, secret_name):
7070
index_client = SearchIndexClient(endpoint=search_endpoint, credential=search_credential)
7171
print("Azure Search setup complete.")
7272

73-
# ---------- Azure AI Foundry (Inference) clients (Managed Identity) ----------
74-
# Project endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/api/projects/your-project-name
75-
# Inference endpoint has the form: https://your-ai-services-account-name.services.ai.azure.com/models
76-
# Strip the "/api/projects/your-project-name" part and replace with "/models":
73+
# Azure AI Foundry (Inference) clients (Managed Identity)
7774
inference_endpoint = f"https://{urlparse(ai_project_endpoint).netloc}/models"
7875

7976
chat_client = ChatCompletionsClient(
@@ -187,7 +184,6 @@ def create_search_index():
187184

188185
# Utility functions
189186
def get_embeddings(text: str):
190-
# Uses Azure AI Inference EmbeddingsClient with the AI Foundry project inference endpoint.
191187
try:
192188
resp = embeddings_client.embed(model=embedding_model, input=[text])
193189
return resp.data[0].embedding

0 commit comments

Comments
 (0)