File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Sources/CompilerSwiftAI/Function Calling Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public extension CompilerClient {
1616 /// - state: Current state of your app (as defined by the developer, only needs to conform to Encodable and Sendable)
1717 /// - token: Authorization token
1818 /// - Returns: An array of functions with Parameters that are both Decodable and Sendable
19- func processFunction< State: AppStateProtocol , FunctionType: FunctionCallProtocol > (
19+ func processFunction< State: AppStateProtocol , FunctionType: Decodable & Sendable > (
2020 prompt: String ,
2121 for state: State
2222 ) async throws -> [ FunctionType ] {
Original file line number Diff line number Diff line change 22
33/// The Function struct hold's the function call being returned from Compiler with parameters defined by in the applcation
44public struct Function < Parameters: Decodable & Sendable > : FunctionCallProtocol {
5+ private enum CodingKeys : String , CodingKey {
6+ case id = " function "
7+ case parameters
8+ case colloquialDescription = " colloquial_response "
9+ }
10+
511 /// Function name
612 public let id : String
713
@@ -10,10 +16,10 @@ public struct Function<Parameters: Decodable & Sendable>: FunctionCallProtocol {
1016
1117 /// The description to show the user while this function is being executed.
1218 public let colloquialDescription : String
13-
14- private enum CodingKeys : String , CodingKey {
15- case id = " function "
16- case parameters
17- case colloquialDescription = " colloquial_response "
19+
20+ public init ( id : String , parameters : Parameters ? , colloquialDescription : String ) {
21+ self . id = id
22+ self . parameters = parameters
23+ self . colloquialDescription = colloquialDescription
1824 }
1925}
You can’t perform that action at this time.
0 commit comments