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:
schihei committed 2026-11-26 13:04:22 +01:00
1 parent 7ca5c710ec
commit 26b493e7e5
93 files changed
+3732 -218

No files matched your search

@@ -0,0 +1,52 @@
import SprachmittlerOllama
/// Builds the documented Hy-MT3 requests. T2.1/T2.2 replace this with the adapter protocol;
/// until then this is the only place the translation request shape is assembled.
public struct HyMT3RequestFactory: Sendable {
/// The model tag.
public let model: String
/// The Ollama `keep_alive` value.
public let keepAlive: String
/// Creates a factory.
public init(
model: String = HyMT3ModelPreset.defaultModel,
keepAlive: String = HyMT3ModelPreset.defaultKeepAlive
) {
self.model = model
self.keepAlive = keepAlive
}
/// A translation request with the documented prompt and sampling.
public func translationRequest(text: String, target: ModelLanguage) -> ChatRequest {
ChatRequest(
model: model,
messages: [ChatMessage(content: HyMT3Prompt.defaultTranslation(target: target, source: text))],
stream: true,
keepAlive: keepAlive,
options: HyMT3Options.translation
)
}
/// A warm-up request with fixed synthetic text and `num_predict: 8`.
public func warmUpRequest() -> ChatRequest {
ChatRequest(
model: model,
messages: [ChatMessage(content: HyMT3ModelPreset.warmUpText)],
stream: true,
keepAlive: keepAlive,
options: HyMT3Options.warmUp
)
}
/// A request that unloads the model after it completes.
public func unloadRequest() -> ChatRequest {
ChatRequest(
model: model,
messages: [ChatMessage(content: HyMT3ModelPreset.warmUpText)],
stream: true,
keepAlive: "0",
options: HyMT3Options.warmUp
)
}
}