Skip to content

Commit 69fb0af

Browse files
authored
chore: allow more free formatted json response input (#726)
1 parent 266d072 commit 69fb0af

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/openai/resources/chat/completions.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ def create(params)
119119
}
120120
}
121121
)
122+
in {response_format: {type: :json_schema, json_schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}
123+
parsed.fetch(:response_format).update(
124+
json_schema: {
125+
strict: true,
126+
name: model.name.split("::").last,
127+
schema: model.to_json_schema
128+
}
129+
)
122130
in {response_format: {type: :json_schema, json_schema: {schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}}
123131
parsed.dig(:response_format, :json_schema).store(:schema, model.to_json_schema)
124132
in {tools: Array => tools}

0 commit comments

Comments
 (0)