Skip to content

Commit

Permalink
Add optional 'additionalProperties' param
Browse files Browse the repository at this point in the history
  • Loading branch information
neelvirdy committed Aug 30, 2024
1 parent 3c970ea commit c5bbd80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Sources/OpenAI/Public/Models/ChatQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ public struct ChatQuery: Equatable, Codable, Streamable {
public let multipleOf: Int?
public let minimum: Int?
public let maximum: Int?
public let additionalProperties: Bool?

public init(
type: Self.JSONType,
Expand All @@ -713,7 +714,8 @@ public struct ChatQuery: Equatable, Codable, Streamable {
enum: [String]? = nil,
multipleOf: Int? = nil,
minimum: Int? = nil,
maximum: Int? = nil
maximum: Int? = nil,
additionalProperties: Bool? = nil
) {
self.type = type
self.properties = properties
Expand All @@ -724,6 +726,7 @@ public struct ChatQuery: Equatable, Codable, Streamable {
self.multipleOf = multipleOf
self.minimum = minimum
self.maximum = maximum
self.additionalProperties = additionalProperties
}

public struct Property: Codable, Equatable {
Expand Down
6 changes: 4 additions & 2 deletions Tests/OpenAITests/OpenAITestsDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ class OpenAITestsDecoder: XCTestCase {
"location": .init(type: .string, description: "The city and state, e.g. San Francisco, CA"),
"unit": .init(type: .string, enum: ["celsius", "fahrenheit"])
],
required: ["location"]
required: ["location"],
additionalProperties: false
),
strict: true
))
Expand Down Expand Up @@ -293,7 +294,8 @@ class OpenAITestsDecoder: XCTestCase {
},
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location"]
"required": ["location"],
"additionalProperties": false
},
"strict": true
},
Expand Down

0 comments on commit c5bbd80

Please sign in to comment.