Skip to content

Commit d63ff65

Browse files
authored
Merge branch 'main' into chore/update-legacy-models
2 parents 2359958 + e369566 commit d63ff65

24 files changed

+740
-107
lines changed

Diff for: .release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.3.3"
2+
".": "1.3.7"
33
}

Diff for: CHANGELOG.md

+73
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,78 @@
11
# Changelog
22

3+
## 1.3.7 (2023-12-01)
4+
5+
Full Changelog: [v1.3.6...v1.3.7](https://github.com/openai/openai-python/compare/v1.3.6...v1.3.7)
6+
7+
### Bug Fixes
8+
9+
* **client:** correct base_url setter implementation ([#919](https://github.com/openai/openai-python/issues/919)) ([135d9cf](https://github.com/openai/openai-python/commit/135d9cf2820f1524764bf536a9322830bdcd5875))
10+
* **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))
11+
* **client:** ensure retried requests are closed ([#902](https://github.com/openai/openai-python/issues/902)) ([e025e6b](https://github.com/openai/openai-python/commit/e025e6bee44ea145d948869ef0c79bac0c376b9f))
12+
13+
14+
### Chores
15+
16+
* **internal:** add tests for proxy change ([#899](https://github.com/openai/openai-python/issues/899)) ([71a13d0](https://github.com/openai/openai-python/commit/71a13d0c70d105b2b97720c72a1003b942cda2ae))
17+
* **internal:** remove unused type var ([#915](https://github.com/openai/openai-python/issues/915)) ([4233bcd](https://github.com/openai/openai-python/commit/4233bcdae5f467f10454fcc008a6e728fa846830))
18+
* **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))
19+
* **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))
20+
21+
22+
### Documentation
23+
24+
* fix typo in readme ([#904](https://github.com/openai/openai-python/issues/904)) ([472cd44](https://github.com/openai/openai-python/commit/472cd44e45a45b0b4f12583a5402e8aeb121d7a2))
25+
* **readme:** update example snippets ([#907](https://github.com/openai/openai-python/issues/907)) ([bbb648e](https://github.com/openai/openai-python/commit/bbb648ef81eb11f81b457e2cbf33a832f4d29a76))
26+
27+
## 1.3.6 (2023-11-28)
28+
29+
Full Changelog: [v1.3.5...v1.3.6](https://github.com/openai/openai-python/compare/v1.3.5...v1.3.6)
30+
31+
### Bug Fixes
32+
33+
* **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))
34+
35+
36+
### Chores
37+
38+
* **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))
39+
* **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))
40+
* revert binary streaming change ([#875](https://github.com/openai/openai-python/issues/875)) ([0a06d6a](https://github.com/openai/openai-python/commit/0a06d6a078c5ee898dae75bab4988e1a1936bfbf))
41+
42+
43+
### Documentation
44+
45+
* **readme:** minor updates ([#894](https://github.com/openai/openai-python/issues/894)) ([5458457](https://github.com/openai/openai-python/commit/54584572df4c2a086172d812c6acb84e3405328b))
46+
* **readme:** update examples ([#893](https://github.com/openai/openai-python/issues/893)) ([124da87](https://github.com/openai/openai-python/commit/124da8720c44d40c083d29179f46a265761c1f4f))
47+
* update readme code snippet ([#890](https://github.com/openai/openai-python/issues/890)) ([c522f21](https://github.com/openai/openai-python/commit/c522f21e2a685454185d57e462e74a28499460f9))
48+
49+
## 1.3.5 (2023-11-21)
50+
51+
Full Changelog: [v1.3.4...v1.3.5](https://github.com/openai/openai-python/compare/v1.3.4...v1.3.5)
52+
53+
### Bug Fixes
54+
55+
* **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))
56+
57+
58+
### Chores
59+
60+
* **package:** add license classifier ([#826](https://github.com/openai/openai-python/issues/826)) ([bec004d](https://github.com/openai/openai-python/commit/bec004d030b277e05bdd51f66fae1e881291c30b))
61+
* **package:** add license classifier metadata ([#860](https://github.com/openai/openai-python/issues/860)) ([80dffb1](https://github.com/openai/openai-python/commit/80dffb17ff0a10b0b9ea704c4247521e48b68408))
62+
63+
## 1.3.4 (2023-11-21)
64+
65+
Full Changelog: [v1.3.3...v1.3.4](https://github.com/openai/openai-python/compare/v1.3.3...v1.3.4)
66+
67+
### Bug Fixes
68+
69+
* **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))
70+
71+
72+
### Chores
73+
74+
* **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))
75+
376
## 1.3.3 (2023-11-17)
477

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

Diff for: README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ pip install openai
2626
The full API of this library can be found in [api.md](https://www.github.com/openai/openai-python/blob/main/api.md).
2727

2828
```python
29+
import os
2930
from openai import OpenAI
3031

3132
client = OpenAI(
32-
# defaults to os.environ.get("OPENAI_API_KEY")
33-
api_key="My API Key",
33+
# This is the default and can be omitted
34+
api_key=os.environ.get("OPENAI_API_KEY"),
3435
)
3536

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

5657
```python
58+
import os
5759
import asyncio
5860
from openai import AsyncOpenAI
5961

6062
client = AsyncOpenAI(
61-
# defaults to os.environ.get("OPENAI_API_KEY")
62-
api_key="My API Key",
63+
# This is the default and can be omitted
64+
api_key=os.environ.get("OPENAI_API_KEY"),
6365
)
6466

6567

@@ -94,8 +96,9 @@ stream = client.chat.completions.create(
9496
messages=[{"role": "user", "content": "Say this is a test"}],
9597
stream=True,
9698
)
97-
for part in stream:
98-
print(part.choices[0].delta.content or "")
99+
for chunk in stream:
100+
if chunk.choices[0].delta.content is not None:
101+
print(chunk.choices[0].delta.content)
99102
```
100103

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

117121
## Module-level client
@@ -250,7 +254,7 @@ completion = client.chat.completions.create(
250254
"content": "Can you generate an example json object describing a fruit?",
251255
}
252256
],
253-
model="gpt-3.5-turbo",
257+
model="gpt-3.5-turbo-1106",
254258
response_format={"type": "json_object"},
255259
)
256260
```

Diff for: examples/assistant.py

+12-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import openai
21
import time
32

3+
import openai
4+
45
# gets API Key from environment variable OPENAI_API_KEY
56
client = openai.OpenAI()
67

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

2223
run = client.beta.threads.runs.create(
23-
thread_id=thread.id,
24-
assistant_id=assistant.id,
25-
instructions="Please address the user as Jane Doe. The user has a premium account."
24+
thread_id=thread.id,
25+
assistant_id=assistant.id,
26+
instructions="Please address the user as Jane Doe. The user has a premium account.",
2627
)
2728

2829
print("checking assistant status. ")
2930
while True:
30-
run = client.beta.threads.runs.retrieve(
31-
thread_id=thread.id,
32-
run_id=run.id
33-
)
31+
run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)
3432

3533
if run.status == "completed":
3634
print("done!")
37-
messages = client.beta.threads.messages.list(
38-
thread_id=thread.id
39-
)
35+
messages = client.beta.threads.messages.list(thread_id=thread.id)
4036

4137
print("messages: ")
4238
for message in messages:
43-
print({
44-
"role": message.role,
45-
"message": message.content[0].text.value
46-
})
39+
assert message.content[0].type == "text"
40+
print({"role": message.role, "message": message.content[0].text.value})
4741

4842
client.beta.assistants.delete(assistant.id)
49-
43+
5044
break
5145
else:
5246
print("in progress...")
53-
time.sleep(5)
47+
time.sleep(5)

Diff for: pyproject.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai"
3-
version = "1.3.3"
3+
version = "1.3.7"
44
description = "The official Python library for the openai API"
55
readme = "README.md"
66
license = "Apache-2.0"
@@ -13,6 +13,7 @@ dependencies = [
1313
"typing-extensions>=4.5, <5",
1414
"anyio>=3.5.0, <4",
1515
"distro>=1.7.0, <2",
16+
"sniffio",
1617
"tqdm > 4"
1718
]
1819
requires-python = ">= 3.7.1"
@@ -31,6 +32,7 @@ classifiers = [
3132
"Operating System :: POSIX :: Linux",
3233
"Operating System :: Microsoft :: Windows",
3334
"Topic :: Software Development :: Libraries :: Python Modules",
35+
"License :: OSI Approved :: Apache Software License"
3436
]
3537

3638
[project.optional-dependencies]
@@ -47,7 +49,7 @@ openai = "openai.cli:main"
4749
managed = true
4850
dev-dependencies = [
4951
"pyright==1.1.332",
50-
"mypy==1.6.1",
52+
"mypy==1.7.1",
5153
"black==23.3.0",
5254
"respx==0.19.2",
5355
"pytest==7.1.1",

Diff for: requirements-dev.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ azure-identity==1.15.0
1616
black==23.3.0
1717
certifi==2023.7.22
1818
cffi==1.16.0
19-
charset-normalizer==3.3.1
19+
charset-normalizer==3.3.2
2020
click==8.1.7
2121
colorlog==6.7.0
22-
cryptography==41.0.5
22+
cryptography==41.0.7
2323
dirty-equals==0.6.0
2424
distlib==0.3.7
2525
distro==1.8.0
@@ -31,15 +31,15 @@ httpx==0.23.0
3131
idna==3.4
3232
iniconfig==2.0.0
3333
isort==5.10.1
34-
msal==1.24.1
34+
msal==1.25.0
3535
msal-extensions==1.0.0
36-
mypy==1.6.1
36+
mypy==1.7.1
3737
mypy-extensions==1.0.0
3838
nodeenv==1.8.0
3939
nox==2023.4.22
40-
numpy==1.26.1
40+
numpy==1.26.2
4141
packaging==23.2
42-
pandas==2.1.1
42+
pandas==2.1.3
4343
pandas-stubs==2.1.1.230928
4444
pathspec==0.11.2
4545
platformdirs==3.11.0
@@ -68,7 +68,7 @@ types-pytz==2023.3.1.1
6868
types-tqdm==4.66.0.2
6969
typing-extensions==4.8.0
7070
tzdata==2023.3
71-
urllib3==2.0.7
71+
urllib3==2.1.0
7272
virtualenv==20.24.5
7373
# The following packages are considered to be unsafe in a requirements file:
7474
setuptools==68.2.2

0 commit comments

Comments
 (0)