From d81bd8f50262720a1f4388a64569abfb31930e1f Mon Sep 17 00:00:00 2001 From: Michael Harris Date: Wed, 24 Apr 2024 17:06:20 -0400 Subject: [PATCH 1/3] chore(changelog): add notes for v0.2.0 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dbcffb..08ac7ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.2.0 + +Migrates assistant endpoints to Assistants V2 + +- [#8: feat: assistants v2](https://github.com/mharrisb1/openai-responses-python/issues/8) +- [#13: feat(endpoints): add token usage estimates to chat endpoint](https://github.com/mharrisb1/openai-responses-python/issues/13) + ## 0.1.1 Fixes some issues with chat completions and other stateless mocks From e40c65620649fe238a83e056b009537b1a784bbc Mon Sep 17 00:00:00 2001 From: Michael Harris Date: Wed, 24 Apr 2024 17:06:36 -0400 Subject: [PATCH 2/3] chore(contributing): add notes on poetry and deps --- CONTRIBUTING.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 005b40c..f4c1e71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,18 @@ # Contributing -All contributions are welcome but I need to setup CI tests so nothing will be merged in until that is done. +All contributions are welcome. + +## Development Environment + +This project uses [Poetry](https://python-poetry.org/) to manage Python environment, [Black](https://github.com/psf/black) to format code, +and [mypy](https://mypy-lang.org/) to run static analysis. Please make sure your environment is setup with these enabled. + +To make sure everything is working correctly, make sure you have Poetry installed, then install the dependencies, and then run [tox](https://tox.wiki/en/4.14.2/). + +```sh +pipx install poetry==1.8 --force +poetry config virtualenvs.in-project true +poetry install --with dev +poetry shell +tox run +``` From 8856f9b28d7c0d6bdbd33b5d07fa452ede707f0f Mon Sep 17 00:00:00 2001 From: Michael Harris Date: Wed, 24 Apr 2024 17:06:52 -0400 Subject: [PATCH 3/3] chore(docs): add link to docs site --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c8e9e7b..6481edd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,60 @@ -# openai-responses-python +# openai-responses [![PyPI version](https://badge.fury.io/py/openai-responses.svg)](https://badge.fury.io/py/openai-responses) -[![PyPI - Downloads](https://img.shields.io/pypi/dm/openai-responses)](https://pypi.org/project/openai-responses/) +[![PyPI - License](https://img.shields.io/pypi/l/openai-responses)](https://opensource.org/blog/license/mit) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openai-responses.svg)](https://pypi.org/project/openai-responses/) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) +[![PyPI - Downloads](https://img.shields.io/pypi/dm/openai-responses)](https://pypi.org/project/openai-responses/) +[![Open Issues](https://img.shields.io/github/issues/mharrisb1/openai-responses-python)](https://github.com/mharrisb1/openai-responses-python/issues) +[![Stargazers](https://img.shields.io/github/stars/mharrisb1/openai-responses-python?style)](https://pypistats.org/packages/openai-responses) + + +Pytest plugin for automatically mocking OpenAI requests. Simply decorate any test function that contains code that calls an OpenAI endpoint (either using the SDK or HTTPX). + +```python +import openai_responses +from openai import OpenAI + + +@openai_responses.mock.chat.completions( + choices=[ + {"message": {"content": "Hello, how can I help?"}}, + {"message": {"content": "Hi! I'm here to help!"}}, + {"message": {"content": "How can I help?"}}, + ], +) +def test_create_completion_with_multiple_choices(): + client = OpenAI(api_key="fakeKey") + completion = client.chat.completions.create( + model="gpt-3.5-turbo", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Hello!"}, + ], + n=3, + ) + assert len(completion.choices) == 3 +``` + +## Installation + +Available on [PyPi](https://pypi.org/project/openai-responses/) + +```bash +pip install openai-responses +``` + +## Usage + +See the [documentation site](https://mharrisb1.github.io/openai-responses-python) for more info. + +## License + +See [LICENSE](https://github.com/mharrisb1/openai-responses-python/blob/main/LICENSE) for more info. + +## Contributing + +See [CONTRIBUTING.md](https://github.com/mharrisb1/openai-responses-python/blob/main/CONTRIBUTING.md) for more info. + +## Changelog -Automatically mock OpenAI requests +See [CHANGELOG.md](https://github.com/mharrisb1/openai-responses-python/blob/main/CHANGELOG.md) for more info.