Skip to content

Commit 2108d12

Browse files
🎷 [UPDATE] Stream support added because now ACMNetworking also stream response supported.
1 parent bbcfdcf commit 2108d12

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

‎Package.resolved‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Package.swift‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import PackageDescription
55

66
let package = Package(
77
name: "ACMOpenAI",
8+
platforms: [
9+
.iOS(.v13), // Set the minimum iOS version here
10+
],
811
products: [
912
.library(
1013
name: "ACMOpenAI",
1114
targets: ["ACMOpenAI"]
1215
),
1316
],
1417
dependencies: [
15-
.package(url: "https://github.com/AppcentMobile/ACMNetworking.git", from: "1.1.3"),
18+
.package(url: "https://github.com/AppcentMobile/ACMNetworking.git", branch: "main"),
1619
],
1720
targets: [
1821
.target(

‎Sources/ACMOpenAI/Callbacks/Chat/ChatCallback.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ public struct ChatCallback {}
77

88
public extension ChatCallback {
99
/// Create chat typealias
10-
typealias Create = ((ACMOAIChatResponse.Create?) -> Void)?
10+
typealias Create = (([ACMOAIChatResponse.Create?]) -> Void)?
1111
}

‎Sources/ACMOpenAI/Manager/Chat/ACMOAIChatManager.swift‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,20 @@ public extension ACMOAIChatManager {
6060
to = to.add(param: ACMBodyModel(key: "user", value: user))
6161
}
6262

63-
network.request(to: to.build()) { (response: ACMOAIChatResponse.Create) in
64-
onSuccess?(response)
65-
} onError: { error in
66-
onError?(error)
63+
let buildEndpoint = to.build()
64+
65+
if request.stream == true {
66+
network.request(to: buildEndpoint) { (response: [ACMOAIChatResponse.Create]) in
67+
onSuccess?(response)
68+
} onError: { error in
69+
onError?(error)
70+
}
71+
} else {
72+
network.request(to: buildEndpoint) { (response: ACMOAIChatResponse.Create) in
73+
onSuccess?([response])
74+
} onError: { error in
75+
onError?(error)
76+
}
6777
}
6878
}
6979
}

0 commit comments

Comments
 (0)