Skip to content

Commit 771c80b

Browse files
committed
Added stepper for editing MaxToken
1 parent 0892351 commit 771c80b

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

Copilot for Xcode/OpenAIView.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)