Skip to content

Provide supported Sorbet/Tapioca typing for user-defined structured-output models #309

Description

@jbeckwith-oai

Carried over from #126 and originally requested by @agarcher.

Applications can define structured-output schemas by subclassing OpenAI::BaseModel, but the SDK does not ship a supported Tapioca compiler (or equivalent) that generates RBI definitions for those application-defined models. The generated SDK RBI also exposes fields such as message.parsed and response output parsed as T.anything.

The OpenAI::EnumOf#to_sorbet_type bug was separately fixed in #151; this issue tracks the remaining end-to-end typing experience.

Desired behavior

  • Provide a supported way to generate useful RBI definitions for application-defined OpenAI::BaseModel subclasses.
  • Cover fields declared with required, optional, OpenAI::ArrayOf, OpenAI::EnumOf, nested models, and nilability.
  • Ideally preserve the supplied structured-output model type through parsed; at minimum, make a documented T.cast/assertion type-safe by generating the schema class's accessors.
  • Keep compatibility with the SDK's policy of not requiring sorbet-runtime.
  • Add documentation and a representative Tapioca/Sorbet test.

Source discussion and prototype compiler: #126.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgeneratorTouches generated SDK files

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions