Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

889 B
Raw Blame
import Foundation

struct CommandModelOption: Identifiable, Hashable {
    let providerID: String
    let providerName: String
    let modelID: String
    let displayName: String

    // Length-prefix the provider so model IDs containing separators cannot collide.
    var id: String { "\(self.providerID.utf8.count):\(self.providerID)\(self.modelID)" }
}

enum CommandModelCatalog {
    static func filtered(_ options: [CommandModelOption], query: String) -> [CommandModelOption] {
        let terms = query.split(whereSeparator: \.isWhitespace).map(String.init)
        guard !terms.isEmpty else { return options }
        return options.filter { option in
            let fields = [option.providerID, option.providerName, option.modelID, option.displayName]
            return terms.allSatisfy { term in fields.contains { $0.localizedCaseInsensitiveContains(term) } }
        }
    }
}