LangSchema.Converter.OpenAI (LangSchema v0.3.0)

View Source

Summary

Functions

Wraps the given JSON schema into the structure expected by OpenAI's Chat API when using response_format: "json_schema".

Functions

wrap(json_schema, opts)

Wraps the given JSON schema into the structure expected by OpenAI's Chat API when using response_format: "json_schema".

This implementation follows the specification described under: OpenAI API Reference - Create Chat Completion (Request body → response_format → JSON schema → json_schema).

It sets the name, attaches the provided JSON schema under the schema field, and enforces strict: true. If a description is provided in the options, it will be added as well.