Skip to content

Commit 0611fea

Browse files
Merge pull request #150 from Mickael-tinytap/fix/openai-responses-missing-text-format-name
Fixed: Add 'name' encoding for .jsonSchema in FormatType (Responses API)
2 parents d2b17e5 + ac93540 commit 0611fea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/OpenAI/Public/Shared/TextConfiguration.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct TextConfiguration: Codable {
2424
/// Format types for text response
2525
public enum FormatType: Codable {
2626
case text
27-
case jsonSchema(JSONSchema)
27+
case jsonSchema(JSONSchema, name: String? = nil)
2828
case jsonObject
2929

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

60-
case .jsonSchema(let schema):
60+
case let .jsonSchema(schema, name):
6161
try container.encode("json_schema", forKey: .type)
62+
try container.encode(name ?? "schema_response", forKey: .name)
6263
try container.encode(schema, forKey: .schema)
6364

6465
case .jsonObject:
@@ -69,6 +70,7 @@ public enum FormatType: Codable {
6970
enum CodingKeys: String, CodingKey {
7071
case type
7172
case schema
73+
case name
7274
}
7375

7476
}

0 commit comments

Comments
 (0)