Skip to content

Use pydantic models for requests instead of TypedDict #1074

@Vegoo89

Description

@Vegoo89

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

Hello,
I have been using library for some time now and lately started to update from 0.x to newest (1.7.x)
From the start we are using pydantic models for requests and responses handling, mostly due to being very type-safe but also because it works nicely with FastApi.

Let's take chat completion as example.
Right now you are creating different dictionary type for every role, then you have one common return type which is Union of these possible values.
Couldn't it be replaced by one pydantic model?

I am wondering why was there a choice to use TypedDict instead of pydantic models for requests objects?
Searched the issues/PRs but couldn't find anything.

Thanks in advance for response!

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions