From 8d6586099b181cb18c879693151739b9cca5d2bf Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Wed, 17 Jan 2024 23:15:06 -0800 Subject: [PATCH] Support for Python 3.12 (#1317) * 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 --- .github/workflows/build.yml | 15 +++++---- .github/workflows/contrib-tests.yml | 22 +++++++------- .github/workflows/openai.yml | 14 ++++----- README.md | 4 +-- notebook/agentchat_function_call_async.ipynb | 10 +++--- setup.py | 2 +- test/test_notebook.py | 32 ++++++++++---------- website/docs/Installation.md | 2 +- 8 files changed, 50 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f1af9ab744..0f1d1ae238e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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] @@ -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 }} diff --git a/.github/workflows/contrib-tests.yml b/.github/workflows/contrib-tests.yml index 27a616b7719..47272e8b2eb 100644 --- a/.github/workflows/contrib-tests.yml +++ b/.github/workflows/contrib-tests.yml @@ -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 }} @@ -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 }} @@ -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 @@ -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 }} @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/openai.yml b/.github/workflows/openai.yml index 83679b58e38..461e2539b22 100644 --- a/.github/workflows/openai.yml +++ b/.github/workflows/openai.yml @@ -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: diff --git a/README.md b/README.md index 99131cb461f..2b39c45cd5d 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/notebook/agentchat_function_call_async.ipynb b/notebook/agentchat_function_call_async.ipynb index 613c733c3db..ca65291b2c0 100644 --- a/notebook/agentchat_function_call_async.ipynb +++ b/notebook/agentchat_function_call_async.ipynb @@ -15,7 +15,7 @@ "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", @@ -23,9 +23,9 @@ "\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", "```" ] }, @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "# %pip install \"pyautogen[mathchat]~=0.1.0\"" + "# %pip install \"pyautogen>=0.2.6\"" ] }, { @@ -390,7 +390,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/setup.py b/setup.py index 215e88980b6..92585afa271 100644 --- a/setup.py +++ b/setup.py @@ -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", ) diff --git a/test/test_notebook.py b/test/test_notebook.py index 109410dfc0e..b879cfe9e37 100644 --- a/test/test_notebook.py +++ b/test/test_notebook.py @@ -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) @@ -78,32 +78,32 @@ 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 @@ -111,8 +111,8 @@ def _test_hierarchy_flow_using_select_speaker(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.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) diff --git a/website/docs/Installation.md b/website/docs/Installation.md index 7360204692d..a04da82767d 100644 --- a/website/docs/Installation.md +++ b/website/docs/Installation.md @@ -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