Skip to content

add chat-with-pdf example #14

add chat-with-pdf example

add chat-with-pdf example #14

# 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_chat_chat_with_pdf
on:
schedule:
- cron: "4 22 * * *" # Every day starting at 6:4 BJT
pull_request:
branches: [ main ]
paths: [ examples/** ]
workflow_dispatch:
jobs:
auto_generated_steps:
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 }} > ${{ github.workspace }}/examples/config.json
- name: Prepare requirements
working-directory: examples/flows/chat/chat-with-pdf
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Prepare dev requirements
working-directory: examples
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.txt
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Refine .env file
working-directory: examples/flows/chat/chat-with-pdf
run: |
AOAI_API_KEY=${{ secrets.AOAI_API_KEY }}
AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT }}
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 AOAI Connection from ENV file
working-directory: ${{ github.workspace }}
run: |
pf connection create --file .env --name chat_with_pdf_custom_connection
pf connection list
- name: Create run.yml
working-directory: examples/flows/chat/chat-with-pdf
run: |
gpt_base=${{ secrets.AOAI_API_ENDPOINT }}
gpt_base=$(echo ${gpt_base//\//\\/})
if [[ -e run.yml ]]; then
sed -i -e "s/\${azure_open_ai_connection.api_key}/${{ secrets.AOAI_API_KEY }}/g" -e "s/\${azure_open_ai_connection.api_base}/$gpt_base/g" run.yml
fi
- name: Extract Steps
working-directory: ${{ github.workspace }}
run: |
python scripts/readme/extract_steps_from_readme.py -f examples/flows/chat/chat-with-pdf/README.md -o examples/flows/chat/chat-with-pdf
- name: Run scripts
working-directory: examples/flows/chat/chat-with-pdf
run: |
export aoai_api_key=${{secrets.AOAI_API_KEY }}
export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT }}
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 }}
bash bash_script.sh
- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: artifact
path: examples/flows/chat/chat-with-pdf/bash_script.sh