Skip to content

Commit d28f47b

Browse files
authored
Evaluation Sample Fix (#178)
* Add files via upload * Update model_endpoints.py * Running nb clean
1 parent 92b0993 commit d28f47b

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

scenarios/evaluate/Supported_Evaluation_Targets/Evaluate_Base_Model_Endpoint/Evaluate_Base_Model_Endpoint.ipynb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {
6-
"tags": []
7-
},
5+
"metadata": {},
86
"source": [
97
"# Evaluate Base Model Endpoints using Azure AI Evaluation APIs\n",
108
"\n",
@@ -39,9 +37,7 @@
3937
"metadata": {},
4038
"outputs": [],
4139
"source": [
42-
"%pip install azure-ai-evaluation\n",
43-
"%pip install promptflow-azure\n",
44-
"%pip install promptflow-tracing"
40+
"%pip install -U azure-ai-evaluation"
4541
]
4642
},
4743
{
@@ -65,9 +61,7 @@
6561
},
6662
{
6763
"cell_type": "markdown",
68-
"metadata": {
69-
"tags": []
70-
},
64+
"metadata": {},
7165
"source": [
7266
"## Target Application\n",
7367
"\n",
@@ -86,7 +80,7 @@
8680
"source": [
8781
"env_var = {\n",
8882
" \"gpt4-0613\": {\n",
89-
" \"endpoint\": \"https://ai-***.**.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2023-03-15-preview\",\n",
83+
" \"endpoint\": \"https://ai-**.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-08-01-preview\",\n",
9084
" \"key\": \"***\",\n",
9185
" },\n",
9286
" \"gpt35-turbo\": {\n",
@@ -143,9 +137,10 @@
143137
"\n",
144138
"# Use the following code to set the environment variables if not already set. If set, you can skip this step.\n",
145139
"\n",
146-
"os.environ[\"AZURE_OPENAI_API_VERSION\"] = \"<api version>\"\n",
147-
"os.environ[\"AZURE_OPENAI_DEPLOYMENT\"] = \"<your-deployment>\"\n",
148-
"os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"<your-endpoint>\""
140+
"os.environ[\"AZURE_OPENAI_API_VERSION\"] = \"<api-version>\"\n",
141+
"os.environ[\"AZURE_OPENAI_DEPLOYMENT\"] = \"<deployment-name>\"\n",
142+
"os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"<endpoint>\"\n",
143+
"os.environ[\"AZURE_OPENAI_KEY\"] = \"<key>\""
149144
]
150145
},
151146
{
@@ -198,10 +193,14 @@
198193
"metadata": {},
199194
"outputs": [],
200195
"source": [
201-
"model_config = {\n",
202-
" \"azure_endpoint\": os.environ.get(\"AZURE_OPENAI_ENDPOINT\"),\n",
203-
" \"azure_deployment\": os.environ.get(\"AZURE_OPENAI_DEPLOYMENT\"),\n",
204-
"}"
196+
"from azure.ai.evaluation import AzureOpenAIModelConfiguration\n",
197+
"\n",
198+
"model_config = AzureOpenAIModelConfiguration(\n",
199+
" azure_endpoint=os.environ.get(\"AZURE_OPENAI_ENDPOINT\"),\n",
200+
" azure_deployment=os.environ.get(\"AZURE_OPENAI_DEPLOYMENT\"),\n",
201+
" api_key=os.environ.get(\"AZURE_OPENAI_KEY\"),\n",
202+
" api_version=os.environ.get(\"AZURE_OPENAI_API_VERSION\"),\n",
203+
")"
205204
]
206205
},
207206
{
@@ -259,6 +258,7 @@
259258
" evaluators={\n",
260259
" \"relevance\": relevance_evaluator,\n",
261260
" },\n",
261+
" azure_ai_project=azure_ai_project,\n",
262262
" evaluator_config={\n",
263263
" \"relevance\": {\n",
264264
" \"column_mapping\": {\n",

scenarios/evaluate/Supported_Evaluation_Targets/Evaluate_Base_Model_Endpoint/model_endpoints.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Response(TypedDict):
1515

1616
@trace
1717
def __call__(self: Self, query: str) -> Response:
18-
if self.model_type == "gpt4-0821":
18+
if self.model_type == "gpt4-0613":
1919
output = self.call_gpt4_endpoint(query)
2020
elif self.model_type == "gpt35-turbo":
2121
output = self.call_gpt35_turbo_endpoint(query)
@@ -37,8 +37,8 @@ def query(self: Self, endpoint: str, headers: str, payload: str) -> str:
3737
return response.json()
3838

3939
def call_gpt4_endpoint(self: Self, query: str) -> Response:
40-
endpoint = self.env["gpt4-0821"]["endpoint"]
41-
key = self.env["gpt4-0821"]["key"]
40+
endpoint = self.env["gpt4-0613"]["endpoint"]
41+
key = self.env["gpt4-0613"]["key"]
4242

4343
headers = {"Content-Type": "application/json", "api-key": key}
4444

@@ -115,5 +115,5 @@ def call_mistral_endpoint(self: Self, query: str) -> Response:
115115
response = output["choices"][0]["message"]["content"]
116116
return {"query": query, "response": response}
117117

118-
def call_default_endpoint(query: str) -> Response:
119-
return {"query": "What is the capital of France?", "response": "Paris"}
118+
def call_default_endpoint(self: Self, query: str) -> Response:
119+
return {"query": query, "response": "Paris"}

0 commit comments

Comments
 (0)