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 ) } }