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,38 @@
|
||||
import Foundation
|
||||
import SprachmittlerEngines
|
||||
import SprachmittlerOllama
|
||||
|
||||
struct TranslateOutcome: Sendable, Equatable {
|
||||
let translation: String
|
||||
let model: String
|
||||
let target: ModelLanguage
|
||||
let metrics: ChatMetrics
|
||||
let firstTokenMs: Int?
|
||||
let totalMs: Int
|
||||
let sourceCharacters: Int
|
||||
|
||||
/// The CLI JSON contract from docs/TRANSLATION_OUTPUT.md §10. `sourceLanguage` stays null
|
||||
/// until T2.4; warnings stay empty until T2.5.
|
||||
func jsonData(includeSource: Bool, source: String) throws -> Data {
|
||||
let timing: [String: Any] = [
|
||||
"firstTokenMs": firstTokenMs.map { $0 as Any } ?? NSNull(),
|
||||
"totalMs": totalMs,
|
||||
"promptTokens": metrics.promptEvalCount.map { $0 as Any } ?? NSNull(),
|
||||
"outputTokens": metrics.evalCount.map { $0 as Any } ?? NSNull(),
|
||||
]
|
||||
var object: [String: Any] = [
|
||||
"schema": "sprachmittler-translation-v1",
|
||||
"sourceLanguage": NSNull(),
|
||||
"targetLanguage": target.code,
|
||||
"model": model,
|
||||
"sourceCharacters": sourceCharacters,
|
||||
"translation": translation,
|
||||
"warnings": [String](),
|
||||
"timing": timing,
|
||||
]
|
||||
if includeSource {
|
||||
object["source"] = source
|
||||
}
|
||||
return try JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted, .sortedKeys])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user