-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yalu4
committed
Oct 20, 2023
1 parent
84c8279
commit 2c6a3c3
Showing
14 changed files
with
383 additions
and
34 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
...ows/samples_flows_standard_flow_with_package_tool_using_custom_strong_type_connection.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# This code is autogenerated. | ||
# Code is generated by running custom script: python3 readme.py | ||
# Any manual changes to this file may cause incorrect behavior. | ||
# Any manual changes will be overwritten if the code is regenerated. | ||
|
||
name: samples_flows_standard_flow_with_package_tool_using_custom_strong_type_connection | ||
on: | ||
schedule: | ||
- cron: "38 19 * * *" # Every day starting at 3:38 BJT | ||
pull_request: | ||
branches: [ main ] | ||
paths: [ examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection/**, examples/*requirements.txt, .github/workflows/samples_flows_standard_flow_with_package_tool_using_custom_strong_type_connection.yml ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
samples_readme_ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Python 3.9 environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
- name: Generate config.json | ||
run: echo '${{ secrets.TEST_WORKSPACE_CONFIG_JSON_CANARY }}' > ${{ github.workspace }}/examples/config.json | ||
- name: Prepare requirements | ||
working-directory: examples | ||
run: | | ||
if [[ -e requirements.txt ]]; then | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
fi | ||
- name: Prepare dev requirements | ||
working-directory: examples | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r dev_requirements.txt | ||
- name: Refine .env file | ||
working-directory: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
run: | | ||
AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} | ||
AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) | ||
if [[ -e .env.example ]]; then | ||
echo "env replacement" | ||
sed -i -e "s/<your_AOAI_key>/$AOAI_API_KEY/g" -e "s/<your_AOAI_endpoint>/$AOAI_API_ENDPOINT/g" .env.example | ||
mv .env.example .env | ||
fi | ||
- name: Create run.yml | ||
working-directory: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
run: | | ||
gpt_base=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
gpt_base=$(echo ${gpt_base//\//\\/}) | ||
if [[ -e run.yml ]]; then | ||
sed -i -e "s/\${azure_open_ai_connection.api_key}/${{ secrets.AOAI_API_KEY_TEST }}/g" -e "s/\${azure_open_ai_connection.api_base}/$gpt_base/g" run.yml | ||
fi | ||
- name: Azure Login | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
- name: Extract Steps examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection/README.md | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
python scripts/readme/extract_steps_from_readme.py -f examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection/README.md -o examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
- name: Cat script | ||
working-directory: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
run: | | ||
cat bash_script.sh | ||
- name: Run scripts | ||
working-directory: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
run: | | ||
export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} | ||
export aoai_api_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 }} | ||
bash bash_script.sh | ||
- name: Pip List for Debug | ||
if : ${{ always() }} | ||
working-directory: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection | ||
run: | | ||
pip list | ||
- name: Upload artifact | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact | ||
path: examples/flows/standard/flow-with-package-tool-using-custom-strong-type-connection/bash_script.sh |
89 changes: 89 additions & 0 deletions
89
...lows/samples_flows_standard_flow_with_script_tool_using_custom_strong_type_connection.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# This code is autogenerated. | ||
# Code is generated by running custom script: python3 readme.py | ||
# Any manual changes to this file may cause incorrect behavior. | ||
# Any manual changes will be overwritten if the code is regenerated. | ||
|
||
name: samples_flows_standard_flow_with_script_tool_using_custom_strong_type_connection | ||
on: | ||
schedule: | ||
- cron: "13 20 * * *" # Every day starting at 4:13 BJT | ||
pull_request: | ||
branches: [ main ] | ||
paths: [ examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/**, examples/*requirements.txt, .github/workflows/samples_flows_standard_flow_with_script_tool_using_custom_strong_type_connection.yml ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
samples_readme_ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Python 3.9 environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
- name: Generate config.json | ||
run: echo '${{ secrets.TEST_WORKSPACE_CONFIG_JSON_CANARY }}' > ${{ github.workspace }}/examples/config.json | ||
- name: Prepare requirements | ||
working-directory: examples | ||
run: | | ||
if [[ -e requirements.txt ]]; then | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
fi | ||
- name: Prepare dev requirements | ||
working-directory: examples | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r dev_requirements.txt | ||
- name: Refine .env file | ||
working-directory: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
run: | | ||
AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} | ||
AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) | ||
if [[ -e .env.example ]]; then | ||
echo "env replacement" | ||
sed -i -e "s/<your_AOAI_key>/$AOAI_API_KEY/g" -e "s/<your_AOAI_endpoint>/$AOAI_API_ENDPOINT/g" .env.example | ||
mv .env.example .env | ||
fi | ||
- name: Create run.yml | ||
working-directory: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
run: | | ||
gpt_base=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
gpt_base=$(echo ${gpt_base//\//\\/}) | ||
if [[ -e run.yml ]]; then | ||
sed -i -e "s/\${azure_open_ai_connection.api_key}/${{ secrets.AOAI_API_KEY_TEST }}/g" -e "s/\${azure_open_ai_connection.api_base}/$gpt_base/g" run.yml | ||
fi | ||
- name: Azure Login | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
- name: Extract Steps examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/README.md | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
python scripts/readme/extract_steps_from_readme.py -f examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/README.md -o examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
- name: Cat script | ||
working-directory: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
run: | | ||
cat bash_script.sh | ||
- name: Run scripts | ||
working-directory: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
run: | | ||
export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} | ||
export aoai_api_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 }} | ||
bash bash_script.sh | ||
- name: Pip List for Debug | ||
if : ${{ always() }} | ||
working-directory: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection | ||
run: | | ||
pip list | ||
- name: Upload artifact | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact | ||
path: examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/bash_script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...s/standard/flow-with-package-tool-using-custom-strong-type-connection/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Basic flow with package tool using custom strong type connection | ||
A basic standard flow that using custom python tool calls Azure OpenAI with connection info stored in custom connection. | ||
|
||
Tools used in this flow: | ||
- custom package Tool | ||
|
||
Connections used in this flow: | ||
- custom strong type connection | ||
|
||
## Prerequisites | ||
|
||
Install promptflow sdk and other dependencies: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Setup connection | ||
Create connection if you haven't done that. | ||
```bash | ||
# Override keys with --set to avoid yaml file changes | ||
pf connection create -f my_custom_connection.yml --set secrets.api_key=<your_api_key> configs.api_base=<your_api_base> | ||
``` | ||
|
||
Ensure you have created `my_custom_connection` connection. | ||
```bash | ||
pf connection show -n my_custom_connection | ||
``` | ||
|
||
## Run flow | ||
|
||
### Run with single line input | ||
|
||
```bash | ||
# test with default input value in flow.dag.yaml | ||
pf flow test --flow . | ||
|
||
# test with flow inputs | ||
pf flow test --flow . --inputs text="Promptflow" | ||
|
||
|
||
### Run with multiple lines data | ||
|
||
- create run | ||
```bash | ||
pf run create --flow . --data ./data.jsonl --stream | ||
``` | ||
|
||
- list and show run meta | ||
```bash | ||
# list created run | ||
pf run list -r 3 | ||
# get a sample run name | ||
name=$(pf run list -r 10 | jq '.[] | select(.name | contains("custom_strong_type")) | .name'| head -n 1 | tr -d '"') | ||
# show specific run detail | ||
pf run show --name $name | ||
# show output | ||
pf run show-details --name $name | ||
# visualize run in browser | ||
pf run visualize --name $name | ||
``` | ||
|
||
### Run with connection override | ||
|
||
Run flow with newly created connection. | ||
|
||
```bash | ||
pf run create --flow . --data ./data.jsonl --connections my_package_tool.connection=my_custom_connection --stream | ||
``` | ||
|
||
### Run in cloud with connection override | ||
|
||
Ensure you have created `my_custom_connection` connection in cloud. Reference [this notebook](../../../tutorials/get-started/quickstart-azure.ipynb) on how to create connections in cloud with UI. | ||
|
||
Run flow with connection `my_custom_connection`. | ||
|
||
```bash | ||
# set default workspace | ||
az account set -s <your_subscription_id> | ||
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name> | ||
pfazure run create --flow . --data ./data.jsonl --connections my_package_tool.connection=my_custom_connection --stream --runtime demo-mir | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ndard/flow-with-package-tool-using-custom-strong-type-connection/my_custom_connection.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "to_replace_with_connection_name" | ||
type: custom | ||
custom_type: MyCustomConnection | ||
module: my_tool_package.tools.my_tool_with_custom_strong_type_connection | ||
package: test-custom-tools | ||
package_version: 0.0.2 | ||
configs: | ||
api_url: "This is a fake api url." # String, The api url. | ||
secrets: | ||
api_key: <user-input> # Don't replace the '<user-input>' placeholder. The application will prompt you to enter a value when it runs. |
86 changes: 86 additions & 0 deletions
86
...ws/standard/flow-with-script-tool-using-custom-strong-type-connection/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Basic flow with script tool using custom strong type connection | ||
A basic standard flow that using custom python tool calls Azure OpenAI with connection info stored in custom connection. | ||
|
||
Tools used in this flow: | ||
- custom `python` Tool | ||
|
||
Connections used in this flow: | ||
- custom strong type connection | ||
|
||
## Prerequisites | ||
|
||
Install promptflow sdk and other dependencies: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Setup connection | ||
Create connection if you haven't done that. | ||
```bash | ||
# Override keys with --set to avoid yaml file changes | ||
pf connection create -f custom.yml --set secrets.api_key=<your_api_key> configs.api_base=<your_api_base> | ||
``` | ||
|
||
Ensure you have created `normal_custom_connection` connection. | ||
```bash | ||
pf connection show -n normal_custom_connection | ||
``` | ||
|
||
## Run flow | ||
|
||
### Run with single line input | ||
|
||
```bash | ||
# test with default input value in flow.dag.yaml | ||
pf flow test --flow . | ||
|
||
# test with flow inputs | ||
pf flow test --flow . --inputs text="Promptflow" | ||
|
||
|
||
### Run with multiple lines data | ||
|
||
- create run | ||
```bash | ||
pf run create --flow . --data ./data.jsonl --stream | ||
``` | ||
|
||
- list and show run meta | ||
```bash | ||
# list created run | ||
pf run list -r 3 | ||
# get a sample run name | ||
name=$(pf run list -r 10 | jq '.[] | select(.name | contains("custom_strong_type")) | .name'| head -n 1 | tr -d '"') | ||
# show specific run detail | ||
pf run show --name $name | ||
# show output | ||
pf run show-details --name $name | ||
# visualize run in browser | ||
pf run visualize --name $name | ||
``` | ||
|
||
### Run with connection override | ||
|
||
Run flow with newly created connection. | ||
|
||
```bash | ||
pf run create --flow . --data ./data.jsonl --connections my_script_tool.connection=normal_custom_connection --stream | ||
``` | ||
|
||
### Run in cloud with connection override | ||
|
||
Ensure you have created `normal_custom_connection` connection in cloud. Reference [this notebook](../../../tutorials/get-started/quickstart-azure.ipynb) on how to create connections in cloud with UI. | ||
|
||
Run flow with connection `normal_custom_connection`. | ||
|
||
```bash | ||
# set default workspace | ||
az account set -s <your_subscription_id> | ||
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name> | ||
pfazure run create --flow . --data ./data.jsonl --connections my_script_tool.connection=normal_custom_connection --stream --runtime demo-mir | ||
``` |
7 changes: 7 additions & 0 deletions
7
examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/custom.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json | ||
name: normal_custom_connection | ||
type: custom | ||
configs: | ||
api_base: test | ||
secrets: # must-have | ||
api_key: <to-be-replaced> |
4 changes: 3 additions & 1 deletion
4
examples/flows/standard/flow-with-script-tool-using-custom-strong-type-connection/data.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
{"my_input": "hello world!"} | ||
{"text": "Python Hello World!"} | ||
{"text": "C Hello World!"} | ||
{"text": "C# Hello World!"} |
Oops, something went wrong.