Skip to content

Commit

Permalink
Resolve confMerge branch 'main' into brynn/test-openai-1x
Browse files Browse the repository at this point in the history
Signed-off-by: Brynn Yin <[email protected]>
  • Loading branch information
brynn-code committed Nov 29, 2023
2 parents 52a90d5 + 686e4b2 commit 85cee97
Show file tree
Hide file tree
Showing 45 changed files with 790 additions and 269 deletions.
20 changes: 10 additions & 10 deletions .github/actions/step_sdk_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ runs:
shell: pwsh
run: |
pip uninstall -y promptflow promptflow-sdk promptflow-tools
- name: 'Build and install: promptflow-tools'
shell: pwsh
run: |
Set-PSDebug -Trace 2
python ./setup.py bdist_wheel
$package = Get-ChildItem ./dist | ? { $_.Name.Contains('.whl')}
pip install $package.FullName
echo "########### pip freeze (After) ###########"
pip freeze
working-directory: src/promptflow-tools
- name: 'Build and install: promptflow with extra'
if: inputs.setupType == 'promptflow_with_extra'
shell: pwsh
Expand All @@ -52,3 +42,13 @@ runs:
echo "########### pip freeze ###########"
pip freeze
working-directory: ${{ inputs.scriptPath }}
- name: 'Build and install: promptflow-tools'
shell: pwsh
run: |
Set-PSDebug -Trace 2
python ./setup.py bdist_wheel
$package = Get-ChildItem ./dist | ? { $_.Name.Contains('.whl')}
pip install $package.FullName
echo "########### pip freeze (After) ###########"
pip freeze
working-directory: src/promptflow-tools
72 changes: 54 additions & 18 deletions .github/workflows/promptflow-executor-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: true
executor_e2e_tests:
build:
needs: authorize
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -40,26 +38,61 @@ jobs:
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
if [ "ubuntu-latest" == "${{ matrix.os }}" ]; then
export pyVersion="3.9";
elif [ "macos-latest" == "${{ matrix.os }}" ]; then
export pyVersion="3.10";
else
echo "Unsupported OS: ${{ matrix.os }}";
exit 1;
fi
env | sort >> $GITHUB_OUTPUT
id: display_env
shell: bash
- name: Python Setup - ${{ matrix.os }} - Python Version ${{ steps.display_env.outputs.pyVersion }}
shell: bash -el {0}
- name: Python Setup - ubuntu-latest - Python Version 3.9
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: ${{ steps.display_env.outputs.pyVersion }}
pythonVersion: 3.9
- name: Build wheel
uses: "./.github/actions/step_sdk_setup"
with:
setupType: ${{ env.packageSetupType }}
setupType: promptflow_with_extra
scriptPath: ${{ env.testWorkingDirectory }}
- name: Upload Wheel
if: always()
uses: actions/upload-artifact@v3
with:
name: wheel
path: |
${{ github.workspace }}/src/promptflow/dist/*.whl
${{ github.workspace }}/src/promptflow-tools/dist/*.whl
executor_e2e_tests:
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Python Setup - ${{ matrix.os }} - Python Version 3.9
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: 3.9
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: wheel
path: artifacts
- name: Install wheel
shell: pwsh
working-directory: artifacts
run: |
Set-PSDebug -Trace 1
pip install promptflow-tools
# Pin the openai version for sdk cli tests because pf and pf-tools which support openai 1.x aren't published to PyPi
# TODO: Remove restriction on openai version after pf-tools package which supports openai 1.x is published
pip install openai==0.27.10
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
pip freeze
- name: Azure Login
uses: azure/login@v1
with:
Expand Down Expand Up @@ -92,7 +125,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Python ${{ steps.display_env.outputs.pyVersion }}) (OS ${{ matrix.os }})
name: Test Results (Python 3.9) (OS ${{ matrix.os }})
path: |
${{ github.workspace }}/*.xml
${{ github.workspace }}/htmlcov/
Expand All @@ -104,9 +137,12 @@ jobs:
if: always()
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Publish Test Results
uses: "./.github/actions/step_publish_test_results"
with:
Expand Down
75 changes: 58 additions & 17 deletions .github/workflows/promptflow-executor-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: true
executor_unit_tests:
build:
needs: authorize
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -40,26 +38,66 @@ jobs:
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
if [ "ubuntu-latest" == "${{ matrix.os }}" ]; then
export pyVersion="3.9";
elif [ "macos-latest" == "${{ matrix.os }}" ]; then
export pyVersion="3.10";
else
echo "Unsupported OS: ${{ matrix.os }}";
exit 1;
fi
env | sort >> $GITHUB_OUTPUT
id: display_env
shell: bash -el {0}
- name: Python Setup - ${{ matrix.os }} - Python Version ${{ steps.display_env.outputs.pyVersion }}
- name: Python Setup - ubuntu-latest - Python Version 3.9
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: ${{ steps.display_env.outputs.pyVersion }}
pythonVersion: 3.9
- name: Build wheel
uses: "./.github/actions/step_sdk_setup"
with:
setupType: ${{ env.packageSetupType }}
setupType: promptflow_with_extra
scriptPath: ${{ env.testWorkingDirectory }}
- name: Upload Wheel
if: always()
uses: actions/upload-artifact@v3
with:
name: wheel
path: |
${{ github.workspace }}/src/promptflow/dist/*.whl
${{ github.workspace }}/src/promptflow-tools/dist/*.whl
executor_unit_tests:
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
env | sort >> $GITHUB_OUTPUT
id: display_env
shell: bash -el {0}
- name: Python Setup - ${{ matrix.os }} - Python Version 3.9
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: 3.9
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: wheel
path: artifacts
- name: Install wheel
shell: pwsh
working-directory: artifacts
run: |
Set-PSDebug -Trace 1
pip install promptflow-tools
# Pin the openai version for sdk cli tests because pf and pf-tools which support openai 1.x aren't published to PyPi
# TODO: Remove restriction on openai version after pf-tools package which supports openai 1.x is published
pip install openai==0.27.10
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
pip freeze
- name: Azure Login
uses: azure/login@v1
with:
Expand Down Expand Up @@ -90,7 +128,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results (Python ${{ steps.display_env.outputs.pyVersion }}) (OS ${{ matrix.os }})
name: Test Results (Python 3.9) (OS ${{ matrix.os }})
path: |
${{ github.workspace }}/*.xml
${{ github.workspace }}/htmlcov/
Expand All @@ -103,9 +141,12 @@ jobs:

steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Publish Test Results
uses: "./.github/actions/step_publish_test_results"
with:
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/promptflow-sdk-cli-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jobs:
pip install -r ${{ github.workspace }}/src/promptflow/dev_requirements.txt
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
# Pin the openai version for sdk cli tests because pf and pf-tools which support openai 1.x aren't published to PyPi
# TODO: Remove restriction on openai version after pf-tools package which supports openai 1.x is published
pip install openai==0.28.0
pip freeze
- name: Azure login (non pull_request workflow)
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -115,10 +112,9 @@ jobs:
working-directory: artifacts
run: |
Set-PSDebug -Trace 1
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[executable]" --force}}
# Pin the openai version for sdk cli tests because pf and pf-tools which support openai 1.x aren't published to PyPi
# TODO: Remove restriction on openai version after pf package which supports openai 1.x is published
pip install openai==0.28.0
pip uninstall -y promptflow promptflow-sdk promptflow-tools
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[executable]"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Run SDK CLI Executable Test
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion docs/cloud/azureai/manage-flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To create a flow to Azure from local flow directory, you can use
pfazure flow create --flow <path-to-flow-folder>

# create the flow with metadata
pfazure flow create --flow <path-to-flow-folder> --set display-name=<display-name> description=<description> tags.key1=value1
pfazure flow create --flow <path-to-flow-folder> --set display_name=<display-name> description=<description> tags.key1=value1
```

After the flow is created successfully, you can see the flow summary in the command line.
Expand Down
1 change: 1 addition & 0 deletions docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tools-reference/faiss_index_lookup_tool
tools-reference/vector_db_lookup_tool
tools-reference/embedding_tool
tools-reference/open_source_llm_tool
tools-reference/openai-gpt-4v-tool
```

```{toctree}
Expand Down
43 changes: 43 additions & 0 deletions docs/reference/tools-reference/openai-gpt-4v-tool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# OpenAI GPT-4V

## Introduction
OpenAI GPT-4V tool enables you to leverage OpenAI's GPT-4 with vision, also referred to as GPT-4V or gpt-4-vision-preview in the API, to take images as input and answer questions about them.

## Prerequisites

- Create OpenAI resources

Sign up account [OpenAI website](https://openai.com/)
Login and [Find personal API key](https://platform.openai.com/account/api-keys)

- Get Access to GPT-4 API

To use GPT-4 with vision, you need access to GPT-4 API. Learn more about [How to get access to GPT-4 API](https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4)

## Connection

Setup connections to provisioned resources in prompt flow.

| Type | Name | API KEY |
|-------------|----------|----------|
| OpenAI | Required | Required |

## Inputs

| Name | Type | Description | Required |
|------------------------|-------------|------------------------------------------------------------------------------------------------|----------|
| connection | OpenAI | the OpenAI connection to be used in the tool | Yes |
| model | string | the language model to use, currently only support gpt-4-vision-preview | Yes |
| prompt | string | The text prompt that the language model will use to generate it's response. | Yes |
| max\_tokens | integer | the maximum number of tokens to generate in the response. Default is a low value decided by [OpenAI API](https://platform.openai.com/docs/guides/vision). | No |
| temperature | float | the randomness of the generated text. Default is 1. | No |
| stop | list | the stopping sequence for the generated text. Default is null. | No |
| top_p | float | the probability of using the top choice from the generated tokens. Default is 1. | No |
| presence\_penalty | float | value that controls the model's behavior with regards to repeating phrases. Default is 0. | No |
| frequency\_penalty | float | value that controls the model's behavior with regards to generating rare phrases. Default is 0. | No |

## Outputs

| Return Type | Description |
|-------------|------------------------------------------|
| string | The text of one response of conversation |
3 changes: 1 addition & 2 deletions src/promptflow-tools/promptflow/tools/openai_gpt4v.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def chat(
model: str = "gpt-4-vision-preview",
temperature: float = 1.0,
top_p: float = 1.0,
n: int = 1,
# stream is a hidden to the end user, it is only supposed to be set by the executor.
stream: bool = False,
stop: list = None,
Expand All @@ -49,7 +48,7 @@ def chat(
"messages": messages,
"temperature": temperature,
"top_p": top_p,
"n": n,
"n": 1,
"stream": stream,
"presence_penalty": presence_penalty,
"frequency_penalty": frequency_penalty,
Expand Down
4 changes: 0 additions & 4 deletions src/promptflow-tools/promptflow/tools/yamls/openai_gpt4v.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ promptflow.tools.openai_gpt4v.OpenAI.chat:
default: 1
type:
- double
n:
default: 1
type:
- int
max_tokens:
default: ""
type:
Expand Down
3 changes: 3 additions & 0 deletions src/promptflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@

- [SDK/CLI] Fix node test with dict node input will raise "Required input(s) missing".
- [SDK/CLI] Will use run name as display name when display name not specified (used flow folder name before).
- [SDK/CLI] Fix pf flow build created unexpected layer of dist folder

### Improvements
- Force 'az login' if using azureml connection provider in cli command.
- Add env variable 'PF_NO_INTERACTIVE_LOGIN' to disable interactive login if using azureml connection provider in promptflow sdk.
- Improved CLI invoke time.
- Bump `pydash` upper bound to 8.0.0.
- Bump `SQLAlchemy` upper bound to 3.0.0.
- Bump `flask` upper bound to 4.0.0, `flask-restx` upper bound to 2.0.0.
- Bump `ruamel.yaml` upper bound to 1.0.0.

## 1.0.0 (2023.11.09)

Expand Down
2 changes: 1 addition & 1 deletion src/promptflow/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mock
nox
portalocker~=1.2
pre-commit
promptflow-tools
# promptflow-tools Comment this since it will take in unecessary dependencies
pydash
PyJWT==2.8.0 # parse token to get tenant id during sanitization
pytest
Expand Down
Loading

0 comments on commit 85cee97

Please sign in to comment.