Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-legacy-models
Browse files Browse the repository at this point in the history
  • Loading branch information
franz101 authored Dec 6, 2023
2 parents 2359958 + e369566 commit d63ff65
Show file tree
Hide file tree
Showing 24 changed files with 740 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.3.3"
".": "1.3.7"
}
73 changes: 73 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,78 @@
# Changelog

## 1.3.7 (2023-12-01)

Full Changelog: [v1.3.6...v1.3.7](https://github.com/openai/openai-python/compare/v1.3.6...v1.3.7)

### Bug Fixes

* **client:** correct base_url setter implementation ([#919](https://github.com/openai/openai-python/issues/919)) ([135d9cf](https://github.com/openai/openai-python/commit/135d9cf2820f1524764bf536a9322830bdcd5875))
* **client:** don't cause crashes when inspecting the module ([#897](https://github.com/openai/openai-python/issues/897)) ([db029a5](https://github.com/openai/openai-python/commit/db029a596c90b1af4ef0bfb1cdf31f54b2f5755d))
* **client:** ensure retried requests are closed ([#902](https://github.com/openai/openai-python/issues/902)) ([e025e6b](https://github.com/openai/openai-python/commit/e025e6bee44ea145d948869ef0c79bac0c376b9f))


### Chores

* **internal:** add tests for proxy change ([#899](https://github.com/openai/openai-python/issues/899)) ([71a13d0](https://github.com/openai/openai-python/commit/71a13d0c70d105b2b97720c72a1003b942cda2ae))
* **internal:** remove unused type var ([#915](https://github.com/openai/openai-python/issues/915)) ([4233bcd](https://github.com/openai/openai-python/commit/4233bcdae5f467f10454fcc008a6e728fa846830))
* **internal:** replace string concatenation with f-strings ([#908](https://github.com/openai/openai-python/issues/908)) ([663a8f6](https://github.com/openai/openai-python/commit/663a8f6dead5aa523d1e8779e75af1dabb1690c4))
* **internal:** replace string concatenation with f-strings ([#909](https://github.com/openai/openai-python/issues/909)) ([caab767](https://github.com/openai/openai-python/commit/caab767156375114078cf8d85031863361326b5f))


### Documentation

* fix typo in readme ([#904](https://github.com/openai/openai-python/issues/904)) ([472cd44](https://github.com/openai/openai-python/commit/472cd44e45a45b0b4f12583a5402e8aeb121d7a2))
* **readme:** update example snippets ([#907](https://github.com/openai/openai-python/issues/907)) ([bbb648e](https://github.com/openai/openai-python/commit/bbb648ef81eb11f81b457e2cbf33a832f4d29a76))

## 1.3.6 (2023-11-28)

Full Changelog: [v1.3.5...v1.3.6](https://github.com/openai/openai-python/compare/v1.3.5...v1.3.6)

### Bug Fixes

* **client:** add support for streaming binary responses ([#866](https://github.com/openai/openai-python/issues/866)) ([2470d25](https://github.com/openai/openai-python/commit/2470d251b751e92e8950bc9e3026965e9925ac1c))


### Chores

* **deps:** bump mypy to v1.7.1 ([#891](https://github.com/openai/openai-python/issues/891)) ([11fcb2a](https://github.com/openai/openai-python/commit/11fcb2a3cd4205b307c13c65ad47d9e315b0084d))
* **internal:** send more detailed x-stainless headers ([#877](https://github.com/openai/openai-python/issues/877)) ([69e0549](https://github.com/openai/openai-python/commit/69e054947d587ff2548b101ece690d21d3c38f74))
* revert binary streaming change ([#875](https://github.com/openai/openai-python/issues/875)) ([0a06d6a](https://github.com/openai/openai-python/commit/0a06d6a078c5ee898dae75bab4988e1a1936bfbf))


### Documentation

* **readme:** minor updates ([#894](https://github.com/openai/openai-python/issues/894)) ([5458457](https://github.com/openai/openai-python/commit/54584572df4c2a086172d812c6acb84e3405328b))
* **readme:** update examples ([#893](https://github.com/openai/openai-python/issues/893)) ([124da87](https://github.com/openai/openai-python/commit/124da8720c44d40c083d29179f46a265761c1f4f))
* update readme code snippet ([#890](https://github.com/openai/openai-python/issues/890)) ([c522f21](https://github.com/openai/openai-python/commit/c522f21e2a685454185d57e462e74a28499460f9))

## 1.3.5 (2023-11-21)

Full Changelog: [v1.3.4...v1.3.5](https://github.com/openai/openai-python/compare/v1.3.4...v1.3.5)

### Bug Fixes

* **azure:** ensure custom options can be passed to copy ([#858](https://github.com/openai/openai-python/issues/858)) ([05ca0d6](https://github.com/openai/openai-python/commit/05ca0d68e84d40f975614d27cb52c0f382104377))


### Chores

* **package:** add license classifier ([#826](https://github.com/openai/openai-python/issues/826)) ([bec004d](https://github.com/openai/openai-python/commit/bec004d030b277e05bdd51f66fae1e881291c30b))
* **package:** add license classifier metadata ([#860](https://github.com/openai/openai-python/issues/860)) ([80dffb1](https://github.com/openai/openai-python/commit/80dffb17ff0a10b0b9ea704c4247521e48b68408))

## 1.3.4 (2023-11-21)

Full Changelog: [v1.3.3...v1.3.4](https://github.com/openai/openai-python/compare/v1.3.3...v1.3.4)

### Bug Fixes

* **client:** attempt to parse unknown json content types ([#854](https://github.com/openai/openai-python/issues/854)) ([ba50466](https://github.com/openai/openai-python/commit/ba5046611029a67714d5120b9cc6a3c7fecce10c))


### Chores

* **examples:** fix static types in assistants example ([#852](https://github.com/openai/openai-python/issues/852)) ([5b47b2c](https://github.com/openai/openai-python/commit/5b47b2c542b9b4fb143af121022e2d5ad0890ef4))

## 1.3.3 (2023-11-17)

Full Changelog: [v1.3.2...v1.3.3](https://github.com/openai/openai-python/compare/v1.3.2...v1.3.3)
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ pip install openai
The full API of this library can be found in [api.md](https://www.github.com/openai/openai-python/blob/main/api.md).

```python
import os
from openai import OpenAI

client = OpenAI(
# defaults to os.environ.get("OPENAI_API_KEY")
api_key="My API Key",
# This is the default and can be omitted
api_key=os.environ.get("OPENAI_API_KEY"),
)

chat_completion = client.chat.completions.create(
Expand All @@ -54,12 +55,13 @@ so that your API Key is not stored in source control.
Simply import `AsyncOpenAI` instead of `OpenAI` and use `await` with each API call:

```python
import os
import asyncio
from openai import AsyncOpenAI

client = AsyncOpenAI(
# defaults to os.environ.get("OPENAI_API_KEY")
api_key="My API Key",
# This is the default and can be omitted
api_key=os.environ.get("OPENAI_API_KEY"),
)


Expand Down Expand Up @@ -94,8 +96,9 @@ stream = client.chat.completions.create(
messages=[{"role": "user", "content": "Say this is a test"}],
stream=True,
)
for part in stream:
print(part.choices[0].delta.content or "")
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content)
```

The async client uses the exact same interface.
Expand All @@ -110,8 +113,9 @@ stream = await client.chat.completions.create(
messages=[{"role": "user", "content": "Say this is a test"}],
stream=True,
)
async for part in stream:
print(part.choices[0].delta.content or "")
async for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content)
```

## Module-level client
Expand Down Expand Up @@ -250,7 +254,7 @@ completion = client.chat.completions.create(
"content": "Can you generate an example json object describing a fruit?",
}
],
model="gpt-3.5-turbo",
model="gpt-3.5-turbo-1106",
response_format={"type": "json_object"},
)
```
Expand Down
30 changes: 12 additions & 18 deletions examples/assistant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import openai
import time

import openai

# gets API Key from environment variable OPENAI_API_KEY
client = openai.OpenAI()

Expand All @@ -16,38 +17,31 @@
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="I need to solve the equation `3x + 11 = 14`. Can you help me?"
content="I need to solve the equation `3x + 11 = 14`. Can you help me?",
)

run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
instructions="Please address the user as Jane Doe. The user has a premium account."
thread_id=thread.id,
assistant_id=assistant.id,
instructions="Please address the user as Jane Doe. The user has a premium account.",
)

print("checking assistant status. ")
while True:
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id
)
run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)

if run.status == "completed":
print("done!")
messages = client.beta.threads.messages.list(
thread_id=thread.id
)
messages = client.beta.threads.messages.list(thread_id=thread.id)

print("messages: ")
for message in messages:
print({
"role": message.role,
"message": message.content[0].text.value
})
assert message.content[0].type == "text"
print({"role": message.role, "message": message.content[0].text.value})

client.beta.assistants.delete(assistant.id)

break
else:
print("in progress...")
time.sleep(5)
time.sleep(5)
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.3.3"
version = "1.3.7"
description = "The official Python library for the openai API"
readme = "README.md"
license = "Apache-2.0"
Expand All @@ -13,6 +13,7 @@ dependencies = [
"typing-extensions>=4.5, <5",
"anyio>=3.5.0, <4",
"distro>=1.7.0, <2",
"sniffio",
"tqdm > 4"
]
requires-python = ">= 3.7.1"
Expand All @@ -31,6 +32,7 @@ classifiers = [
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: Apache Software License"
]

[project.optional-dependencies]
Expand All @@ -47,7 +49,7 @@ openai = "openai.cli:main"
managed = true
dev-dependencies = [
"pyright==1.1.332",
"mypy==1.6.1",
"mypy==1.7.1",
"black==23.3.0",
"respx==0.19.2",
"pytest==7.1.1",
Expand Down
14 changes: 7 additions & 7 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ azure-identity==1.15.0
black==23.3.0
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.1
charset-normalizer==3.3.2
click==8.1.7
colorlog==6.7.0
cryptography==41.0.5
cryptography==41.0.7
dirty-equals==0.6.0
distlib==0.3.7
distro==1.8.0
Expand All @@ -31,15 +31,15 @@ httpx==0.23.0
idna==3.4
iniconfig==2.0.0
isort==5.10.1
msal==1.24.1
msal==1.25.0
msal-extensions==1.0.0
mypy==1.6.1
mypy==1.7.1
mypy-extensions==1.0.0
nodeenv==1.8.0
nox==2023.4.22
numpy==1.26.1
numpy==1.26.2
packaging==23.2
pandas==2.1.1
pandas==2.1.3
pandas-stubs==2.1.1.230928
pathspec==0.11.2
platformdirs==3.11.0
Expand Down Expand Up @@ -68,7 +68,7 @@ types-pytz==2023.3.1.1
types-tqdm==4.66.0.2
typing-extensions==4.8.0
tzdata==2023.3
urllib3==2.0.7
urllib3==2.1.0
virtualenv==20.24.5
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2
Loading

0 comments on commit d63ff65

Please sign in to comment.