Skip to content

Commit 49e52c7

Browse files
cassiebreviuandredewesAndre Dewes
authored
Container app updates, fast api updates, fixes, infra updates (#157)
* inital aca work * container config updates * Fixing container startup issues (#129) * Fixing container startup issues * Fixing import --------- Co-authored-by: Andre Dewes <andredewes@microsoft.com> * update arch diagram * fix get response * path fixes * fix chat request * fix env vars * fix path for ai search * update to fastapi, prompty updates, start eval work, * some deployment fixes * fix api deployment, fix endpoint name * update eval py to load model config * evalution notebook * move evals * update infra to ai studio * update model version to deploy to east us2 * update evaluate * remove unsued deployment files * update text * fix models for infra * fix aca name --------- Co-authored-by: Andre Dewes <31827221+andredewes@users.noreply.github.com> Co-authored-by: Andre Dewes <andredewes@microsoft.com>
1 parent 451994c commit 49e52c7

File tree

93 files changed

+68355
-4332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+68355
-4332
lines changed

.github/workflows/evaluations.yaml

+24-44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Evaluate Chat Relevance, Fluency, Coherence, and Groundedness
1+
name: Evaluate
22

33
on:
44
workflow_dispatch:
@@ -7,7 +7,6 @@ on:
77
# Set this to the mainline branch you are using
88
branches:
99
- main
10-
- azd
1110

1211
# Set up permissions for deploying with secretless Azure federated credentials
1312
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
@@ -23,17 +22,24 @@ jobs:
2322
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
2423
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
2524
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
26-
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
27-
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
28-
AZURE_DEPLOYMENT_NAME: "gpt-4"
29-
AZURE_EMBEDDING_NAME: "text-embedding-ada-002"
30-
COSMOS_ENDPOINT: "${{ secrets.CONTOSO_SEARCH_ENDPOINT }}"
31-
AZURE_SEARCH_ENDPOINT: "${{ secrets.AZURE_SEARCH_ENDPOINT }}"
25+
AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }}
26+
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
27+
AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_4_EVAL_DEPLOYMENT_NAME }}
28+
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
29+
AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_35_TURBO_DEPLOYMENT_NAME }}
30+
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
31+
AZURE_SEARCH_ENDPOINT: ${{ vars.AZURE_SEARCH_ENDPOINT }}
32+
AZURE_OPENAI_NAME: ${{ vars.AZURE_OPENAI_NAME }}
33+
BING_SEARCH_ENDPOINT: ${{ vars.BING_SEARCH_ENDPOINT }}
34+
BING_SEARCH_KEY: ${{ secrets.BING_SEARCH_KEY }}
3235

3336
steps:
3437
- name: checkout repo content
3538
uses: actions/checkout@v4 # checkout the repository content
3639

40+
- name: Install azd
41+
uses: Azure/setup-azd@v1.0.0
42+
3743
- name: setup python
3844
uses: actions/setup-python@v5
3945
with:
@@ -42,64 +48,38 @@ jobs:
4248
- name: install python packages
4349
run: |
4450
python -m pip install --upgrade pip
45-
pip install -r requirements.txt
46-
47-
- name: install promptflow dev bits
48-
run: |
49-
# unstall old promptflow
50-
pip uninstall -y promptflow promptflow-azure promptflow-core promptflow-devkit promptflow-tools promptflow-evals
51-
52-
# install dev packages
53-
pip install promptflow-evals==0.2.0.dev125831637 --extra-index-url https://azuremlsdktestpypi.azureedge.net/promptflow
54-
pip install azure_ai_ml==1.16.0a20240501004 --extra-index-url https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/
55-
56-
pip install azure-cli
57-
pip install bs4
58-
pip install ipykernel
59-
pip install azure-cosmos==4.6.0
60-
pip install azure-search-documents==11.4.0
61-
62-
pf version
51+
pip install -r src/api/requirements.txt
6352
6453
- name: Azure login
6554
uses: azure/login@v2
6655
with:
6756
client-id: ${{ env.AZURE_CLIENT_ID }}
6857
tenant-id: ${{ env.AZURE_TENANT_ID }}
6958
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
70-
59+
7160
- name: Set az account
7261
uses: azure/CLI@v2
7362
with:
7463
inlineScript: |
7564
az account set --subscription ${{env.AZURE_SUBSCRIPTION_ID}}
7665
77-
- name: Set Promptflow config
78-
run: |
79-
pf config set trace.destination=azureml://subscriptions/${{ env.AZURE_SUBSCRIPTION_ID }}/resourceGroups/rg-${{ vars.AZURE_ENV_NAME }}/providers/Microsoft.MachineLearningServices/workspaces/${{ vars.ML_WORKSPACE_NAME }}
80-
81-
- name: evaluate chat data using the eval sdk
82-
working-directory: ./evaluations
66+
- name: evaluate
67+
working-directory: ./src/api
8368
run: |
84-
python evaluations_chat.py
69+
python -m evaluators.evaluate
8570
8671
- name: Upload eval results as build artifact
8772
uses: actions/upload-artifact@v4
8873
with:
8974
name: eval_result
90-
path: ./evaluations/eval_result.jsonl
75+
path: ./src/api/evaluators/eval_results.jsonl
9176

