Skip to content

Commit 24bebd3

Browse files
Add ToolCallMessage struct and update FunctionCallDetails to use dictionary for arguments
1 parent 6dade8c commit 24bebd3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Sources/Grok-API-SDK/Models/ChatData.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,11 @@ public struct SchemaProperty: Codable, Sendable {
242242
public let type: String
243243
public let description: String?
244244
}
245+
246+
public struct ToolCallMessage: Codable, Sendable {
247+
public let toolCalls: [ToolCall]?
248+
249+
enum CodingKeys: String, CodingKey {
250+
case toolCalls = "tool_calls"
251+
}
252+
}

Sources/Grok-API-SDK/Models/FunctionCall.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ public struct ToolCall: Codable, Sendable {
8080

8181
public struct FunctionCallDetails: Codable, Sendable {
8282
public let name: String
83-
public let arguments: String
83+
public let arguments: [String: String] // Change to dictionary to match JSON response
84+
85+
// Explicit public initializer
86+
public init(name: String, arguments: [String: String]) {
87+
self.name = name
88+
self.arguments = arguments
89+
}
8490
}
8591

8692
public struct ToolCallResponse: Codable, Sendable {

0 commit comments

Comments
 (0)