Module: LlmLogs::Batch::SchemaFormat
- Defined in:
- app/models/llm_logs/batch/schema_format.rb
Overview
Translates a schema:, strict: schema (the shape RubyLLM::Chat#with_schema produces) into the OpenAI Responses API ‘text.format` block. The batch path builds request bodies directly via RubyLLM.batch#add(**extra), bypassing with_schema, so we must hand the json_schema block in ourselves.
Class Method Summary collapse
Class Method Details
.call(schema) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/llm_logs/batch/schema_format.rb', line 10 def call(schema) return nil if schema.nil? schema = schema.symbolize_keys if schema.respond_to?(:symbolize_keys) { format: { type: "json_schema", name: schema[:name] || "response", schema: schema[:schema] || schema, strict: schema.key?(:strict) ? schema[:strict] : true } } end |