9277
- name: GitHub Summary Step
9378
if: ${{ success() }}
94-
working-directory: ./evaluations
79+
working-directory: ./src/api
9580
run: |
96-
studio_url=$(cat studio_url.txt)
97-
echo $studio_url
98-
99-
echo "🔗 [View in Azure Studio Here]($studio_url)" >> $GITHUB_STEP_SUMMARY
100-
10181
echo "" >> $GITHUB_STEP_SUMMARY
10282
103-
echo "📊 Promptflow Evaluation Results" >> $GITHUB_STEP_SUMMARY
104-
cat eval_result.md >> $GITHUB_STEP_SUMMARY
105-
83+
echo "📊 Evaluation Results" >> $GITHUB_STEP_SUMMARY
84+
cat evaluate/eval_results.md >> $GITHUB_STEP_SUMMARY
85+

.gitignore

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.venv/
22
__pycache__/
3-
.promptflow/
3+
.prompty/
44
.env
55
config.json
66
eval/downloaded_artifacts/remote/eval_results.jsonl
@@ -11,7 +11,20 @@ deployment/push_and_deploy_pf.py
1111
endpoint.json
1212
principal.txt
1313
.azure
14-
evaluations/process_log/
15-
evaluations/flow.flex.yaml
16-
evaluations/eval_result.**
17-
evaluations/studio_url.txt
14+
evaluators/process_log/
15+
evaluators/flow.flex.yaml
16+
evaluators/eval_result.**
17+
evaluators/studio_url.txt
18+
src/contoso_chat/.runs/*
19+
src/api/contoso_chat/.runs/*
20+
src/api/.runs/*
21+
.runs/*
22+
evaluators/.runs/*
23+
evaluators/result_evaluated.jsonl
24+
evaluators/result.jsonl
25+
src/api/evaluators/.runs/*
26+
src/api/evaluators/result_evaluated.jsonl
27+
src/api/evaluators/result.jsonl
28+
src/api/evaluators/eval_results.jsonl
29+
src/api/evaluators/eval_results.md
30+
src/api/evaluators/.runs/*

README.md

+5-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Contoso Chat Retail with Azure AI Studio and Promptflow
2+
name: Contoso Chat Retail with Azure AI Studio and Prompty
33
description: A retail copilot that answers customer queries with responses grounded in retailer's product and customer data.
44
languages:
55
- python
@@ -15,7 +15,7 @@ page_type: sample
1515
urlFragment: contoso-chat
1616
---
1717

18-
# Contoso Chat Retail with Azure AI Studio and Promptflow
18+
# Contoso Chat Retail with Azure AI Studio and Prompty
1919

2020
This sample creates a customer support chat agent for an online retailer called Contoso Outdoors. The solution uses a _retrieval-augmented generation pattern_ to ground responses in the company's product and customer data. Customers can ask questions about the retailer's product catalog, and also get recommendations based on their prior purchases.
2121

@@ -32,8 +32,8 @@ The sample uses [Azure AI Search](https://learn.microsoft.com/azure/search/) to
3232

3333
By exploring and deploying this sample, you will learn to:
3434
- Build a retail copilot application using the [_RAG pattern_](https://learn.microsoft.com/azure/ai-studio/concepts/retrieval-augmented-generation).
35-
- Define and engineer prompts using the [_Prompty_ asset](https://microsoft.github.io/promptflow/tutorials/prompty-quickstart.html?highlight=prompty#).
36-
- Design, run & evaluate a copilot using the [_Promptflow_ framework](https://microsoft.github.io/promptflow/tutorials/flex-flow-quickstart.html).
35+
- Define and engineer prompts using the Prompty
36+
- Design, run & evaluate a copilot
3737
- Provision and deploy the solution to Azure using the [_Azure Developer CLI_](https://learn.microsoft.com/azure/developer/azure-developer-cli/).
3838
- Understand and apply Responsible AI practices like [_evaluation and content safety_](https://learn.microsoft.com/en-us/azure/ai-services/responsible-use-of-ai-overview?context=%2Fazure%2Fai-studio%2Fcontext%2Fcontext).
3939

@@ -103,7 +103,6 @@ This has been the signature sample used to showcase end-to-end development of a
103103
* [Visual Studio Code](https://code.visualstudio.com) - recommended IDE for local development.
104104
* [Azure Developer CLI (azd)](https://aka.ms/install-azd) - to manage Azure deployment.
105105
* [Python 3.10+](https://www.python.org/downloads/) - to run, test & evaluate application.
106-
* [Promptflow 1.10+](https://microsoft.github.io/promptflow/) - to build, evaluate, and deploy application flows.
107106

108107
You will also need:
109108
* [Azure Subscription](https://azure.microsoft.com/free/) - sign up for a free account.
@@ -222,26 +221,7 @@ The [contoso_chat](./contoso_chat) sample contains an example [chat.prompty](./c
222221
- `question` section to embed user query
223222
- `Instructions` section to reference related product recommendations
224223
225-
This specific prompty takes 3 inputs: a `customer` object, a `documentation` object (that could be chat history) and a `question` string that represents the user query. You can now _load_, _execute_, and _trace_ individual prompty assets for a more granular prompt engineering solution.
226-
227-
* See the [prompty specification](https://microsoft.github.io/promptflow/how-to-guides/develop-a-prompty/index.html#prompty-specification) for more details on the format.
228-
* Read the [prompty examples](https://github.com/microsoft/promptflow/tree/main/examples/prompty) for usage guidance from SDK or CLI.
229-
230-
### Testing the Application Flow
231-
232-
This sample uses a [flex-flow](https://microsoft.github.io/promptflow/how-to-guides/develop-a-flex-flow/index.html) feature that lets you "create LLM apps using a Python class or function as the entry point" - making it easier to test and run them using a code-first experience.
233-
- This sample implements a _Function based flow_
234-
- The entry point is the _get_response_ functionin `chat_request.py`
235-
236-
You can now [test the flow](https://microsoft.github.io/promptflow/how-to-guides/develop-a-flex-flow/function-based-flow.html#flow-test) in different ways:
237-
- Run it directly, like any Python script
238-
- Convert it to a flow, then use `pf flow test --flow ...`
239-
- Start a UI to chat with the flow using `pf flow test --flow ... --ui`
240-
241-
🌟 | Watch this space for more testing guidance.
242-
243-
244-
## Guidance
224+
This specific prompty takes 3 inputs: a `customer` object, a `documentation` object (that could be chat history) and a `question` string that represents the user query. You can now _load_, _execute_, and _trace_ individual prompty assets for a more granular prompt
245225
246226
### Region Availability
247227
@@ -270,14 +250,6 @@ This template uses [Managed Identity](https://learn.microsoft.com/entra/identity
270250
271251
Additionally, we have added a [GitHub Action tool](https://github.com/microsoft/security-devops-action) that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices we recommend anyone creating solutions based on our templates ensure that the [Github secret scanning](https://docs.github.com/code-security/secret-scanning/about-secret-scanning) setting is enabled in your repo.
272252
273-
274-
## Resources
275-
276-
* [Azure AI Studio Documentation](https://learn.microsoft.com/azure/ai-studio/)
277-
* [Promptflow/Prompty Documentation](https://microsoft.github.io/promptflow/reference/python-library-reference/promptflow-core/promptflow.core.html?highlight=prompty#promptflow.core.Prompty)
278-
* [Develop Python apps that use Azure AI services](https://learn.microsoft.com/azure/developer/python/azure-ai-for-python-developers)
279-
* Related Sample: [Process Automation: Speech to Text and Summarization with ACA](https://github.com/Azure-Samples/summarization-openai-python-promptflow/blob/main/README.md)
280-
281253
## Troubleshooting
282254
283255
Have questions or issues to report? Please [open a new issue](https://github.com/Azure-Samples/contoso-chat/issues) after first verifying that the same question or issue has not already been reported. In the latter case, please add any additional comments you may have, to the existing issue.

azure.yaml

+4-33
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2-
3-
name: contoso-chat
1+
name: contoso-chat-openai-prompty
42
metadata:
5-
template: contoso-chat@0.0.1-beta
6-
workflows:
7-
up:
8-
steps:
9-
- azd: provision
10-
- azd: deploy
3+
template: contoso-chat-openai-prompty@0.0.1
114
hooks:
125
postprovision:
136
posix:
@@ -20,27 +13,5 @@ hooks:
2013
continueOnError: false
2114
interactive: true
2215
run: infra/hooks/postprovision.ps1
23-
24-
25-
################################################################
26-
# The section below configures the new `ai.endpoint` resource
27-
# used for the Azure AI based chat service (application)
28-
################################################################
29-
services:
30-
chat:
31-
host: ai.endpoint
32-
language: python
33-
config:
34-
workspace: ${AZUREAI_PROJECT_NAME}
35-
environment:
36-
path: ./deployment/environment.yaml
37-
model:
38-
path: ./deployment/chat-model.yaml
39-
deployment:
40-
path: ./deployment/chat-deployment.yaml
41-
overrides:
42-
environment_variables.PRT_CONFIG_OVERRIDE: deployment.subscription_id=${AZURE_SUBSCRIPTION_ID},deployment.resource_group=${AZURE_RESOURCE_GROUP},deployment.workspace_name=${AZUREAI_PROJECT_NAME},deployment.endpoint_name=${AZUREAI_ENDPOINT_NAME},deployment.deployment_name=${AZUREAI_DEPLOYMENT_NAME}
43-
environment_variables.AZURE_OPENAI_ENDPOINT: ${AZURE_OPENAI_ENDPOINT}
44-
environment_variables.AZURE_OPENAI_API_VERSION: ${AZURE_OPENAI_API_VERSION}
45-
environment_variables.COSMOS_ENDPOINT: ${COSMOS_ENDPOINT}
46-
environment_variables.AZURE_SEARCH_ENDPOINT: ${AZURE_SEARCH_ENDPOINT}
16+
infra:
17+
provider: "bicep"

0 commit comments

Comments
 (0)