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.
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// A comparable Ollama version such as `0.40.18`.
|
|
public struct OllamaVersion: Comparable, Sendable, CustomStringConvertible {
|
|
/// The numeric components, e.g. `[0, 40, 18]`.
|
|
public let components: [Int]
|
|
|
|
/// The minimum supported server version (ARCHITECTURE §2).
|
|
public static let minimumSupported = OllamaVersion(components: [0, 40, 0])
|
|
|
|
/// Parses a dotted numeric version. Returns nil for non-numeric or empty input.
|
|
public init?(_ string: String) {
|
|
let withoutBuild = string.split(separator: "+", maxSplits: 1).first.map(String.init) ?? string
|
|
let core = withoutBuild.split(separator: "-", maxSplits: 1).first.map(String.init) ?? withoutBuild
|
|
let parts = core.split(separator: ".").map { Int($0) }
|
|
guard !parts.isEmpty, parts.allSatisfy({ $0 != nil }) else {
|
|
return nil
|
|
}
|
|
components = parts.compactMap(\.self)
|
|
}
|
|
|
|
private init(components: [Int]) {
|
|
self.components = components
|
|
}
|
|
|
|
/// The dotted representation.
|
|
public var description: String {
|
|
components.map(String.init).joined(separator: ".")
|
|
}
|
|
|
|
/// Component-wise comparison, padding the shorter version with zeros.
|
|
public static func < (lhs: OllamaVersion, rhs: OllamaVersion) -> Bool {
|
|
let count = max(lhs.components.count, rhs.components.count)
|
|
for index in 0 ..< count {
|
|
let left = index < lhs.components.count ? lhs.components[index] : 0
|
|
let right = index < rhs.components.count ? rhs.components[index] : 0
|
|
if left != right {
|
|
return left < right
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
/// Equality treats `0.40` and `0.40.0` as the same version.
|
|
public static func == (lhs: OllamaVersion, rhs: OllamaVersion) -> Bool {
|
|
!(lhs < rhs) && !(rhs < lhs)
|
|
}
|
|
}
|