Skip to content

Commit d08e5cc

Browse files
risinhrisinhmicrosoftCopilot
authored
Pass Model Deployment parameter to cluster insight sample (#44064)
* Pass Model Deployment parameter to cluster insight sample * Update sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Ritesh Kumar Sinha <risinh@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7a20243 commit d08e5cc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from pprint import pprint
3535
from dotenv import load_dotenv
3636
from azure.ai.projects.models._enums import OperationState
37-
from azure.ai.projects.models._models import EvaluationComparisonRequest, EvaluationRunClusterInsightsRequest, Insight
37+
from azure.ai.projects.models._models import EvaluationRunClusterInsightsRequest, Insight, InsightModelConfiguration
3838
from azure.identity import DefaultAzureCredential
3939
from azure.ai.projects import AIProjectClient
4040
from openai.types.eval_create_params import DataSourceConfigCustom, TestingCriterionLabelModel
@@ -45,6 +45,10 @@
4545
load_dotenv()
4646

4747
endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"]
48+
model_deployment_name = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME")
49+
50+
if not model_deployment_name:
51+
raise ValueError("AZURE_AI_MODEL_DEPLOYMENT_NAME environment variable is not set")
4852

4953
with (
5054
DefaultAzureCredential() as credential,
@@ -61,7 +65,7 @@
6165
TestingCriterionLabelModel(
6266
type="label_model",
6367
name="sentiment_analysis",
64-
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
68+
model=model_deployment_name,
6569
input=[
6670
{
6771
"role": "developer",
@@ -127,7 +131,13 @@
127131
clusterInsight = project_client.insights.generate(
128132
Insight(
129133
display_name="Cluster analysis",
130-
request=EvaluationRunClusterInsightsRequest(eval_id=eval_object.id, run_ids=[eval_run.id]),
134+
request=EvaluationRunClusterInsightsRequest(
135+
eval_id=eval_object.id,
136+
run_ids=[eval_run.id],
137+
model_configuration=InsightModelConfiguration(
138+
model_deployment_name=model_deployment_name
139+
),
140+
),
131141
)
132142
)
133143
print(f"Started insight generation (id: {clusterInsight.id})")

0 commit comments

Comments
 (0)