import SwiftUI struct PromptCustomizationView: View { @ObservedObject var whisperPrompt: WhisperPrompt @AppStorage("SelectedLanguage") private var selectedLanguage: String = "en" @State private var customPrompt: String = "" @State private var isEditing: Bool = false var body: some View { VStack(alignment: .leading, spacing: 12) { HStack { Text("Output Format") .font(.headline) InfoTip( title: "Output Format Guide", message: "Unlike GPT, Voice Models(whisper) follows the style of your prompt rather than instructions. Use examples of your desired output format instead of commands.", learnMoreURL: "https://cookbook.openai.com/examples/whisper_prompting_guide#comparison-with-gpt-prompting" ) Spacer() Button(action: { if isEditing { // Save changes whisperPrompt.setCustomPrompt(customPrompt, for: selectedLanguage) isEditing = false } else { // Enter edit mode customPrompt = whisperPrompt.getLanguagePrompt(for: selectedLanguage) isEditing = true } }) { Text(isEditing ? "Save" : "Edit") .font(.caption) } } if isEditing { TextEditor(text: $customPrompt) .font(.system(size: 12)) .padding(8) .frame(height: 80) .overlay( RoundedRectangle(cornerRadius: 6) .stroke(Color.secondary.opacity(0.2), lineWidth: 1) ) } else { Text(whisperPrompt.getLanguagePrompt(for: selectedLanguage)) .font(.system(size: 12)) .foregroundColor(.secondary) .padding(8) .frame(maxWidth: .infinity, alignment: .leading) .background( RoundedRectangle(cornerRadius: 6) .fill(Color(.windowBackgroundColor).opacity(0.4)) ) .overlay( RoundedRectangle(cornerRadius: 6) .stroke(Color.secondary.opacity(0.2), lineWidth: 1) ) } } .padding() .background(Color(NSColor.controlBackgroundColor)) .cornerRadius(10) // Reset the editor when language changes .onChange(of: selectedLanguage) { _ in if isEditing { customPrompt = whisperPrompt.getLanguagePrompt(for: selectedLanguage) } } } }