Skip to content

Commit d8c908b

Browse files
committed
Update language settings
1 parent b8b2551 commit d8c908b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

Copilot for Xcode/OpenAIView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct OpenAIView: View {
7070
Text("Reply in Language")
7171
TextField(
7272
text: $settings.chatGPTLanguage,
73-
prompt: Text("English")
73+
prompt: Text("e.g. English. Leave it blank to let the bot decide.")
7474
) {
7575
EmptyView()
7676
}.textFieldStyle(.copilot)

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,13 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
194194
let fileURL = try await Environment.fetchCurrentFileURL()
195195
let endpoint = UserDefaults.shared.value(for: \.chatGPTEndpoint)
196196
let model = UserDefaults.shared.value(for: \.chatGPTModel)
197-
var language = UserDefaults.shared.value(for: \.chatGPTLanguage)
198-
if language.isEmpty { language = "English" }
197+
let language = UserDefaults.shared.value(for: \.chatGPTLanguage)
199198
guard let selection = editor.selections.last else { return }
200199

201200
let service = ChatGPTService(
202201
systemPrompt: """
203202
You are a code explanation engine, you can only explain the code concisely, do not interpret or translate it
204-
Reply in \(language)
203+
Reply in \(language.isEmpty ? "" : "in \(language)")
205204
""",
206205
apiKey: UserDefaults.shared.value(for: \.openAIAPIKey),
207206
endpoint: endpoint.isEmpty ? nil : endpoint,
@@ -239,8 +238,7 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
239238
let fileURL = try await Environment.fetchCurrentFileURL()
240239
let endpoint = UserDefaults.shared.value(for: \.chatGPTEndpoint)
241240
let model = UserDefaults.shared.value(for: \.chatGPTModel)
242-
var language = UserDefaults.shared.value(for: \.chatGPTLanguage)
243-
if language.isEmpty { language = "English" }
241+
let language = UserDefaults.shared.value(for: \.chatGPTLanguage)
244242

245243
let code = {
246244
guard let selection = editor.selections.last,
@@ -251,12 +249,14 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
251249
let prompt = {
252250
if code.isEmpty {
253251
return """
254-
You are a senior programmer, you will answer my questions concisely in \(language)
252+
You are a senior programmer, you will answer my questions concisely \(
253+
language.isEmpty ? "" : "in \(language)"
254+
)
255255
"""
256256
}
257257
return """
258258
You are a senior programmer, you will answer my questions concisely in \(
259-
language
259+
language.isEmpty ? "" : "in \(language)"
260260
) about the code
261261
```
262262
\(removeContinuousSpaces(from: code))

0 commit comments

Comments
 (0)