Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 1.54.4 #1859

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.54.3"
".": "1.54.4"
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.54.4 (2024-11-12)

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

### Bug Fixes

* don't use dicts as iterables in transform ([#1865](https://github.com/openai/openai-python/issues/1865)) ([76a51b1](https://github.com/openai/openai-python/commit/76a51b11efae50659a562197b1e18c6343964b56))


### Documentation

* bump models in example snippets to gpt-4o ([#1861](https://github.com/openai/openai-python/issues/1861)) ([adafe08](https://github.com/openai/openai-python/commit/adafe0859178d406fa93b38f3547f3d262651331))
* move comments in example snippets ([#1860](https://github.com/openai/openai-python/issues/1860)) ([362cf74](https://github.com/openai/openai-python/commit/362cf74d6c34506f98f6c4fb2304357be21f7691))
* **readme:** add missing asyncio import ([#1858](https://github.com/openai/openai-python/issues/1858)) ([dec9d0c](https://github.com/openai/openai-python/commit/dec9d0c97b702b6bcf9c71f5bdd6172bb5718354))

## 1.54.3 (2024-11-06)

Full Changelog: [v1.54.2...v1.54.3](https://github.com/openai/openai-python/compare/v1.54.2...v1.54.3)
Expand Down
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import os
from openai import OpenAI

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

chat_completion = client.chat.completions.create(
Expand All @@ -42,7 +41,7 @@ chat_completion = client.chat.completions.create(
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
)
```

Expand Down Expand Up @@ -153,8 +152,7 @@ import asyncio
from openai import AsyncOpenAI

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


Expand All @@ -166,7 +164,7 @@ async def main() -> None:
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
)


Expand All @@ -185,8 +183,13 @@ from openai import OpenAI
client = OpenAI()

stream = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Say this is a test"}],
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-4o",
stream=True,
)
for chunk in stream:
Expand All @@ -196,6 +199,7 @@ for chunk in stream:
The async client uses the exact same interface.

```python
import asyncio
from openai import AsyncOpenAI

client = AsyncOpenAI()
Expand Down Expand Up @@ -232,7 +236,7 @@ openai.base_url = "https://..."
openai.default_headers = {"x-foo": "true"}

completion = openai.chat.completions.create(
model="gpt-4",
model="gpt-4o",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -350,7 +354,7 @@ completion = client.chat.completions.create(
"content": "Can you generate an example json object describing a fruit?",
}
],
model="gpt-3.5-turbo-1106",
model="gpt-4o",
response_format={"type": "json_object"},
)
```
Expand Down Expand Up @@ -390,7 +394,7 @@ client = OpenAI()

try:
client.fine_tuning.jobs.create(
model="gpt-3.5-turbo",
model="gpt-4o",
training_file="file-abc123",
)
except openai.APIConnectionError as e:
Expand Down Expand Up @@ -457,10 +461,10 @@ client.with_options(max_retries=5).chat.completions.create(
messages=[
{
"role": "user",
"content": "How can I get the name of the current day in Node.js?",
"content": "How can I get the name of the current day in JavaScript?",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
)
```

Expand Down Expand Up @@ -491,7 +495,7 @@ client.with_options(timeout=5.0).chat.completions.create(
"content": "How can I list all files in a directory using Python?",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
)
```

Expand Down Expand Up @@ -536,7 +540,7 @@ response = client.chat.completions.with_raw_response.create(
"role": "user",
"content": "Say this is a test",
}],
model="gpt-3.5-turbo",
model="gpt-4o",
)
print(response.headers.get('X-My-Header'))

Expand Down Expand Up @@ -569,7 +573,7 @@ with client.chat.completions.with_streaming_response.create(
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
) as response:
print(response.headers.get("X-My-Header"))

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.54.3"
version = "1.54.4"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
5 changes: 5 additions & 0 deletions src/openai/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ async def _async_transform_recursive(
# Iterable[T]
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
):
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
# intended as an iterable, so we don't transform it.
if isinstance(data, dict):
return cast(object, data)

inner_type = extract_type_arg(stripped_type, 0)
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]

Expand Down
2 changes: 1 addition & 1 deletion src/openai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openai"
__version__ = "1.54.3" # x-release-please-version
__version__ = "1.54.4" # x-release-please-version
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
),
),
cast_to=httpx.Response,
Expand All @@ -753,7 +753,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
),
),
cast_to=httpx.Response,
Expand Down Expand Up @@ -1594,7 +1594,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
),
),
cast_to=httpx.Response,
Expand All @@ -1620,7 +1620,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
model="gpt-4o",
),
),
cast_to=httpx.Response,
Expand Down