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.9 KB · 59 lines swift
Raw Blame History
1//2//  PersonaStore.swift3//  Zyquo Local4//5//  Author: Simon-Pierre Boucher6//  Mail: contact@spboucher.ai7//89import Foundation10import Observation1112/// User personas: system prompt + preferred model + params.13@MainActor14@Observable15final class PersonaStore {16    var personas: [Persona] {17        didSet { PersistenceService.saveDocument(personas, named: "personas") }18    }1920    init() {21        personas = PersistenceService.loadDocument([Persona].self, named: "personas") ?? Self.builtIns22    }2324    func add(_ persona: Persona) {25        personas.append(persona)26    }2728    func remove(id: UUID) {29        personas.removeAll { $0.id == id }30    }3132    func update(_ persona: Persona) {33        if let i = personas.firstIndex(where: { $0.id == persona.id }) {34            personas[i] = persona35        }36    }3738    private static let builtIns: [Persona] = [39        Persona(40            name: "Helpful Assistant",41            systemPrompt: "You are a helpful, concise assistant. Answer directly; use short paragraphs and lists when they aid clarity."42        ),43        Persona(44            name: "Code Reviewer",45            systemPrompt: "You are a rigorous senior engineer. Review code for correctness, clarity, performance and idiomatic style. Point at concrete lines, propose fixes, and keep praise brief.",46            params: GenerationParams(temperature: 0.3)47        ),48        Persona(49            name: "Technical Writer",50            systemPrompt: "You are a precise technical writer. Produce clear, well-structured prose with correct terminology, no filler, and consistent formatting.",51            params: GenerationParams(temperature: 0.5)52        ),53        Persona(54            name: "Socratic Tutor",55            systemPrompt: "You are a patient tutor. Guide with questions before revealing answers, adapt to the learner's level, and verify understanding with small checks."56        ),57    ]58}59