new features

This commit is contained in:
Mark Gregory
2026-11-17 16:39:43 +00:00
parent d1a1b454f6
commit 713d021454
13 changed files with 1100 additions and 141 deletions
+43
View File
@@ -6,14 +6,57 @@ struct StudioError: LocalizedError, Sendable {
var errorDescription: String? { message }
}
struct ChatModelChoice: Equatable, Codable {
static let settingsKey = "chatModelChoices"
enum Backend: String, Codable {
case ollama = "Ollama"
case mlx = "MLX"
case compatible = "Compatible API"
}
let backend: Backend
let model: String
var displayName: String {
guard !model.isEmpty else { return "Choose Model" }
return backend == .mlx ? URL(fileURLWithPath: model).lastPathComponent : model
}
static func read(_ data: Data) -> [UUID: Self] {
(try? JSONDecoder().decode([UUID: Self].self, from: data)) ?? [:]
}
func thinkingMode(_ mode: Thinking) -> Thinking {
if backend == .mlx && ![Thinking.automatic, .off, .on].contains(mode) { return .automatic }
return mode
}
}
enum Role: String, Codable, Sendable { case system, user, assistant }
struct WebReplySource: Identifiable, Equatable, Codable, Sendable {
enum Kind: String, Codable, Sendable {
case page = "Retrieved page"
case searchSnippet = "Search snippet"
case savedClip = "Saved web clip"
}
let url: URL
let title: String
let kind: Kind
var id: String { kind.rawValue + " " + url.absoluteString }
}
struct Message: Identifiable, Equatable, Sendable {
var id = UUID()
let role: Role
var content: String
var thinking = ""
var backend = ""
var webSources: [WebReplySource] = []
var documentNames: [String] = []
}
enum Thinking: String, CaseIterable, Codable, Identifiable, Sendable {