60 lines
1.6 KiB
Swift
60 lines
1.6 KiB
Swift
//
|
|
// Conversation.swift
|
|
// oAI
|
|
//
|
|
// Model for saved conversations
|
|
//
|
|
// 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 Conversation: Identifiable, Codable {
|
|
let id: UUID
|
|
var name: String
|
|
var messages: [Message]
|
|
let createdAt: Date
|
|
var updatedAt: Date
|
|
var primaryModel: String? // Primary model used in this conversation
|
|
|
|
init(
|
|
id: UUID = UUID(),
|
|
name: String,
|
|
messages: [Message] = [],
|
|
createdAt: Date = Date(),
|
|
updatedAt: Date = Date(),
|
|
primaryModel: String? = nil
|
|
) {
|
|
self.id = id
|
|
self.name = name
|
|
self.messages = messages
|
|
self.createdAt = createdAt
|
|
self.updatedAt = updatedAt
|
|
self.primaryModel = primaryModel
|
|
}
|
|
|
|
var messageCount: Int {
|
|
messages.count
|
|
}
|
|
|
|
var lastMessageDate: Date {
|
|
messages.last?.timestamp ?? updatedAt
|
|
}
|
|
}
|