import SprachmittlerOllama /// The Hy-MT3 adapter: exact documented prompt, publisher sampling, no system message, no /// thinking and an explicit 8192-token context (`docs/HYMT3_MODEL.md` §1–§3). public struct HyMT3Adapter: TranslationAdapter { /// The stable adapter identifier. public let identifier = "hy-mt3" /// The adapter version. public let version = 1 /// Creates the adapter. public init() {} /// Matches every Hy-MT3 tag, including 7B, 1.8B and 30B-A3B conversions. public func supports(model: String) -> Bool { HyMT3ModelPreset.isHyMT3(model) } /// Builds one documented request. There is exactly one user message and no system message. public func makeRequest(_ request: AdapterRequest) -> ChatRequest { let content = HyMT3Prompt.text(for: request.prompt, target: request.target, source: request.text) return ChatRequest( model: request.model, messages: [ChatMessage(content: content)], stream: true, keepAlive: request.keepAlive, options: request.sampling.chatOptions() ) } /// A warm-up request with fixed synthetic text and `num_predict: 8` (T1.5). public func warmUpRequest(model: String, keepAlive: String) -> 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(model: String) -> ChatRequest { ChatRequest( model: model, messages: [ChatMessage(content: HyMT3ModelPreset.warmUpText)], stream: true, keepAlive: "0", options: HyMT3Options.warmUp ) } }