Skip to content

Commit

Permalink
Support for Python 3.12 (microsoft#1317)
Browse files Browse the repository at this point in the history
* support for Python 3.12

* add python 3.12 to workflows

* version string fix

* retrieval chat

* teachability

* workflow

* redistribute notebook tests

* fix incorrect notebook introduction

* update banner; remove unused imports; update openai workflow

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
  • Loading branch information
ekzhu and sonichi committed Jan 18, 2024
1 parent 519e15a commit 8d65860
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 51 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ name: Build

on:
push:
branches: ['main']
branches: ["main"]
paths:
- 'autogen/**'
- 'test/**'
- '.github/workflows/build.yml'
- 'setup.py'
- "autogen/**"
- "test/**"
- ".github/workflows/build.yml"
- "setup.py"
pull_request:
branches: ['main']
branches: ["main"]
merge_group:
types: [checks_requested]

Expand All @@ -22,13 +22,12 @@ concurrency:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/contrib-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ name: ContribTests

on:
pull_request:
branches: ['main', 'dev/v0.2']
branches: ["main"]
paths:
- 'autogen/**'
- 'test/agentchat/contrib/**'
- '.github/workflows/contrib-tests.yml'
- 'setup.py'
- "autogen/**"
- "test/agentchat/contrib/**"
- ".github/workflows/contrib-tests.yml"
- "setup.py"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -82,7 +82,7 @@ jobs:
run: |
pip install -e .
- name: Test Compression
if: matrix.python-version != '3.10' # diversify the python versions
if: matrix.python-version != '3.10' # diversify the python versions
run: |
pytest test/agentchat/contrib/test_compressible_agent.py --skip-openai
- name: Coverage
Expand All @@ -104,7 +104,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -119,7 +119,7 @@ jobs:
run: |
pip install -e .
- name: Test GPTAssistantAgent
if: matrix.python-version != '3.11' # diversify the python versions
if: matrix.python-version != '3.11' # diversify the python versions
run: |
pytest test/agentchat/contrib/test_gpt_assistant.py --skip-openai
- name: Coverage
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
run: |
pip install -e .[teachable]
- name: Test TeachableAgent
if: matrix.python-version != '3.9' # diversify the python versions
if: matrix.python-version != '3.9' # diversify the python versions
run: |
pytest test/agentchat/contrib/test_teachable_agent.py --skip-openai
- name: Coverage
Expand All @@ -178,7 +178,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ name: OpenAI

on:
pull_request_target:
branches: ['main']
branches: ["main"]
paths:
- 'autogen/**'
- 'test/**'
- 'notebook/agentchat_auto_feedback_from_code_execution.ipynb'
- 'notebook/agentchat_function_call.ipynb'
- '.github/workflows/openai.yml'
- "autogen/**"
- "test/**"
- "notebook/agentchat_auto_feedback_from_code_execution.ipynb"
- "notebook/agentchat_function_call.ipynb"
- ".github/workflows/openai.yml"

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
environment: openai1
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![PyPI version](https://badge.fury.io/py/pyautogen.svg)](https://badge.fury.io/py/pyautogen)
[![Build](https://github.com/microsoft/autogen/actions/workflows/python-package.yml/badge.svg)](https://github.com/microsoft/autogen/actions/workflows/python-package.yml)
![Python Version](https://img.shields.io/badge/3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)
![Python Version](https://img.shields.io/badge/3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
[![Downloads](https://static.pepy.tech/badge/pyautogen/week)](https://pepy.tech/project/pyautogen)
[![](https://img.shields.io/discord/1153072414184452236?logo=discord&style=flat)](https://discord.gg/pAbnFJrkgZ)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen)
Expand Down Expand Up @@ -69,7 +69,7 @@ Find detailed instructions for users [here](https://microsoft.github.io/autogen/

### Option 2. Install AutoGen Locally

AutoGen requires **Python version >= 3.8, < 3.12**. It can be installed from pip:
AutoGen requires **Python version >= 3.8, < 3.13**. It can be installed from pip:

```bash
pip install pyautogen
Expand Down
10 changes: 5 additions & 5 deletions notebook/agentchat_function_call_async.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"id": "9a71fa36",
"metadata": {},
"source": [
"# Auto Generated Agent Chat: Task Solving with Provided Tools as Functions\n",
"# Auto Generated Agent Chat: Task Solving with Provided Tools as Functions (Asynchronous Function Calls)\n",
"\n",
"AutoGen offers conversable agents powered by LLM, tool, or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation. Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
"\n",
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to make function calls with the new feature of OpenAI models (in model version 0613). A specified prompt and function configs must be passed to `AssistantAgent` to initialize the agent. The corresponding functions must be passed to `UserProxyAgent`, which will execute any function calls made by `AssistantAgent`. Besides this requirement of matching descriptions with functions, we recommend checking the system message in the `AssistantAgent` to ensure the instructions align with the function call descriptions.\n",
"\n",
"## Requirements\n",
"\n",
"AutoGen requires `Python>=3.8`. To run this notebook example, please install the [mathchat] option since we will import functions from `MathUserProxyAgent`:\n",
"AutoGen requires `Python>=3.8`. To run this notebook example, please install `pyautogen`:\n",
"```bash\n",
"pip install \"pyautogen[mathchat]\"\n",
"pip install pyautogen\n",
"```"
]
},
Expand All @@ -36,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
"# %pip install \"pyautogen[mathchat]~=0.1.0\""
"# %pip install \"pyautogen>=0.2.6\""
]
},
{
Expand Down Expand Up @@ -390,7 +390,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.8, <3.12",
python_requires=">=3.8,<3.13",
)
32 changes: 16 additions & 16 deletions test/test_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ def run_notebook(input_nb, output_nb="executed_openai_notebook.ipynb", save=Fals


@pytest.mark.skipif(
skip or not sys.version.startswith("3.11"),
reason="do not run if openai is not installed or py!=3.11",
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
)
def test_agentchat_auto_feedback_from_code(save=False):
run_notebook("agentchat_auto_feedback_from_code_execution.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.11"),
reason="do not run if openai is not installed or py!=3.11",
)
def _test_oai_completion(save=False):
run_notebook("oai_completion.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.12"),
reason="do not run if openai is not installed or py!=3.12",
)
def test_agentchat_function_call(save=False):
run_notebook("agentchat_function_call.ipynb", save=save)
Expand All @@ -78,41 +78,41 @@ def test_agentchat_function_call_currency_calculator(save=False):


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.11"),
reason="do not run if openai is not installed or py!=3.11",
)
def test_agentchat_function_call_async(save=False):
run_notebook("agentchat_function_call_async.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.12"),
reason="do not run if openai is not installed or py!=3.12",
)
def _test_agentchat_MathChat(save=False):
run_notebook("agentchat_MathChat.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.11"),
reason="do not run if openai is not installed or py!=3.11",
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
)
def _test_oai_chatgpt_gpt4(save=False):
run_notebook("oai_chatgpt_gpt4.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.11"),
reason="do not run if openai is not installed or py!=3.11",
)
def _test_hierarchy_flow_using_select_speaker(save=False):
# TODO: recover this test after rewriting after the new group chat api
run_notebook("agentchat_hierarchy_flow_using_select_speaker.ipynb", save=save)


@pytest.mark.skipif(
skip or not sys.version.startswith("3.10"),
reason="do not run if openai is not installed or py!=3.10",
skip or not sys.version.startswith("3.12"),
reason="do not run if openai is not installed or py!=3.12",
)
def test_graph_modelling_language_using_select_speaker(save=False):
run_notebook("agentchat_graph_modelling_language_using_select_speaker.ipynb", save=save)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Now, you're ready to install AutoGen in the virtual environment you've just crea

## Python

AutoGen requires **Python version >= 3.8, < 3.12**. It can be installed from pip:
AutoGen requires **Python version >= 3.8, < 3.13**. It can be installed from pip:

```bash
pip install pyautogen
Expand Down

0 comments on commit 8d65860

Please sign in to comment.