1515import Foundation
1616
1717/// A predicted function call returned from the model.
18- public struct FunctionCall : Equatable , Encodable {
18+ public struct FunctionCall : Equatable {
1919 /// The name of the function to call.
2020 public let name : String
2121
@@ -27,7 +27,7 @@ public struct FunctionCall: Equatable, Encodable {
2727///
2828/// These types can be objects, but also primitives and arrays. Represents a select subset of an
2929/// [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema).
30- public class Schema : Encodable {
30+ public class Schema {
3131 /// The data type.
3232 let type : DataType
3333
@@ -52,17 +52,6 @@ public class Schema: Encodable {
5252 /// Required properties of type ``DataType/object``.
5353 let requiredProperties : [ String ] ?
5454
55- enum CodingKeys : String , CodingKey {
56- case type
57- case format
58- case description
59- case nullable
60- case enumValues = " enum "
61- case items
62- case properties
63- case requiredProperties = " required "
64- }
65-
6655 /// Constructs a new `Schema`.
6756 ///
6857 /// - Parameters:
@@ -98,7 +87,7 @@ public class Schema: Encodable {
9887/// A data type.
9988///
10089/// Contains the set of OpenAPI [data types](https://spec.openapis.org/oas/v3.0.3#data-types).
101- public enum DataType : String , Encodable {
90+ public enum DataType : String {
10291 /// A `String` type.
10392 case string = " STRING "
10493
@@ -157,7 +146,7 @@ public struct FunctionDeclaration {
157146///
158147/// A `Tool` is a piece of code that enables the system to interact with external systems to
159148/// perform an action, or set of actions, outside of knowledge and scope of the model.
160- public struct Tool : Encodable {
149+ public struct Tool {
161150 /// A list of `FunctionDeclarations` available to the model.
162151 let functionDeclarations : [ FunctionDeclaration ] ?
163152
@@ -178,10 +167,10 @@ public struct Tool: Encodable {
178167}
179168
180169/// Configuration for specifying function calling behavior.
181- public struct FunctionCallingConfig : Encodable {
170+ public struct FunctionCallingConfig {
182171 /// Defines the execution behavior for function calling by defining the
183172 /// execution mode.
184- public enum Mode : String , Encodable {
173+ public enum Mode : String {
185174 /// The default behavior for function calling. The model calls functions to answer queries at
186175 /// its discretion.
187176 case auto = " AUTO "
@@ -213,8 +202,7 @@ public struct FunctionCallingConfig: Encodable {
213202}
214203
215204/// Tool configuration for any `Tool` specified in the request.
216- @available ( iOS 15 . 0 , macOS 11 . 0 , macCatalyst 15 . 0 , * )
217- public struct ToolConfig : Encodable {
205+ public struct ToolConfig {
218206 let functionCallingConfig : FunctionCallingConfig ?
219207
220208 public init ( functionCallingConfig: FunctionCallingConfig ? = nil ) {
@@ -227,7 +215,7 @@ public struct ToolConfig: Encodable {
227215/// Contains a string representing the `FunctionDeclaration.name` and a structured JSON object
228216/// containing any output from the function is used as context to the model. This should contain the
229217/// result of a ``FunctionCall`` made based on model prediction.
230- public struct FunctionResponse : Equatable , Encodable {
218+ public struct FunctionResponse : Equatable {
231219 /// The name of the function that was called.
232220 let name : String
233221
@@ -264,6 +252,8 @@ extension FunctionCall: Decodable {
264252 }
265253}
266254
255+ extension FunctionCall : Encodable { }
256+
267257extension FunctionDeclaration : Encodable {
268258 enum CodingKeys : String , CodingKey {
269259 case name
@@ -278,3 +268,28 @@ extension FunctionDeclaration: Encodable {
278268 try container. encode ( parameters, forKey: . parameters)
279269 }
280270}
271+
272+ extension Schema : Encodable {
273+ enum CodingKeys : String , CodingKey {
274+ case type
275+ case format
276+ case description
277+ case nullable
278+ case enumValues = " enum "
279+ case items
280+ case properties
281+ case requiredProperties = " required "
282+ }
283+ }
284+
285+ extension DataType : Encodable { }
286+
287+ extension Tool : Encodable { }
288+
289+ extension FunctionCallingConfig : Encodable { }
290+
291+ extension FunctionCallingConfig . Mode : Encodable { }
292+
293+ extension ToolConfig : Encodable { }
294+
295+ extension FunctionResponse : Encodable { }
0 commit comments