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
@@ -52,17 +52,6 @@ public class Schema: Encodable {
52
52
/// Required properties of type ``DataType/object``.
53
53
let requiredProperties : [ String ] ?
54
54
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
-
66
55
/// Constructs a new `Schema`.
67
56
///
68
57
/// - Parameters:
@@ -98,7 +87,7 @@ public class Schema: Encodable {
98
87
/// A data type.
99
88
///
100
89
/// 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 {
102
91
/// A `String` type.
103
92
case string = " STRING "
104
93
@@ -157,7 +146,7 @@ public struct FunctionDeclaration {
157
146
///
158
147
/// A `Tool` is a piece of code that enables the system to interact with external systems to
159
148
/// perform an action, or set of actions, outside of knowledge and scope of the model.
160
- public struct Tool : Encodable {
149
+ public struct Tool {
161
150
/// A list of `FunctionDeclarations` available to the model.
162
151
let functionDeclarations : [ FunctionDeclaration ] ?
163
152
@@ -178,10 +167,10 @@ public struct Tool: Encodable {
178
167
}
179
168
180
169
/// Configuration for specifying function calling behavior.
181
- public struct FunctionCallingConfig : Encodable {
170
+ public struct FunctionCallingConfig {
182
171
/// Defines the execution behavior for function calling by defining the
183
172
/// execution mode.
184
- public enum Mode : String , Encodable {
173
+ public enum Mode : String {
185
174
/// The default behavior for function calling. The model calls functions to answer queries at
186
175
/// its discretion.
187
176
case auto = " AUTO "
@@ -213,8 +202,7 @@ public struct FunctionCallingConfig: Encodable {
213
202
}
214
203
215
204
/// 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 {
218
206
let functionCallingConfig : FunctionCallingConfig ?
219
207
220
208
public init ( functionCallingConfig: FunctionCallingConfig ? = nil ) {
@@ -227,7 +215,7 @@ public struct ToolConfig: Encodable {
227
215
/// Contains a string representing the `FunctionDeclaration.name` and a structured JSON object
228
216
/// containing any output from the function is used as context to the model. This should contain the
229
217
/// result of a ``FunctionCall`` made based on model prediction.
230
- public struct FunctionResponse : Equatable , Encodable {
218
+ public struct FunctionResponse : Equatable {
231
219
/// The name of the function that was called.
232
220
let name : String
233
221
@@ -264,6 +252,8 @@ extension FunctionCall: Decodable {
264
252
}
265
253
}
266
254
255
+ extension FunctionCall : Encodable { }
256
+
267
257
extension FunctionDeclaration : Encodable {
268
258
enum CodingKeys : String , CodingKey {
269
259
case name
@@ -278,3 +268,28 @@ extension FunctionDeclaration: Encodable {
278
268
try container. encode ( parameters, forKey: . parameters)
279
269
}
280
270
}
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