Files
oai-swift/oAI/Models/Settings.swift
T
runeandClaude Sonnet 5 cf3f4ebfe4 Relicense oAI from AGPL-3.0-or-later to PolyForm Noncommercial 1.0.0
Switches the project from AGPL to a source-available license that
restricts commercial use — selling oAI or any part of it, standalone
or bundled into another product/service, now requires a separate
commercial license from the copyright holder. Noncommercial use,
study, modification, and sharing remain fully permitted.

Updates: LICENSE (canonical PolyForm Noncommercial 1.0.0 text +
commercial licensing contact note), SPDX headers and file-header
boilerplate across all Swift source files, the in-app About dialog's
license link (+ its localization catalog entry), README.md and
DEVELOPMENT.md license sections.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-15 11:16:09 +02:00

128 lines
3.5 KiB
Swift

//
// Settings.swift
// oAI
//
// Application settings and configuration
//
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
// Copyright (C) 2026 Rune Olsen
//
// This file is part of oAI.
//
// oAI is licensed under the PolyForm Noncommercial License 1.0.0.
// You may use, study, modify, and share it for any noncommercial
// purpose. Commercial use — including selling oAI or any part of
// it, standalone or bundled into another product or service —
// requires a separate commercial license from the copyright holder.
//
// See the LICENSE file or
// <https://polyformproject.org/licenses/noncommercial/1.0.0> for
// the full license text. For commercial licensing, contact Rune
// Olsen via <https://mac.oai.pm>.
import Foundation
struct Settings: Codable {
// Provider settings
var defaultProvider: Provider
var openrouterAPIKey: String?
var anthropicAPIKey: String?
var openaiAPIKey: String?
var ollamaBaseURL: String
// Model settings
var defaultModel: String?
var streamEnabled: Bool
var maxTokens: Int
var systemPrompt: String?
var customPromptMode: CustomPromptMode
// Feature flags
var onlineMode: Bool
var memoryEnabled: Bool
var mcpEnabled: Bool
// Web search
var searchProvider: SearchProvider
var googleAPIKey: String?
var googleSearchEngineID: String?
// UI
var costWarningThreshold: Double
enum Provider: String, Codable, CaseIterable {
case openrouter
case anthropic
case openai
case ollama
var displayName: String {
rawValue.capitalized
}
var iconName: String {
switch self {
case .openrouter: return "network"
case .anthropic: return "brain"
case .openai: return "sparkles"
case .ollama: return "server.rack"
}
}
}
enum SearchProvider: String, Codable, CaseIterable {
case anthropicNative = "anthropic_native"
case duckduckgo
case google
var displayName: String {
switch self {
case .anthropicNative: return "Anthropic Native"
case .duckduckgo: return "DuckDuckGo"
case .google: return "Google"
}
}
}
enum CustomPromptMode: String, Codable, CaseIterable {
case append = "append"
case replace = "replace"
var displayName: String {
switch self {
case .append: return "Append to Default"
case .replace: return "Replace Default (BYOP)"
}
}
var description: String {
switch self {
case .append: return "Your custom prompt will be added after the default system prompt"
case .replace: return "Only use your custom prompt (Bring Your Own Prompt)"
}
}
}
// Default settings
static let `default` = Settings(
defaultProvider: .openrouter,
openrouterAPIKey: nil,
anthropicAPIKey: nil,
openaiAPIKey: nil,
ollamaBaseURL: "http://localhost:11434",
defaultModel: nil,
streamEnabled: true,
maxTokens: 4096,
systemPrompt: nil,
customPromptMode: .append,
onlineMode: false,
memoryEnabled: true,
mcpEnabled: false,
searchProvider: .duckduckgo,
googleAPIKey: nil,
googleSearchEngineID: nil,
costWarningThreshold: 1.0
)
}