Files
schihei 26b493e7e5 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.
2026-11-26 13:04:22 +01:00

62 lines
1.9 KiB
Swift

import Foundation
/// One model returned by `GET /api/tags`.
public struct InstalledModel: Sendable, Equatable, Decodable {
/// The user-facing tag, e.g. `hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M`.
public let name: String
/// The tag as Ollama reports it (normally identical to `name`).
public let model: String
/// The ISO-8601 modification time, when present.
public let modifiedAt: String?
/// The model size in bytes, when present.
public let size: Int64?
/// The full sha256 digest.
public let digest: String
/// The optional family/quantization details.
public let details: ModelDetailsInfo?
/// Creates a model value.
public init(
name: String,
model: String,
modifiedAt: String? = nil,
size: Int64? = nil,
digest: String,
details: ModelDetailsInfo? = nil
) {
self.name = name
self.model = model
self.modifiedAt = modifiedAt
self.size = size
self.digest = digest
self.details = details
}
/// True when the tag or model name contains `hy-mt3`, case-insensitively.
///
/// Temporary for the M1 CLI filter; the adapter registry (T2.1) owns family matching in M2.
public var isHyMT3: Bool {
name.localizedCaseInsensitiveContains("hy-mt3")
|| model.localizedCaseInsensitiveContains("hy-mt3")
}
/// `name` with a trailing `:latest` removed.
public var normalizedName: String {
Self.normalizedName(name)
}
/// Removes only a trailing `:latest`; other tags are preserved.
public static func normalizedName(_ name: String) -> String {
name.hasSuffix(":latest") ? String(name.dropLast(":latest".count)) : name
}
private enum CodingKeys: String, CodingKey {
case name
case model
case modifiedAt = "modified_at"
case size
case digest
case details
}
}