feat(m1): Ollama client, catalog, streaming chat and CLI (T1.1-T1.6)
Add endpoint policy and redirect-safe ephemeral HTTP client, error mapping, catalog cache and version checks, streaming chat with phase timeouts/cancellation, provisional Hy-MT3 prompt/language/request factory, warm-up policy, and sprachmittler-cli models/show/translate. Recapture the 7B fixtures; defer the 1.8B VERIFY items; document ADR-016. Also fix the signature checker's pipefail SIGPIPE issue.
This commit is contained in:
1 parent
7ca5c710ec
commit
26b493e7e5
93 files changed
+3732
-218
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import Foundation
|
||||
|
||||
/// Schedules one timeout at a time. Scheduling a new phase cancels the previous timer.
|
||||
actor ChatTimeoutController {
|
||||
private let sleeper: any AsyncSleeper
|
||||
private var generation = 0
|
||||
private var task: Task<Void, Never>?
|
||||
private var handler: (@Sendable (TimeoutPhase) -> Void)?
|
||||
|
||||
init(sleeper: any AsyncSleeper) {
|
||||
self.sleeper = sleeper
|
||||
}
|
||||
|
||||
func schedule(
|
||||
_ phase: TimeoutPhase,
|
||||
after duration: Duration,
|
||||
onTimeout: @escaping @Sendable (TimeoutPhase) -> Void
|
||||
) {
|
||||
generation += 1
|
||||
let expected = generation
|
||||
task?.cancel()
|
||||
handler = onTimeout
|
||||
task = Task { [weak self, sleeper] in
|
||||
do {
|
||||
try await sleeper.sleep(for: duration)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
await self?.fire(expected, phase)
|
||||
}
|
||||
}
|
||||
|
||||
private func fire(_ expected: Int, _ phase: TimeoutPhase) {
|
||||
guard expected == generation else { return }
|
||||
handler?(phase)
|
||||
}
|
||||
|
||||
func cancel() {
|
||||
generation += 1
|
||||
task?.cancel()
|
||||
task = nil
|
||||
handler = nil
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user