Skip to content

Commit

Permalink
Merge pull request #302 from Azure-Samples/removing_gpt_35
Browse files Browse the repository at this point in the history
removing gpt 35 and adding gpt4o and 4omini support.
  • Loading branch information
marlenezw authored Dec 18, 2024
2 parents d402cf6 + 9a9f321 commit 1b00e79
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 111 deletions.
1 change: 0 additions & 1 deletion .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME }}
AZURE_OPENAI_NAME: ${{ vars.AZURE_OPENAI_NAME }}
AZURE_CONTAINER_REGISTRY_NAME: ${{ vars.AZURE_CONTAINER_REGISTRY_NAME }}
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/evaluate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME }}
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
AZURE_SEARCH_ENDPOINT: ${{ vars.AZURE_SEARCH_ENDPOINT }}
AZURE_OPENAI_NAME: ${{ vars.AZURE_OPENAI_NAME }}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ This project template provides the following features:

* **Azure account**. If you're new to Azure, [get an Azure account for free](https://azure.microsoft.com/free/cognitive-search/) and you'll get some free Azure credits to get started. See [guide to deploying with the free trial](docs/deploy_lowcost.md).
* **Azure subscription with access enabled for the Azure OpenAI Service**. If your access request to Azure OpenAI Service doesn't match the [acceptance criteria](https://learn.microsoft.com/legal/cognitive-services/openai/limited-access?context=%2Fazure%2Fcognitive-services%2Fopenai%2Fcontext%2Fcontext), you can use [OpenAI public API](https://platform.openai.com/docs/api-reference/introduction) instead.
- Ability to deploy `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13`.
- We recommend using Canada East, as this region has access to all models and services required.
- Ability to deploy `gpt-4o` and `gpt-4o-mini`.
- We recommend using `swedencentral`, as this region has access to all models and services required.
* **Azure subscription with access enabled for [Bing Search API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api)**
* **Azure subscription with access enabled for [Azure AI Search](https://azure.microsoft.com/en-gb/products/ai-services/ai-search)**

Expand Down Expand Up @@ -105,9 +105,9 @@ The easiest way to get started is GitHub Codespaces, since it will setup all the
azd up
```

You will be prompted to select some details about your deployed resources, including location. As a reminder we recommend Canada East as the region for this project.
You will be prompted to select some details about your deployed resources, including location. As a reminder we recommend `Sweden Central` as the region for this project.
Once the deployment is complete you should be able to scroll up in your terminal and see the url that the app has been deployed to. It should look similar to this
`Ingress Updated. Access your app at https://env-name.codespacesname.eastus2.azurecontainerapps.io/`. Navigate to the link to try out the app straight away!
`Ingress Updated. Access your app at https://env-name.codespacesname.swedencentral.azurecontainerapps.io/`. Navigate to the link to try out the app straight away!

5. Once the above steps are completed you can [test the sample](#testing-the-sample).

Expand Down Expand Up @@ -185,7 +185,7 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
azd up
```
This project uses `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly. We recommend using Canada East for this project.
This project uses `gpt-4o` and `gpt-4o-mini which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly. We recommend using Sweden Central for this project.
After running azd up, you may be asked the following question during `Github Setup`:
Expand Down Expand Up @@ -308,8 +308,8 @@ azd pipeline config

### Region Availability

This template uses `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
* We recommend using Canada East
This template uses `gpt-4o` and `gpt-4o-mini` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
* We recommend using Sweden Central

### Costs

Expand Down
1 change: 0 additions & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pipeline:
- AZURE_RESOURCE_GROUP
- AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME
- AZURE_OPENAI_DEPLOYMENT_NAME
- AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME
- AZURE_SEARCH_ENDPOINT
- BING_SEARCH_ENDPOINT
- AZURE_OPENAI_NAME
Expand Down
22 changes: 17 additions & 5 deletions data/create-azure-search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -161,7 +161,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -174,7 +174,7 @@
" azure_credential = DefaultAzureCredential()\n",
" token_provider = get_bearer_token_provider(azure_credential,\"https://cognitiveservices.azure.com/.default\")\n",
" client = AzureOpenAI(\n",
" api_version=\"2023-07-01-preview\",\n",
" api_version=\"2024-08-01-preview\",\n",
" azure_endpoint=openai_service_endoint,\n",
" azure_deployment=openai_deployment,\n",
" azure_ad_token_provider=token_provider\n",
Expand Down Expand Up @@ -242,9 +242,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down
9 changes: 5 additions & 4 deletions data/create-azure-search.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def create_index_definition(name: str) -> SearchIndex:
return index


# In[5]:

# In[7]:


def gen_products(
Expand All @@ -155,7 +156,7 @@ def gen_products(
azure_credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(azure_credential,"https://cognitiveservices.azure.com/.default")
client = AzureOpenAI(
api_version="2023-07-01-preview",
api_version="2024-08-01-preview",
azure_endpoint=openai_service_endoint,
azure_deployment=openai_deployment,
azure_ad_token_provider=token_provider
Expand All @@ -182,7 +183,7 @@ def gen_products(
return items


# In[6]:
# In[8]:


aisearch_endpoint = os.environ["AZURE_SEARCH_ENDPOINT"]
Expand All @@ -199,7 +200,7 @@ def gen_products(
print(f"index {index_name} created")


# In[7]:
# In[9]:


print(f"indexing documents")
Expand Down
47 changes: 27 additions & 20 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ description: Using Azure OpenAI agent with Python, integrating Bing Search API a
- [Initializing the project](#initializing-the-project)
- [Deployment](#deployment)
- [Testing the sample](#testing-the-sample)
- [Evaluating prompt flow results](#evaluating-prompt-flow-results)
- [Costs](#costs)
- [Security Guidelines](#security-guidelines)
- [Evaluating results](#evaluating-results)
- [Guidance](#guidance)
- [Region Availability](#region-availability)
- [Costs](#costs)
- [Security Guidelines](#security)
- [Resources](#resources)
- [Code of Conduct](#code-of-conduct)

Expand Down Expand Up @@ -66,9 +67,9 @@ This project template provides the following features:
**IMPORTANT:** In order to deploy and run this example, you'll need:

* **Azure account**. If you're new to Azure, [get an Azure account for free](https://azure.microsoft.com/free/cognitive-search/) and you'll get some free Azure credits to get started. See [guide to deploying with the free trial](docs/deploy_lowcost.md).
* **Azure subscription with access enabled for the Azure OpenAI Service**. You can request access with [this form](https://aka.ms/oaiapply). If your access request to Azure OpenAI Service doesn't match the [acceptance criteria](https://learn.microsoft.com/legal/cognitive-services/openai/limited-access?context=%2Fazure%2Fcognitive-services%2Fopenai%2Fcontext%2Fcontext), you can use [OpenAI public API](https://platform.openai.com/docs/api-reference/introduction) instead.
- Ability to deploy `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13`.
- We recommend using Canada East, as this region has access to all models and services required.
* **Azure subscription with access enabled for the Azure OpenAI Service**. If your access request to Azure OpenAI Service doesn't match the [acceptance criteria](https://learn.microsoft.com/legal/cognitive-services/openai/limited-access?context=%2Fazure%2Fcognitive-services%2Fopenai%2Fcontext%2Fcontext), you can use [OpenAI public API](https://platform.openai.com/docs/api-reference/introduction) instead.
- Ability to deploy `gpt-4o` and `gpt-4o-mini`.
- We recommend using `swedencentral`, as this region has access to all models and services required.
* **Azure subscription with access enabled for [Bing Search API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api)**
* **Azure subscription with access enabled for [Azure AI Search](https://azure.microsoft.com/en-gb/products/ai-services/ai-search)**

Expand Down Expand Up @@ -104,9 +105,9 @@ The easiest way to get started is GitHub Codespaces, since it will setup all the
azd up
```

You will be prompted to select some details about your deployed resources, including location. As a reminder we recommend Canada East as the region for this project.
You will be prompted to select some details about your deployed resources, including location. As a reminder we recommend `Sweden Central` as the region for this project.
Once the deployment is complete you should be able to scroll up in your terminal and see the url that the app has been deployed to. It should look similar to this
`Ingress Updated. Access your app at https://env-name.codespacesname.eastus2.azurecontainerapps.io/`. Navigate to the link to try out the app straight away!
`Ingress Updated. Access your app at https://env-name.codespacesname.swedencentral.azurecontainerapps.io/`. Navigate to the link to try out the app straight away!

5. Once the above steps are completed you can [test the sample](#testing-the-sample).

Expand Down Expand Up @@ -184,7 +185,7 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
azd up
```
This project uses `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly. We recommend using Canada East for this project.
This project uses `gpt-4o` and `gpt-4o-mini which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly. We recommend using Sweden Central for this project.
After running azd up, you may be asked the following question during `Github Setup`:
Expand Down Expand Up @@ -215,8 +216,8 @@ To test the sample:
```
**Important Note**: If you are running in Codespaces, you will need to change the visibility of the API's 8000 and 5173 ports to `public` in your VS Code terminal's `PORTS` tab. The ports tab should look like this:
<img src="./images/ports.png" alt="Screenshot showing setting port-visibility" width="800px" />
![Screenshot showing setting port-visibility](images/ports-resized.png)
If you open the server link in a browser, you will see a URL not found error, this is because we haven't created a home url route in FastAPI. We have instead created a `/get_article` route which is used to pass context and instructions directly to the get_article.py file which runs the agent workflow.
Expand Down Expand Up @@ -274,21 +275,26 @@ python -m orchestrator
Once you can see the article has been generated, a `.runs` folder should appear in the `./src/api` . Select this folder and click the `.tracy` file in it.
This shows you all the Python functions that were called in order to generate the article. Explore each section and see what helpful information you can find.

## Evaluating prompt flow results

To understand how well our prompt flow performs using defined metrics like **groundedness**, **coherence** etc we can evaluate the results. To evaluate the prompt flow, we need to be able to compare it to what we see as "good results" in order to understand how well it aligns with our expectations.

We may be able to evaluate the flow manually (e.g., using Azure AI Foundry) but for now, we'll evaluate this by running the prompt flow using **gpt-4** and comparing our performance to the results obtained there. To do this, follow the instructions and steps in the notebook `evaluate-chat-prompt-flow.ipynb` under the `eval` folder.
## Evaluating results

You can also view the evaluation metrics by running the following command from the src/api folder.
Contoso Creative Writer uses evaluators to assess application response quality. The 4 metrics the evaluators in this project assess are Coherence, Fluency, Relevance and Groundedness. A custom `evaluate.py` script has been written to run all evaulations for you.

Run evaluation:
1. To run the script run the following commands:

```shell
cd ./src/api
python -m evaluate.evaluate
```

- Check: You see scores for Coherence, Fluency, Relevance and Groundedness.
- Check: The scores are between 1 and 5


2. To understand what is being evaluated open the `src/api/evaluate/eval_inputs.jsonl` file.
- Observe that 3 examples of research, product and assignment context are stored in this file. This data will be sent to the orchestrator so that each example will have:
- each example will have the evaluations run and will incoperate all of the context, research, products, and final article when grading the response.


## Setting up CI/CD with GitHub actions

This template is set up to run CI/CD when you push changes to your repo. When CI/CD is configured, evaluations will in GitHub actions and then automatically deploy your app on push to main.
Expand All @@ -302,8 +308,8 @@ azd pipeline config

### Region Availability

This template uses `gpt-35-turbo-0613`,`gpt-4-1106-Preview` and `gpt-4o-2024-05-13` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
* We recommend using Canada East
This template uses `gpt-4o` and `gpt-4o-mini` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
* We recommend using Sweden Central

### Costs

Expand All @@ -322,6 +328,7 @@ This template has either [Managed Identity](https://learn.microsoft.com/entra/id
## Resources

* [Prompty Documentation](https://prompty.ai/)
* [Quickstart: Multi-agent applications using Azure OpenAI article](https://learn.microsoft.com/en-us/azure/developer/ai/get-started-multi-agents?tabs=github-codespaces): The Microsoft Learn Quickstart article for this sample, walks through both deployment and the relevant code for orchestrating multi-agents in chat.
* [Develop Python apps that use Azure AI services](https://learn.microsoft.com/azure/developer/python/azure-ai-for-python-developers)

## Code of Conduct
Expand Down
2 changes: 1 addition & 1 deletion docs/workshop/lab_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def create_azd_environment(*, azure_env_name: str, subscription: str):
# Create new environment if it doesn't exist
azd_cmd = [
'azd', 'env', 'new', azure_env_name,
'--location', 'canadaeast',
'--location', 'swedencentral',
'--subscription', subscription
]
subprocess.run(azd_cmd, check=True)
Expand Down
4 changes: 2 additions & 2 deletions docs/workshop/researcher/researcher-0.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ model:
api: chat
configuration:
type: azure_openai
azure_deployment: gpt-35-turbo
api_version: 2023-07-01-preview
azure_deployment: gpt-4
api_version: 2024-08-01-preview
sample:
instructions: Can you generate queries to find the latest winter camping trends? Use 'en-US' as the market code.
---
Expand Down
4 changes: 2 additions & 2 deletions docs/workshop/researcher/researcher-1.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ model:
api: chat
configuration:
type: azure_openai
azure_deployment: gpt-35-turbo
api_version: 2023-07-01-preview
azure_deployment: gpt-4
api_version: 2024-08-01-preview
inputs:
participant:
type: object
Expand Down
4 changes: 2 additions & 2 deletions docs/workshop/researcher/researcher-2.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ model:
api: chat
configuration:
type: azure_openai
azure_deployment: gpt-35-turbo
api_version: 2023-07-01-preview
azure_deployment: gpt-4
api_version: 2024-08-01-preview
parameters:
tools: ${file:functions.json}
sample:
Expand Down
2 changes: 1 addition & 1 deletion docs/workshop/socialmedia/social.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ model:
configuration:
type: azure_openai
azure_deployment: gpt-4
api_version: 2023-07-01-preview
api_version: 2024-08-01-preview
parameters:
max_tokens: 50
sample:
Expand Down
2 changes: 1 addition & 1 deletion docs/workshop/workshop-1-intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
" configuration: \n",
" type: azure_openai\n",
" azure_deployment: gpt-35-turbo\n",
" api_version: 2023-07-01-preview\n",
" api_version: 2024-05-13\n",
" sample:\n",
" instructions: Can you tell me more about Prompty? \n",
" ---\n",
Expand Down
14 changes: 3 additions & 11 deletions infra/ai.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# yaml-language-server: $schema=ai.yaml.json

deployments:
- name: gpt-35-turbo
model:
format: OpenAI
name: gpt-35-turbo
version: "1106"
sku:
name: Standard
capacity: 20
- name: text-embedding-ada-002
model:
format: OpenAI
Expand All @@ -24,12 +16,12 @@ deployments:
version: "2024-05-13"
sku:
name: "GlobalStandard"
capacity: 19
capacity: 20
- name: gpt-4-evals
model:
format: OpenAI
name: gpt-4
version: "0613"
name: gpt-4o-mini
version: "2024-07-18"
sku:
name: "Standard"
capacity: 8
5 changes: 0 additions & 5 deletions infra/app/api.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ param identityId string
param containerAppsEnvironmentName string
param containerRegistryName string
param serviceName string = 'api'
param openAi_35_turbo_DeploymentName string
param openAi_4_DeploymentName string
param openAi_4_eval_DeploymentName string
param openAiEndpoint string
Expand Down Expand Up @@ -66,10 +65,6 @@ module app '../core/host/container-app-upsert.bicep' = {
name: 'AZURE_OPENAI_NAME'
value: openAiName
}
{
name: 'AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME'
value: openAi_35_turbo_DeploymentName
}
{
name: 'AZURE_OPENAI_DEPLOYMENT_NAME'
value: openAi_4_DeploymentName
Expand Down
Loading

0 comments on commit 1b00e79

Please sign in to comment.