From f734115cbd1cce1327a03800f30c6b4d62d97f37 Mon Sep 17 00:00:00 2001 From: Ashley Evans Date: Wed, 26 Nov 2025 15:21:53 +0000 Subject: [PATCH 1/2] chore(deps): bump openai support to v2+ --- .github/workflows/pr.yml | 4 ++-- README.md | 4 ++-- examples/test_langchain_openai.py | 3 +-- pyproject.toml | 8 ++++---- src/openai_responses/_routes/_base.py | 4 +++- src/openai_responses/_routes/beta/vector_stores.py | 3 ++- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 13833ed..e398184 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout branch uses: actions/checkout@v3 @@ -21,7 +21,7 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 - + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: diff --git a/README.md b/README.md index c9652cb..3d56fa1 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Pytest plugin for automatically mocking OpenAI requests. Powered by [RESPX](https://github.com/lundberg/respx). -[![sdk support](https://img.shields.io/badge/SDK_Support-v1.66+-white?logo=openai&logoColor=black&labelColor=white)](https://github.com/openai/openai-python) +[![sdk support](https://img.shields.io/badge/SDK_Support-v2.0+-white?logo=openai&logoColor=black&labelColor=white)](https://github.com/openai/openai-python) > [!NOTE] > This project is in maintenance mode unless I see an appetite for more community contributions. I built this because we at [Definite](https://definite.app) needed a way to easily and quickly test the integration between [openai-python](https://github.com/openai/openai-python) and our codebase but we have [moved on to other frameworks/SDKs](https://pydantic.dev/articles/building-data-team-with-pydanticai). With that, my need and desire to work on this library has dropped significantly. -> +> > I will be encouraging community contributions to fill in the gap for some of the new features released since the last major update to this library such as [evals](https://platform.openai.com/docs/api-reference/evals), [graders](https://platform.openai.com/docs/api-reference/graders), [containers](https://platform.openai.com/docs/api-reference/containers), and all of the new [administration](https://platform.openai.com/docs/api-reference/administration) endpoints. > > Absent community contributions, if the work required just for maintenance mode becomes too much (>2 hours a month) then this project will be fully deprecated and archived. diff --git a/examples/test_langchain_openai.py b/examples/test_langchain_openai.py index 16f466b..e1a8281 100644 --- a/examples/test_langchain_openai.py +++ b/examples/test_langchain_openai.py @@ -1,5 +1,5 @@ from langchain_openai import ChatOpenAI -from pydantic.v1 import SecretStr +from pydantic import SecretStr import openai_responses from openai_responses import OpenAIMock @@ -24,7 +24,6 @@ def test_langchain_chat_openai_invoke(openai_mock: OpenAIMock): name="My Custom Chatbot", model="gpt-4o", temperature=0, - max_tokens=None, timeout=None, max_retries=2, api_key=SecretStr("sk-fake123"), diff --git a/pyproject.toml b/pyproject.toml index 5fffe0a..1be6c20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,14 +19,14 @@ classifiers = [ openai_responses = "openai_responses.plugin" [tool.poetry.dependencies] -python = ">=3.9,<4.0" -openai = ">=1.66,<2.0" +python = ">=3.10,<4.0" +openai = ">=2.0,<3.0" requests-toolbelt = "^1" respx = "^0.22.0" [tool.poetry.group.dev.dependencies] black = "^24.2.0" -langchain-openai = "^0.1.20" +langchain-openai = "^1.1.0" mypy = "^1.9.0" pytest = "^8.1.1" pytest-asyncio = "^0.23.6" @@ -42,7 +42,7 @@ ignore_missing_imports = true [tool.pyright] typeCheckingMode = "strict" -pythonVersion = "3.9" +pythonVersion = "3.10" exclude = [".venv"] venvPath = "." venv = ".venv" diff --git a/src/openai_responses/_routes/_base.py b/src/openai_responses/_routes/_base.py index 19d6dbe..ac238b8 100644 --- a/src/openai_responses/_routes/_base.py +++ b/src/openai_responses/_routes/_base.py @@ -70,7 +70,9 @@ def _handler(request: httpx.Request, route: respx.Route, **kwargs: Any): assert not callable(self._response) return httpx.Response( status_code=self._status_code, - json=model_dict(self._build(self._response, request), by_alias=True), + json=model_dict( + self._build(self._response, request), by_alias=True + ), ) return _handler diff --git a/src/openai_responses/_routes/beta/vector_stores.py b/src/openai_responses/_routes/beta/vector_stores.py index 3b051b3..be949f8 100644 --- a/src/openai_responses/_routes/beta/vector_stores.py +++ b/src/openai_responses/_routes/beta/vector_stores.py @@ -5,6 +5,7 @@ import httpx import respx +from openai._types import SequenceNotStr from openai.pagination import SyncCursorPage from openai.types.vector_store import VectorStore from openai.types.vector_store_create_params import VectorStoreCreateParams @@ -49,7 +50,7 @@ def _handler(self, request: httpx.Request, route: respx.Route) -> httpx.Response model = self._build({}, request) self._state.vector_stores.put(model) content: VectorStoreCreateParams = json_loads(request.content) - file_ids = content.get("file_ids", []) + file_ids: SequenceNotStr[str] = content.get("file_ids", []) for file_id in file_ids: found_file = self._state.files.get(file_id) if not found_file: From edca4de0f987021900449bb955b2932d584ad0f5 Mon Sep 17 00:00:00 2001 From: Michael Harris Date: Tue, 2 Dec 2025 14:10:33 -0700 Subject: [PATCH 2/2] chore(tox): suppress pytest warnings --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index b3b3780..3797727 100644 --- a/tox.ini +++ b/tox.ini @@ -27,8 +27,8 @@ commands = [testenv:unit] commands = - pytest tests/unit -v {posargs} + pytest tests/unit -p no:warnings -v {posargs} [testenv:pydantic{1,2}-examples] commands = - pytest examples -v {posargs} + pytest examples -p no:warnings -v {posargs}