diff --git a/Package.resolved b/Package.resolved index 141e85f..4ab27f4 100644 --- a/Package.resolved +++ b/Package.resolved @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Quick/Nimble.git", "state" : { - "revision" : "d616f15123bfb36db1b1075153f73cf40605b39d", - "version" : "13.0.0" + "revision" : "c1f3dd66222d5e7a1a20afc237f7e7bc432c564f", + "version" : "13.2.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Quick/Quick.git", "state" : { - "revision" : "ef9aaf3f634b3a1ab6f54f1173fe2400b36e7cb8", - "version" : "7.3.0" + "revision" : "3dd0b6791850f99e56518467317a9eec53462c66", + "version" : "7.3.1" } }, { diff --git a/Sources/FalClient/Client.swift b/Sources/FalClient/Client.swift index 61e9592..b28c847 100644 --- a/Sources/FalClient/Client.swift +++ b/Sources/FalClient/Client.swift @@ -43,6 +43,7 @@ public protocol Client { func subscribe( to app: String, + path: String?, input: Payload?, pollInterval: DispatchTimeInterval, timeout: DispatchTimeInterval, @@ -82,6 +83,7 @@ public extension Client { /// - onQueueUpdate: A callback to be called when the queue status is updated. func subscribe( to app: String, + path: String? = nil, input: Payload? = nil, pollInterval: DispatchTimeInterval = .seconds(1), timeout: DispatchTimeInterval = .minutes(3), @@ -89,6 +91,7 @@ public extension Client { onQueueUpdate: OnQueueUpdate? = nil ) async throws -> Payload { try await subscribe(to: app, + path: path, input: input, pollInterval: pollInterval, timeout: timeout, diff --git a/Sources/FalClient/FalClient.swift b/Sources/FalClient/FalClient.swift index aa4e966..7c7b62c 100644 --- a/Sources/FalClient/FalClient.swift +++ b/Sources/FalClient/FalClient.swift @@ -46,13 +46,14 @@ public struct FalClient: Client { public func subscribe( to app: String, + path: String?, input: Payload?, pollInterval: DispatchTimeInterval, timeout: DispatchTimeInterval, includeLogs: Bool, onQueueUpdate: OnQueueUpdate? ) async throws -> Payload { - let requestId = try await queue.submit(app, input: input) + let requestId = try await queue.submit(app, path: path, input: input) let start = Int(Date().timeIntervalSince1970 * 1000) var elapsed = 0 var isCompleted = false diff --git a/Sources/FalClient/Queue.swift b/Sources/FalClient/Queue.swift index 07d0dd2..8acc1bc 100644 --- a/Sources/FalClient/Queue.swift +++ b/Sources/FalClient/Queue.swift @@ -7,7 +7,7 @@ public protocol Queue { /// Submits a request to the given [id], an optional [path]. This method /// uses the [queue] API to initiate the request. Next you need to rely on /// [status] and [result] to poll for the result. - func submit(_ id: String, input: Payload?, webhookUrl: String?) async throws -> String + func submit(_ id: String, path: String?, input: Payload?, webhookUrl: String?) async throws -> String /// Checks the queue for the status of the request with the given [requestId]. /// See [QueueStatus] for the different statuses. @@ -24,8 +24,8 @@ public protocol Queue { } public extension Queue { - func submit(_ id: String, input: Payload? = nil, webhookUrl: String? = nil) async throws -> String { - try await submit(id, input: input, webhookUrl: webhookUrl) + func submit(_ id: String, path: String? = nil, input: Payload? = nil, webhookUrl: String? = nil) async throws -> String { + try await submit(id, path: path, input: input, webhookUrl: webhookUrl) } func status(_ id: String, of requestId: String, includeLogs: Bool = false) async throws -> QueueStatus { @@ -64,8 +64,8 @@ public struct QueueClient: Queue { return try .create(fromJSON: data) } - public func submit(_ id: String, input: Payload?, webhookUrl _: String?) async throws -> String { - let result = try await runOnQueue(id, input: input, options: .withMethod(.post)) + public func submit(_ id: String, path: String?, input: Payload?, webhookUrl _: String?) async throws -> String { + let result = try await runOnQueue(id, input: input, options: .route(path ?? "", withMethod: .post)) guard case let .string(requestId) = result["request_id"] else { throw FalError.invalidResultFormat } diff --git a/Sources/Samples/FalSampleApp/FalSampleApp/ContentView.swift b/Sources/Samples/FalSampleApp/FalSampleApp/ContentView.swift index 6e4748b..28642c0 100644 --- a/Sources/Samples/FalSampleApp/FalSampleApp/ContentView.swift +++ b/Sources/Samples/FalSampleApp/FalSampleApp/ContentView.swift @@ -18,7 +18,7 @@ struct ContentView: View { isLoading = true do { let result = try await fal.subscribe( - to: "110602490-fast-sdxl", + to: "fal-ai/fast-sdxl", input: [ "prompt": .string(PROMPT), ],