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.4 KB · 55 lines swift
Raw Blame History
1//2//  Message.swift3//  Zyquo Local4//5//  Author: Simon-Pierre Boucher6//  Mail: contact@spboucher.ai7//89import Foundation1011/// A single chat message. `thinking` holds the extracted `<think>…</think>`12/// content for reasoning models; `stats` is present on assistant messages.13struct Message: Identifiable, Codable, Hashable, Sendable {14    enum Role: String, Codable, Sendable {15        case system16        case user17        case assistant18    }1920    var id: UUID21    var role: Role22    var content: String23    var thinking: String?24    var stats: MessageStats?25    var date: Date2627    init(28        id: UUID = UUID(),29        role: Role,30        content: String,31        thinking: String? = nil,32        stats: MessageStats? = nil,33        date: Date = Date()34    ) {35        self.id = id36        self.role = role37        self.content = content38        self.thinking = thinking39        self.stats = stats40        self.date = date41    }42}4344/// Per-response performance statistics (first-class per the spec).45struct MessageStats: Codable, Hashable, Sendable {46    /// Seconds from send to the first streamed token.47    var timeToFirstToken: TimeInterval48    /// Generation-phase tokens per second.49    var tokensPerSecond: Double50    var promptTokenCount: Int51    var generationTokenCount: Int52    /// Peak MLX GPU memory during the response, in bytes.53    var peakMemoryBytes: Int54}55