-
-
Notifications
You must be signed in to change notification settings - Fork 68
Add Apple Intelligence language-fallback settings #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import Foundation | ||
| import SwiftUI | ||
|
|
||
| /// Apple Intelligence availability presentation. | ||
|
|
@@ -23,6 +24,64 @@ extension EngineAndModelPaneView { | |
| ) | ||
| } | ||
| .settingsItem(.appleIntelligenceAvailability) | ||
|
|
||
| Toggle(isOn: Binding( | ||
| get: { suggestionSettings.isAppleLanguageFallbackEnabled }, | ||
| set: { suggestionSettings.setAppleLanguageFallbackEnabled($0) } | ||
| )) { | ||
| SettingsRowLabel( | ||
| title: "Fall Back to Open Source Model", | ||
| description: "When Apple Intelligence doesn't support the language you're writing in, " + | ||
| "suggest with \(fallbackModelName) instead. Turn off to get no suggestion in those languages.", | ||
| systemImage: "arrow.triangle.branch" | ||
| ) | ||
| } | ||
| .settingsItem(.appleLanguageFallback) | ||
|
|
||
| Toggle(isOn: Binding( | ||
| get: { suggestionSettings.keepsFallbackModelLoaded }, | ||
| set: { suggestionSettings.setKeepsFallbackModelLoaded($0) } | ||
| )) { | ||
| SettingsRowLabel( | ||
| title: "Keep Fallback Model Loaded", | ||
| description: "Load the fallback model in advance so its first suggestion doesn't wait for it " + | ||
| "to load. Uses the model's memory (several GB) while Apple Intelligence is selected.", | ||
| systemImage: "memorychip" | ||
| ) | ||
| } | ||
| .disabled(!suggestionSettings.isAppleLanguageFallbackEnabled) | ||
|
Comment on lines
+41
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
“Keep Fallback Model Loaded” has no search item or row anchor. Its search terms, including “keep loaded” and “preload,” belong to the fallback switch's item, so searching for the new setting highlights the other switch instead. Give the keep-loaded switch its own indexed item and anchor so search can take users directly to it. Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| // The Open Source section is hidden while Apple Intelligence is the engine, so the | ||
| // fallback model is chosen here. It is the same selection the Open Source engine uses: | ||
| // the local runtime holds one model at a time. | ||
| if runtimeModel.availableModels.isEmpty { | ||
| Text("No downloaded models were found, so there is nothing to fall back to. " + | ||
| "Switch the engine to Open Source to download one.") | ||
| .font(.caption) | ||
| .foregroundStyle(.orange) | ||
| } else { | ||
| Picker(selection: selectedModelBinding) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ForEach(runtimeModel.availableModels) { model in | ||
| Text(model.displayName).tag(model.filename) | ||
| } | ||
| } label: { | ||
| SettingsRowLabel( | ||
| title: "Fallback Model", | ||
| description: "The downloaded model used when Apple Intelligence can't handle the " + | ||
| "language. It is also your Open Source engine's model.", | ||
| systemImage: "shippingbox" | ||
| ) | ||
| } | ||
| .disabled(!suggestionSettings.isAppleLanguageFallbackEnabled | ||
| || suggestionSettings.isPowerBasedModelSwitchingEnabled) | ||
| .settingsItem(.appleLanguageFallbackModel) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// The model the fallback uses: the selected Open Source model. The local runtime holds one | ||
| /// model at a time, so the fallback cannot use a different one without swapping it in. | ||
| private var fallbackModelName: String { | ||
| runtimeModel.selectedModelFilename.map { ($0 as NSString).deletingPathExtension } ?? "your Open Source model" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Apple Intelligence rejects a language and fallback is off, this return skips the router's quality accounting. The coordinator also skips counting it because the result has a suppression reason. As a result, these requests are missing from both the generated count and the
appleLanguageUnsupportedsuppression count.