Files
oai-swift/oAI/Models/Skill.swift

51 lines
1.6 KiB
Swift

//
// Shortcut.swift
// oAI
//
// User-defined slash command templates (prompt shortcuts/macros)
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 Rune Olsen
//
// This file is part of oAI.
//
// oAI is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// oAI is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
// Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with oAI. If not, see <https://www.gnu.org/licenses/>.
import Foundation
struct Shortcut: Codable, Identifiable {
var id: UUID
var command: String // e.g. "/summarize" (always starts with /)
var description: String // shown in dropdown
var template: String // prompt text, may contain {{input}}
var createdAt: Date
var updatedAt: Date
init(id: UUID = UUID(), command: String, description: String, template: String,
createdAt: Date = Date(), updatedAt: Date = Date()) {
self.id = id
self.command = command
self.description = description
self.template = template
self.createdAt = createdAt
self.updatedAt = updatedAt
}
/// True when the template uses {{input}} and needs the user to provide text
var needsInput: Bool {
template.contains("{{input}}")
}
}