File size: 1,323 Bytes
4977db2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import Foundation
public struct CountedValue: Identifiable, Hashable, Sendable {
public var id: String { name }
public let name: String
public let count: Int
public init(name: String, count: Int) {
self.name = name
self.count = count
}
}
public struct PromptStatistics: Sendable {
public let total: Int
public let starred: Int
public let totalUses: Int
public let sourceFamilies: [CountedValue]
public let models: [CountedValue]
public let tags: [CountedValue]
public let ratingDistribution: [Int: Int]
public init(
total: Int,
starred: Int,
totalUses: Int,
sourceFamilies: [CountedValue],
models: [CountedValue],
tags: [CountedValue],
ratingDistribution: [Int: Int]
) {
self.total = total
self.starred = starred
self.totalUses = totalUses
self.sourceFamilies = sourceFamilies
self.models = models
self.tags = tags
self.ratingDistribution = ratingDistribution
}
public static let empty = PromptStatistics(
total: 0,
starred: 0,
totalUses: 0,
sourceFamilies: [],
models: [],
tags: [],
ratingDistribution: Dictionary(uniqueKeysWithValues: (0...5).map { ($0, 0) })
)
}
|