Skip to content

Commit 5de6d26

Browse files
committed
MaxToken changed to editable with stepper and text field
1 parent 42b850b commit 5de6d26

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

Copilot for Xcode/OpenAIView.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,29 @@ struct OpenAIView: View {
7070

7171
HStack {
7272
if let model = ChatGPTModel(rawValue: settings.chatGPTModel) {
73+
let binding = Binding(
74+
get: { String(settings.chatGPTMaxToken) },
75+
set: {
76+
if let selectionMaxToken = Int($0) {
77+
settings.chatGPTMaxToken = model.maxToken < selectionMaxToken ? model.maxToken : selectionMaxToken
78+
} else {
79+
settings.chatGPTMaxToken = 0
80+
}
81+
}
82+
)
7383
Stepper(
7484
value: $settings.chatGPTMaxToken,
7585
in: 0...model.maxToken,
7686
step: 1
7787
) {
7888
Text("Max Token")
7989
}
90+
TextField(text: binding) {
91+
EmptyView()
92+
}
93+
.labelsHidden()
94+
.textFieldStyle(.roundedBorder)
8095
}
81-
Text(settings.chatGPTMaxToken.description)
82-
.font(.body)
83-
.monospacedDigit()
84-
.padding(.vertical, 2)
85-
.padding(.horizontal, 6)
86-
.background(
87-
RoundedRectangle(cornerRadius: 4, style: .continuous)
88-
.fill(Color.white.opacity(0.2))
89-
)
9096
}
9197
}
9298
}

0 commit comments

Comments
 (0)