Skip to content

Commit 39819cc

Browse files
🎷 [UPDATE] Tools updated.
1 parent b40ed0b commit 39819cc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Sources/ACMOpenAI/Manager/Chat/ACMOAIChatManager.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ public extension ACMOAIChatManager {
6868
}
6969

7070
if let tool_choice = request.tool_choice {
71-
to = to.add(param: ACMBodyModel(key: "tool_choice", value: tool_choice))
71+
if let strChoice = tool_choice.strChoice {
72+
to = to.add(param: ACMBodyModel(key: "tool_choice", value: strChoice))
73+
} else if let objChoice = tool_choice.objChoice {
74+
to = to.add(param: ACMBodyModel(key: "tool_choice", value: ACMToolChoiceObjectModel(type: objChoice.type, function: objChoice.function)))
75+
}
7276
}
7377

7478
let buildEndpoint = to.build()

Sources/ACMOpenAI/Requests/Chat/ACMToolsModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public struct ACMToolsFunctionModel: Codable {
2525
public init(description: String? = nil, name: String, params: [String: Any]? = nil) {
2626
self.description = description
2727
self.name = name
28-
if let params {
29-
self.parameters = String(describing: params)
28+
if let params, let data = try? JSONSerialization.data(withJSONObject: params, options: []) {
29+
parameters = String(data: data, encoding: .utf8)
3030
} else {
31-
self.parameters = nil
31+
parameters = nil
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)