Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/OpenAI/Public/Shared/TextConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct TextConfiguration: Codable {
/// Format types for text response
public enum FormatType: Codable {
case text
case jsonSchema(JSONSchema)
case jsonSchema(JSONSchema, name: String? = nil)
case jsonObject

public init(from decoder: Decoder) throws {
Expand Down Expand Up @@ -57,8 +57,9 @@ public enum FormatType: Codable {
case .text:
try container.encode("text", forKey: .type)

case .jsonSchema(let schema):
case let .jsonSchema(schema, name):
try container.encode("json_schema", forKey: .type)
try container.encode(name ?? "schema_response", forKey: .name)
try container.encode(schema, forKey: .schema)

case .jsonObject:
Expand All @@ -69,6 +70,7 @@ public enum FormatType: Codable {
enum CodingKeys: String, CodingKey {
case type
case schema
case name
}

}
Loading