Skip to content

DEFER_PYDANTIC_BUILD causes issues #1306

Open
@radoshi

Description

@radoshi

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Release 1.16.1 broke clients by deferring the build if pydantic models. As a result, doing a model_dump() on an object returned by the library can fail.

bc6866e

While this speeds up build times, it should be considered a breaking change and ideally, avoided.

If the speedup is significant, we would request not using a generic envvar like DEFER_PYDANTIC_BUILD to revert the change, instead using something like OPENAI_PYDANTIC_DEFER_BUILD.

We noticed this issue with a streaming tool call message, and are not sure if other deep classes exhibit this behaviour.

To Reproduce

  1. Create a streaming tool call chat completion message.
  2. Call model_dump() on the object.
  3. Observe stack trace in pydantic serializer code.

Code snippets

No response

OS

macOS, Linux

Python version

Python v3.11.8

Library version

openai v1.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdk

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions