From 8acf9893e3e9990a0189ba971886f1eaefecc816 Mon Sep 17 00:00:00 2001 From: Clement Wang Date: Fri, 12 Apr 2024 19:12:56 +0800 Subject: [PATCH] refine env in workflow --- .github/workflows/samples_prompty_basic.yml | 7 ++++--- .github/workflows/samples_prompty_chat_basic.yml | 7 ++++--- .github/workflows/samples_prompty_eval_apology.yml | 7 ++++--- .github/workflows/samples_prompty_eval_basic.yml | 7 ++++--- .github/workflows/samples_tutorials_tracing.yml | 7 ++++--- examples/prompty/basic/prompty-quickstart.ipynb | 13 +++++++++++++ .../workflow_steps/step_create_env.yml.jinja2 | 3 --- .../step_extract_steps_and_run.yml.jinja2 | 4 ++++ 8 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/samples_prompty_basic.yml b/.github/workflows/samples_prompty_basic.yml index 694d46f035e..f53332b4763 100644 --- a/.github/workflows/samples_prompty_basic.yml +++ b/.github/workflows/samples_prompty_basic.yml @@ -41,11 +41,8 @@ jobs: working-directory: examples/prompty/basic run: | AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example @@ -82,6 +79,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -92,6 +91,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_PROD }} diff --git a/.github/workflows/samples_prompty_chat_basic.yml b/.github/workflows/samples_prompty_chat_basic.yml index 664fc435ab5..3edea145a1b 100644 --- a/.github/workflows/samples_prompty_chat_basic.yml +++ b/.github/workflows/samples_prompty_chat_basic.yml @@ -41,11 +41,8 @@ jobs: working-directory: examples/prompty/chat-basic run: | AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example @@ -82,6 +79,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -92,6 +91,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_PROD }} diff --git a/.github/workflows/samples_prompty_eval_apology.yml b/.github/workflows/samples_prompty_eval_apology.yml index 73d8751ca04..4c69e09f365 100644 --- a/.github/workflows/samples_prompty_eval_apology.yml +++ b/.github/workflows/samples_prompty_eval_apology.yml @@ -41,11 +41,8 @@ jobs: working-directory: examples/prompty/eval-apology run: | AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example @@ -82,6 +79,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -92,6 +91,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_PROD }} diff --git a/.github/workflows/samples_prompty_eval_basic.yml b/.github/workflows/samples_prompty_eval_basic.yml index 0ba68c54824..e690e054a7c 100644 --- a/.github/workflows/samples_prompty_eval_basic.yml +++ b/.github/workflows/samples_prompty_eval_basic.yml @@ -41,11 +41,8 @@ jobs: working-directory: examples/prompty/eval-basic run: | AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example @@ -82,6 +79,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -92,6 +91,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_PROD }} diff --git a/.github/workflows/samples_tutorials_tracing.yml b/.github/workflows/samples_tutorials_tracing.yml index 74840ac12c6..279495b93c4 100644 --- a/.github/workflows/samples_tutorials_tracing.yml +++ b/.github/workflows/samples_tutorials_tracing.yml @@ -41,11 +41,8 @@ jobs: working-directory: examples/tutorials/tracing run: | AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example @@ -82,6 +79,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -92,6 +91,8 @@ jobs: run: | export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_PROD }} diff --git a/examples/prompty/basic/prompty-quickstart.ipynb b/examples/prompty/basic/prompty-quickstart.ipynb index 596804a7170..5007f78c779 100644 --- a/examples/prompty/basic/prompty-quickstart.ipynb +++ b/examples/prompty/basic/prompty-quickstart.ipynb @@ -57,6 +57,19 @@ "Note: before running below cell, please configure required environment variable `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT` by create an `.env` file. Please refer to [.env.example](../.env.example) as an template." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import load_dotenv\n", + "\n", + "if \"AZURE_OPENAI_API_KEY\" not in os.environ:\n", + " # load environment variables from .env file\n", + " load_dotenv()" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/scripts/readme/ghactions_driver/workflow_steps/step_create_env.yml.jinja2 b/scripts/readme/ghactions_driver/workflow_steps/step_create_env.yml.jinja2 index cc4b28907b5..863e53104ee 100644 --- a/scripts/readme/ghactions_driver/workflow_steps/step_create_env.yml.jinja2 +++ b/scripts/readme/ghactions_driver/workflow_steps/step_create_env.yml.jinja2 @@ -2,11 +2,8 @@ working-directory: {{ working_dir }} run: | AOAI_API_KEY=${{ '{{' }} secrets.AOAI_API_KEY_TEST }} - AZURE_OPENAI_API_KEY=${{ '{{' }} secrets.AOAI_API_KEY_TEST }} AOAI_API_ENDPOINT=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) - AZURE_OPENAI_ENDPOINT=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} - AZURE_OPENAI_ENDPOINT=$(echo ${AZURE_OPENAI_ENDPOINT//\//\\/}) if [[ -e .env.example ]]; then echo "env replacement" sed -i -e "s//$AOAI_API_KEY/g" -e "s//$AOAI_API_ENDPOINT/g" .env.example diff --git a/scripts/readme/ghactions_driver/workflow_steps/step_extract_steps_and_run.yml.jinja2 b/scripts/readme/ghactions_driver/workflow_steps/step_extract_steps_and_run.yml.jinja2 index b76dd517409..2d868e3c2ea 100644 --- a/scripts/readme/ghactions_driver/workflow_steps/step_extract_steps_and_run.yml.jinja2 +++ b/scripts/readme/ghactions_driver/workflow_steps/step_extract_steps_and_run.yml.jinja2 @@ -12,6 +12,8 @@ run: | export aoai_api_key=${{ '{{' }}secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{ '{{' }}secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ '{{' }} secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ '{{' }} secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ '{{' }} secrets.TEST_WORKSPACE_NAME_CANARY }} @@ -22,6 +24,8 @@ run: | export aoai_api_key=${{ '{{' }}secrets.AOAI_API_KEY_TEST }} export aoai_api_endpoint=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} + export AZURE_OPENAI_API_KEY=${{ '{{' }}secrets.AOAI_API_KEY_TEST }} + export AZURE_OPENAI_ENDPOINT=${{ '{{' }} secrets.AOAI_API_ENDPOINT_TEST }} export test_workspace_sub_id=${{ '{{' }} secrets.TEST_WORKSPACE_SUB_ID }} export test_workspace_rg=${{ '{{' }} secrets.TEST_WORKSPACE_RG }} export test_workspace_name=${{ '{{' }} secrets.TEST_WORKSPACE_NAME_PROD }}