15
15
import Foundation
16
16
17
17
/// A predicted function call returned from the model.
18
- public struct FunctionCall : Equatable , Encodable {
18
+ public struct FunctionCall : Equatable {
19
19
/// The name of the function to call.
20
20
public let name : String
21
21
@@ -27,7 +27,7 @@ public struct FunctionCall: Equatable, Encodable {
27
27
///
28
28
/// These types can be objects, but also primitives and arrays. Represents a select subset of an
29
29
/// [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema).
30
- public class Schema : Encodable {
30
+ public class Schema {
31
31
/// The data type.
32
32
let type : DataType
33
33
@@ -98,7 +98,7 @@ public class Schema: Encodable {
98
98
/// A data type.
99
99
///
100
100
/// Contains the set of OpenAPI [data types](https://spec.openapis.org/oas/v3.0.3#data-types).
101
- public enum DataType : String , Encodable {
101
+ public enum DataType : String {
102
102
/// A `String` type.
103
103
case string = " STRING "
104
104
@@ -157,7 +157,7 @@ public struct FunctionDeclaration {
157
157
///
158
158
/// A `Tool` is a piece of code that enables the system to interact with external systems to
159
159
/// perform an action, or set of actions, outside of knowledge and scope of the model.
160
- public struct Tool : Encodable {
160
+ public struct Tool {
161
161
/// A list of `FunctionDeclarations` available to the model.
162
162
let functionDeclarations : [ FunctionDeclaration ] ?
163
163
@@ -178,10 +178,10 @@ public struct Tool: Encodable {
178
178
}
179
179
180
180
/// Configuration for specifying function calling behavior.
181
- public struct FunctionCallingConfig : Encodable {
181
+ public struct FunctionCallingConfig {
182
182
/// Defines the execution behavior for function calling by defining the
183
183
/// execution mode.
184
- public enum Mode : String , Encodable {
184
+ public enum Mode : String {
185
185
/// The default behavior for function calling. The model calls functions to answer queries at
186
186
/// its discretion.
187
187
case auto = " AUTO "
@@ -213,8 +213,7 @@ public struct FunctionCallingConfig: Encodable {
213
213
}
214
214
215
215
/// 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 {
216
+ public struct ToolConfig {
218
217
let functionCallingConfig : FunctionCallingConfig ?
219
218
220
219
public init ( functionCallingConfig: FunctionCallingConfig ? = nil ) {
@@ -227,7 +226,7 @@ public struct ToolConfig: Encodable {
227
226
/// Contains a string representing the `FunctionDeclaration.name` and a structured JSON object
228
227
/// containing any output from the function is used as context to the model. This should contain the
229
228
/// result of a ``FunctionCall`` made based on model prediction.
230
- public struct FunctionResponse : Equatable , Encodable {
229
+ public struct FunctionResponse : Equatable {
231
230
/// The name of the function that was called.
232
231
let name : String
233
232
@@ -264,6 +263,8 @@ extension FunctionCall: Decodable {
264
263
}
265
264
}
266
265
266
+ extension FunctionCall : Encodable { }
267
+
267
268
extension FunctionDeclaration : Encodable {
268
269
enum CodingKeys : String , CodingKey {
269
270
case name
@@ -278,3 +279,17 @@ extension FunctionDeclaration: Encodable {
278
279
try container. encode ( parameters, forKey: . parameters)
279
280
}
280
281
}
282
+
283
+ extension Schema : Encodable { }
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