SPB Git

spb/zyquo-local Public MIT

Native macOS AI chat that runs LLMs 100% locally on Apple Silicon with MLX — no cloud, no API keys.

Swift 97.2% Shell 1.8% Makefile 1%
1.3 KB · 51 lines swift
Raw Blame History
1//2//  GenerationParams.swift3//  Zyquo Local4//5//  Author: Simon-Pierre Boucher6//  Mail: contact@spboucher.ai7//89import Foundation10import MLXLMCommon1112/// App-level, persistable generation parameters. Mapped to MLX13/// `GenerateParameters` at the engine boundary — inference behavior never14/// leaks out of the Engine layer.15struct GenerationParams: Codable, Hashable, Sendable {16    var temperature: Float17    var topP: Float18    var repetitionPenalty: Float?19    /// nil = no cap (bounded by the context window).20    var maxTokens: Int?21    /// nil = fresh entropy per generation.22    var seed: UInt64?2324    init(25        temperature: Float = 0.7,26        topP: Float = 0.95,27        repetitionPenalty: Float? = nil,28        maxTokens: Int? = nil,29        seed: UInt64? = nil30    ) {31        self.temperature = temperature32        self.topP = topP33        self.repetitionPenalty = repetitionPenalty34        self.maxTokens = maxTokens35        self.seed = seed36    }37}3839extension GenerationParams {40    /// Engine-internal mapping to MLX parameters.41    func toMLX() -> GenerateParameters {42        var p = GenerateParameters()43        p.temperature = temperature44        p.topP = topP45        p.repetitionPenalty = repetitionPenalty46        p.maxTokens = maxTokens47        p.seed = seed48        return p49    }50}51