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

fix: fail closed for unavailable private ai

altic-dev6ca8ef0ca07d
diff --git a/Sources/Fluid/Services/DictationPostProcessingService.swift b/Sources/Fluid/Services/DictationPostProcessingService.swift
index 73f14b05..ced00f58 100644
--- a/Sources/Fluid/Services/DictationPostProcessingService.swift
+++ b/Sources/Fluid/Services/DictationPostProcessingService.swift
@@ -30,16 +30,8 @@ struct DictationProviderRoute: Equatable {
if selection == .off {
return Self(providerID: "", providerKey: "", baseURL: "", model: "", apiKey: "")
}
- if selection == .privateAI,
- let modelID = PrivateAIProviderPromptFormat.verifiedModelID(settings: settings)
- {
- return Self(
- providerID: PrivateAIProviderFeature.shared.providerID,
- providerKey: PrivateAIProviderFeature.shared.providerID,
- baseURL: ModelRepository.shared.defaultBaseURL(for: PrivateAIProviderFeature.shared.providerID),
- model: modelID,
- apiKey: ""
- )
+ if selection == .privateAI {
+ return self.privateAIRoute(settings: settings)
}
let configuration = settings.dictationPromptConfiguration(for: selection)
@@ -90,6 +82,19 @@ struct DictationProviderRoute: Equatable {
)
}
+ static func privateAIRoute(settings: SettingsStore) -> Self {
+ guard let modelID = PrivateAIProviderPromptFormat.verifiedModelID(settings: settings) else {
+ return Self(providerID: "", providerKey: "", baseURL: "", model: "", apiKey: "")
+ }
+ return Self(
+ providerID: PrivateAIProviderFeature.shared.providerID,
+ providerKey: PrivateAIProviderFeature.shared.providerID,
+ baseURL: ModelRepository.shared.defaultBaseURL(for: PrivateAIProviderFeature.shared.providerID),
+ model: modelID,
+ apiKey: ""
+ )
+ }
+
private static func effectivePromptSelection(
settings: SettingsStore,
dictationSlot: SettingsStore.DictationShortcutSlot,
diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
index acd04198..775c155f 100644
--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
@@ -1599,6 +1599,21 @@ final class DictationE2ETests: XCTestCase {
}
}
+ func testDictationProviderRouteReturnsEmptyRouteForUnverifiedPrivateAI() {
+ self.withPromptAndProviderSettingsRestored {
+ let settings = SettingsStore.shared
+ settings.verifiedProviderFingerprints = [:]
+
+ let route = DictationProviderRoute.privateAIRoute(settings: settings)
+
+ XCTAssertEqual(
+ route,
+ DictationProviderRoute(providerID: "", providerKey: "", baseURL: "", model: "", apiKey: "")
+ )
+ XCTAssertFalse(route.usesPrivateAI)
+ }
+ }
+
func testDictationProviderRouteUsesAppBoundPromptConfiguration() {
self.withRestoredDefaults(
keys: [
@@ -2184,6 +2199,7 @@ final class DictationE2ETests: XCTestCase {
self.selectedProviderIDKey,
self.availableModelsByProviderKey,
self.selectedModelByProviderKey,
+ self.verifiedProviderFingerprintsKey,
self.privateAISelectedModelIDKey,
],
run: run