File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,9 +55,9 @@ struct OpenAIView: View {
5555 } . buttonStyle ( . plain)
5656 }
5757 . onChange ( of: settings. chatGPTModel) { newValue in
58- guard let model = ChatGPTModel ( rawValue: newValue) else { return }
59- settings. chatGPTEndpoint = model. endpoint
60- settings . chatGPTMaxToken = model . maxToken
58+ if let model = ChatGPTModel ( rawValue: newValue) {
59+ settings. chatGPTEndpoint = model. endpoint
60+ }
6161 }
6262
6363 Picker ( selection: $settings. chatGPTLanguage) {
@@ -67,6 +67,23 @@ struct OpenAIView: View {
6767 } label: {
6868 Text ( " Reply in Language " )
6969 } . pickerStyle ( . menu)
70+
71+ HStack {
72+ if let model = ChatGPTModel ( rawValue: settings. chatGPTModel) {
73+ Stepper ( value: $settings. chatGPTMaxToken, in: 0 ... model. maxToken, step: 1 ) {
74+ Text ( " Max Token " )
75+ }
76+ }
77+ Text ( settings. chatGPTMaxToken. description)
78+ . font ( . body)
79+ . monospacedDigit ( )
80+ . padding ( . vertical, 2 )
81+ . padding ( . horizontal, 6 )
82+ . background (
83+ RoundedRectangle ( cornerRadius: 4 , style: . continuous)
84+ . fill ( Color . white. opacity ( 0.2 ) )
85+ )
86+ }
7087 }
7188 }
7289 }
You can’t perform that action at this time.
0 commit comments