Skip to main content

🧪🤖 Pytest plugin for automatically mocking OpenAI requests

Project description

🧪🤖 openai-responses

Pytest plugin for automatically mocking OpenAI requests. Powered by RESPX.

sdk support

[!NOTE] This project is in maintenance mode unless I see an appetite for more community contributions. I built this because we at Definite needed a way to easily and quickly test the integration between openai-python and our codebase but we have moved on to other frameworks/SDKs. 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, graders, containers, and all of the new 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.

Supported Endpoints

View full support coverage here.

[!TIP] ✨ Support for creating streaming responses added in v0.4

Usage

Just decorate any test function that makes a call to the OpenAI API (either using openai-python or with HTTPX).

import openai

import openai_responses


@openai_responses.mock()
def test_create_assistant():
    client = openai.Client(api_key="sk-fake123")

    assistant = client.beta.assistants.create(
        instructions="You are a personal math tutor.",
        name="Math Tutor",
        tools=[{"type": "code_interpreter"}],
        model="gpt-4-turbo",
    )

    assert assistant.name == "Math Tutor"

See examples or docs for more.

Installation

PyPI version PyPI - Python Version PyPI - Downloads

Available on PyPI

pip install openai-responses

Documentation

Docs

See the documentation site for more info.

License

PyPI - License

See LICENSE for more info.

Contributing

Open Issues Stargazers

See CONTRIBUTING.md for info on PRs, issues, and feature requests.

Changelog

See CHANGELOG.md for summarized notes on changes or view releases for more details information on changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openai_responses-0.13.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openai_responses-0.13.1-py3-none-any.whl (51.9 kB view details)

Uploaded Python 3

File details

Details for the file openai_responses-0.13.1.tar.gz.

File metadata

  • Download URL: openai_responses-0.13.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.2 Linux/6.1.0-37-amd64

File hashes

Hashes for openai_responses-0.13.1.tar.gz
Algorithm Hash digest
SHA256 d0bc5f02e9fd355fed5d25794fa1aed548da23c5e8d7175bd8d37ab75482ee05
MD5 1e62539e33a4b8c67002aede446f8f16
BLAKE2b-256 62d419bf1411dbd8eaa84316b14197424018a051874c2a1271582bec67a6fd70

See more details on using hashes here.

File details

Details for the file openai_responses-0.13.1-py3-none-any.whl.

File metadata

  • Download URL: openai_responses-0.13.1-py3-none-any.whl
  • Upload date:
  • Size: 51.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.2 Linux/6.1.0-37-amd64

File hashes

Hashes for openai_responses-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5fc7fb15f546b551757864c1dfaeb01b8a4fc0c353961bd6d0d45ff26389721
MD5 d520b05cb28fa9429aa5dae757a618c6
BLAKE2b-256 089850c755503a55550f170d0211297bc8791b8bf10bf04cb16b4b95ca71d1e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page