// // Message.swift // Zyquo Local // // Author: Simon-Pierre Boucher // Mail: contact@spboucher.ai // import Foundation /// A single chat message. `thinking` holds the extracted `` /// content for reasoning models; `stats` is present on assistant messages. struct Message: Identifiable, Codable, Hashable, Sendable { enum Role: String, Codable, Sendable { case system case user case assistant } var id: UUID var role: Role var content: String var thinking: String? var stats: MessageStats? var date: Date init( id: UUID = UUID(), role: Role, content: String, thinking: String? = nil, stats: MessageStats? = nil, date: Date = Date() ) { self.id = id self.role = role self.content = content self.thinking = thinking self.stats = stats self.date = date } } /// Per-response performance statistics (first-class per the spec). struct MessageStats: Codable, Hashable, Sendable { /// Seconds from send to the first streamed token. var timeToFirstToken: TimeInterval /// Generation-phase tokens per second. var tokensPerSecond: Double var promptTokenCount: Int var generationTokenCount: Int /// Peak MLX GPU memory during the response, in bytes. var peakMemoryBytes: Int }