Skip to content

Commit efda660

Browse files
authored
Merge branch 'main' into patch-1
2 parents ea0ff9e + e6c6757 commit efda660

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+255
-173
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.97.0"
2+
".": "1.97.1"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 111
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-670ea0d2cc44f52a87dd3cadea45632953283e0636ba30788fdbdb22a232ccac.yml
3-
openapi_spec_hash: d8b7d38911fead545adf3e4297956410
4-
config_hash: 5525bda35e48ea6387c6175c4d1651fa
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-b2a451656ca64d30d174391ebfd94806b4de3ab76dc55b92843cfb7f1a54ecb6.yml
3+
openapi_spec_hash: 27d9691b400f28c17ef063a1374048b0
4+
config_hash: e822d0c9082c8b312264403949243179

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 1.97.1 (2025-07-22)
4+
5+
Full Changelog: [v1.97.0...v1.97.1](https://github.com/openai/openai-python/compare/v1.97.0...v1.97.1)
6+
7+
### Bug Fixes
8+
9+
* **parsing:** ignore empty metadata ([58c359f](https://github.com/openai/openai-python/commit/58c359ff67fd6103268e4405600fd58844b6f27b))
10+
* **parsing:** parse extra field types ([d524b7e](https://github.com/openai/openai-python/commit/d524b7e201418ccc9b5c2206da06d1be011808e5))
11+
12+
13+
### Chores
14+
15+
* **api:** event shapes more accurate ([f3a9a92](https://github.com/openai/openai-python/commit/f3a9a9229280ecb7e0b2779dd44290df6d9824ef))
16+
317
## 1.97.0 (2025-07-16)
418

519
Full Changelog: [v1.96.1...v1.97.0](https://github.com/openai/openai-python/compare/v1.96.1...v1.97.0)

api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,6 @@ from openai.types.responses import (
791791
ResponseOutputTextAnnotationAddedEvent,
792792
ResponsePrompt,
793793
ResponseQueuedEvent,
794-
ResponseReasoningDeltaEvent,
795-
ResponseReasoningDoneEvent,
796794
ResponseReasoningItem,
797795
ResponseReasoningSummaryDeltaEvent,
798796
ResponseReasoningSummaryDoneEvent,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai"
3-
version = "1.97.0"
3+
version = "1.97.1"
44
description = "The official Python library for the openai API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/openai/_models.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,18 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
233233
else:
234234
fields_values[name] = field_get_default(field)
235235

236+
extra_field_type = _get_extra_fields_type(__cls)
237+
236238
_extra = {}
237239
for key, value in values.items():
238240
if key not in model_fields:
241+
parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
242+
239243
if PYDANTIC_V2:
240-
_extra[key] = value
244+
_extra[key] = parsed
241245
else:
242246
_fields_set.add(key)
243-
fields_values[key] = value
247+
fields_values[key] = parsed
244248

245249
object.__setattr__(m, "__dict__", fields_values)
246250

@@ -395,6 +399,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
395399
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
396400

397401

402+
def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
403+
if not PYDANTIC_V2:
404+
# TODO
405+
return None
406+
407+
schema = cls.__pydantic_core_schema__
408+
if schema["type"] == "model":
409+
fields = schema["schema"]
410+
if fields["type"] == "model-fields":
411+
extras = fields.get("extras_schema")
412+
if extras and "cls" in extras:
413+
# mypy can't narrow the type
414+
return extras["cls"] # type: ignore[no-any-return]
415+
416+
return None
417+
418+
398419
def is_basemodel(type_: type) -> bool:
399420
"""Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
400421
if is_union(type_):
@@ -464,7 +485,7 @@ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]
464485
type_ = type_.__value__ # type: ignore[unreachable]
465486

466487
# unwrap `Annotated[T, ...]` -> `T`
467-
if metadata is not None:
488+
if metadata is not None and len(metadata) > 0:
468489
meta: tuple[Any, ...] = tuple(metadata)
469490
elif is_annotated_type(type_):
470491
meta = get_args(type_)[1:]

src/openai/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "openai"
4-
__version__ = "1.97.0" # x-release-please-version
4+
__version__ = "1.97.1" # x-release-please-version

src/openai/lib/streaming/responses/_events.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
ResponseRefusalDoneEvent,
2222
ResponseRefusalDeltaEvent,
2323
ResponseMcpCallFailedEvent,
24-
ResponseReasoningDoneEvent,
2524
ResponseOutputItemDoneEvent,
26-
ResponseReasoningDeltaEvent,
2725
ResponseContentPartDoneEvent,
2826
ResponseOutputItemAddedEvent,
2927
ResponseContentPartAddedEvent,
@@ -139,10 +137,8 @@ class ResponseCompletedEvent(RawResponseCompletedEvent, GenericModel, Generic[Te
139137
ResponseMcpListToolsInProgressEvent,
140138
ResponseOutputTextAnnotationAddedEvent,
141139
ResponseQueuedEvent,
142-
ResponseReasoningDeltaEvent,
143140
ResponseReasoningSummaryDeltaEvent,
144141
ResponseReasoningSummaryDoneEvent,
145-
ResponseReasoningDoneEvent,
146142
],
147143
PropertyInfo(discriminator="type"),
148144
]

src/openai/lib/streaming/responses/_responses.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def handle_event(self, event: RawResponseStreamEvent) -> List[ResponseStreamEven
264264
item_id=event.item_id,
265265
output_index=event.output_index,
266266
sequence_number=event.sequence_number,
267+
logprobs=event.logprobs,
267268
type="response.output_text.delta",
268269
snapshot=content.text,
269270
)
@@ -282,6 +283,7 @@ def handle_event(self, event: RawResponseStreamEvent) -> List[ResponseStreamEven
282283
item_id=event.item_id,
283284
output_index=event.output_index,
284285
sequence_number=event.sequence_number,
286+
logprobs=event.logprobs,
285287
type="response.output_text.done",
286288
text=event.text,
287289
parsed=parse_text(event.text, text_format=self._text_format),

src/openai/resources/audio/speech.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def create(
5050
*,
5151
input: str,
5252
model: Union[str, SpeechModel],
53-
voice: Union[
54-
str, Literal["alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"]
55-
],
53+
voice: Union[str, Literal["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"]],
5654
instructions: str | NotGiven = NOT_GIVEN,
5755
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
5856
speed: float | NotGiven = NOT_GIVEN,
@@ -146,9 +144,7 @@ async def create(
146144
*,
147145
input: str,
148146
model: Union[str, SpeechModel],
149-
voice: Union[
150-
str, Literal["alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer", "verse"]
151-
],
147+
voice: Union[str, Literal["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"]],
152148
instructions: str | NotGiven = NOT_GIVEN,
153149
response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] | NotGiven = NOT_GIVEN,
154150
speed: float | NotGiven = NOT_GIVEN,

0 commit comments

Comments
 (0)