Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"metadata": {},
"source": [
"# Evaluate Base Model Endpoints using Azure AI Evaluation APIs\n",
"\n",
Expand Down Expand Up @@ -39,9 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install azure-ai-evaluation\n",
"%pip install promptflow-azure\n",
"%pip install promptflow-tracing"
"%pip install -U azure-ai-evaluation"
]
},
{
Expand All @@ -65,9 +61,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"metadata": {},
"source": [
"## Target Application\n",
"\n",
Expand All @@ -86,7 +80,7 @@
"source": [
"env_var = {\n",
" \"gpt4-0613\": {\n",
" \"endpoint\": \"https://ai-***.**.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2023-03-15-preview\",\n",
" \"endpoint\": \"https://ai-**.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-08-01-preview\",\n",
" \"key\": \"***\",\n",
" },\n",
" \"gpt35-turbo\": {\n",
Expand Down Expand Up @@ -143,9 +137,10 @@
"\n",
"# Use the following code to set the environment variables if not already set. If set, you can skip this step.\n",
"\n",
"os.environ[\"AZURE_OPENAI_API_VERSION\"] = \"<api version>\"\n",
"os.environ[\"AZURE_OPENAI_DEPLOYMENT\"] = \"<your-deployment>\"\n",
"os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"<your-endpoint>\""
"os.environ[\"AZURE_OPENAI_API_VERSION\"] = \"<api-version>\"\n",
"os.environ[\"AZURE_OPENAI_DEPLOYMENT\"] = \"<deployment-name>\"\n",
"os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"<endpoint>\"\n",
"os.environ[\"AZURE_OPENAI_KEY\"] = \"<key>\""
]
},
{
Expand Down Expand Up @@ -198,10 +193,14 @@
"metadata": {},
"outputs": [],
"source": [
"model_config = {\n",
" \"azure_endpoint\": os.environ.get(\"AZURE_OPENAI_ENDPOINT\"),\n",
" \"azure_deployment\": os.environ.get(\"AZURE_OPENAI_DEPLOYMENT\"),\n",
"}"
"from azure.ai.evaluation import AzureOpenAIModelConfiguration\n",
"\n",
"model_config = AzureOpenAIModelConfiguration(\n",
" azure_endpoint=os.environ.get(\"AZURE_OPENAI_ENDPOINT\"),\n",
" azure_deployment=os.environ.get(\"AZURE_OPENAI_DEPLOYMENT\"),\n",
" api_key=os.environ.get(\"AZURE_OPENAI_KEY\"),\n",
" api_version=os.environ.get(\"AZURE_OPENAI_API_VERSION\"),\n",
")"
]
},
{
Expand Down Expand Up @@ -259,6 +258,7 @@
" evaluators={\n",
" \"relevance\": relevance_evaluator,\n",
" },\n",
" azure_ai_project=azure_ai_project,\n",
" evaluator_config={\n",
" \"relevance\": {\n",
" \"column_mapping\": {\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Response(TypedDict):

@trace
def __call__(self: Self, query: str) -> Response:
if self.model_type == "gpt4-0821":
if self.model_type == "gpt4-0613":
output = self.call_gpt4_endpoint(query)
elif self.model_type == "gpt35-turbo":
output = self.call_gpt35_turbo_endpoint(query)
Expand All @@ -37,8 +37,8 @@ def query(self: Self, endpoint: str, headers: str, payload: str) -> str:
return response.json()

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

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

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

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