Download apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMediaPlaybackLoader.swift from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMediaPlaybackLoader.swift
- Command line
-
hf download hf://SaylorTwift/openclaw/apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMediaPlaybackLoader.swift
-
curl -L -o ChatMediaPlaybackLoader.swift https://huggingface.co/SaylorTwift/openclaw/resolve/main/apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMediaPlaybackLoader.swift
1.45 kB
| import Foundation | |
| struct ChatMediaPlaybackRetryPolicy: Sendable { | |
| /// Eleven waits total 120 seconds. The initial request plus these retries | |
| /// gives transcoding time to finish without leaving a card pending forever. | |
| static let bounded = ChatMediaPlaybackRetryPolicy(delays: [ | |
| .seconds(1), | |
| .seconds(2), | |
| .seconds(4), | |
| .seconds(8), | |
| .seconds(15), | |
| .seconds(15), | |
| .seconds(15), | |
| .seconds(15), | |
| .seconds(15), | |
| .seconds(15), | |
| .seconds(15), | |
| ]) | |
| let delays: [Duration] | |
| } | |
| enum ChatMediaPlaybackLoader { | |
| typealias Load = () async throws -> OpenClawChatLoadedMedia? | |
| typealias Sleep = (Duration) async throws -> Void | |
| static func load( | |
| policy: ChatMediaPlaybackRetryPolicy = .bounded, | |
| request: Load, | |
| onPreparing: () -> Void, | |
| sleep: Sleep = { try await Task.sleep(for: $0) }) async throws -> OpenClawChatLoadedMedia? | |
| { | |
| var loaded = try await request() | |
| guard case .preparing = loaded else { return loaded } | |
| onPreparing() | |
| for delay in policy.delays { | |
| try Task.checkCancellation() | |
| try await sleep(delay) | |
| loaded = try await request() | |
| guard case .preparing = loaded else { return loaded } | |
| onPreparing() | |
| } | |
| return nil | |
| } | |
| } | |