File tree Expand file tree Collapse file tree 4 files changed +40
-1
lines changed
Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ struct SettingsView: View {
2222 var disableSuggestionFeatureGlobally : Bool
2323 @AppStorage ( \. suggestionFeatureEnabledProjectList)
2424 var suggestionFeatureEnabledProjectList : [ String ]
25+ @AppStorage ( \. promptToCodeFeatureProvider)
26+ var promptToCodeFeatureProvider : PromptToCodeFeatureProvider
2527 init ( ) { }
2628 }
2729
@@ -134,6 +136,19 @@ struct SettingsView: View {
134136 Text ( " Use accessibility API to accept suggestion in widget " )
135137 }
136138 . toggleStyle ( . switch)
139+
140+ Picker ( selection: $settings. promptToCodeFeatureProvider) {
141+ ForEach ( PromptToCodeFeatureProvider . allCases, id: \. rawValue) {
142+ switch $0 {
143+ case . openAI:
144+ Text ( " OpenAI " ) . tag ( $0)
145+ case . githubCopilot:
146+ Text ( " GitHub Copilot (Less Accurate) " ) . tag ( $0)
147+ }
148+ }
149+ } label: {
150+ Text ( " Prompt to code with " )
151+ }
137152 }
138153 } . buttonStyle ( . copilot)
139154 }
Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ public struct UserDefaultPreferenceKeys {
151151 public var suggestionFeatureEnabledProjectList : SuggestionFeatureEnabledProjectList {
152152 . init( )
153153 }
154+
155+ public struct PromptToCodeFeatureProviderKey : UserDefaultPreferenceKey {
156+ public let defaultValue : PromptToCodeFeatureProvider = . openAI
157+ public let key = " PromptToCodeFeatureProvider "
158+ }
159+
160+ public var promptToCodeFeatureProvider : PromptToCodeFeatureProviderKey {
161+ . init( )
162+ }
154163
155164 public var disableLazyVStack : FeatureFlags . DisableLazyVStack { . init( ) }
156165 public var preCacheOnFileOpen : FeatureFlags . PreCacheOnFileOpen { . init( ) }
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ public enum PromptToCodeFeatureProvider : Int , CaseIterable {
4+ case openAI
5+ case githubCopilot
6+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,16 @@ import OpenAIService
66public final class PromptToCodeService : ObservableObject {
77 var designatedPromptToCodeAPI : PromptToCodeAPI ?
88 var promptToCodeAPI : PromptToCodeAPI {
9- designatedPromptToCodeAPI ?? OpenAIPromptToCodeAPI ( )
9+ if let designatedPromptToCodeAPI {
10+ return designatedPromptToCodeAPI
11+ }
12+
13+ switch UserDefaults . shared. value ( for: \. promptToCodeFeatureProvider) {
14+ case . openAI:
15+ return OpenAIPromptToCodeAPI ( )
16+ case . githubCopilot:
17+ return CopilotPromptToCodeAPI ( )
18+ }
1019 }
1120
1221 var runningAPI : PromptToCodeAPI ?
You can’t perform that action at this time.
0 commit comments