AugustDev / enchanted

Enchanted is iOS and macOS app for chatting with private self hosted language models such as Llama2, Mistral or Vicuna using Ollama.
Apache License 2.0
3.05k stars 183 forks source link

Feature suggestion: Submit input when "Return" key is pressed on physical keyboard #31

Closed maxiR8 closed 6 months ago

maxiR8 commented 6 months ago
AugustDev commented 6 months ago

Hi @maxiR8 thanks for the issue. Return (Enter) works on my mac, I will investigate to make sure it works on iPad's magic keyboard as well!

maxiR8 commented 6 months ago

I added onSubmit method to the TextField in ChatView.swift that fixed it in the emulator. However not sure if this is best way. My Swift knowledge is not great :(

TextField("Message", text: $message, axis: .vertical)
                    .focused($isFocusedInput)
                    .frame(minHeight: 40)
                    .font(.system(size: 14))
                    .onSubmit {
                        Task {
                            Haptics.shared.play(.medium)

                            guard let selectedModel = selectedModel else { return }

                            await onSendMessageTap(
                                message,
                                selectedModel,
                                selectedImage,
                                editMessage?.id.uuidString
                            )
                            withAnimation {
                                isFocusedInput = false
                                editMessage = nil
                                selectedImage = nil
                                message = ""
                            }
                        }
                    }
vishv96 commented 6 months ago

@maxiR8 I think since we have multiline support on TextField the onSubmitwill not work. when the user taps on Return Key it will move to the next line, However it is working on Mac

maxiR8 commented 6 months ago

Strangely it wasn't working for me on the Mac either in the emulator (believe was iPhone 15) when using the keyboard. Using a wireless apple keyboard, but doubt this is related. Will spin up the project tomorrow and see if I can provide anymore input on this.

AugustDev commented 6 months ago

I think @maxiR8 your approach is right. I have implemented this and will make a release today.

The expected experience is (as for ChatGPT, Gemini)

Mac Return - Submits the prompt Shift + Return - New line

Mobile Return (virtual keyboard button) - New line Return (physical keyboard) - Submits the prompt

maxiR8 commented 6 months ago

Sweet :) Thank you. And great job on the app đź‘Ť Take care.

floodedcodeboy commented 5 months ago

Nice fix! As far as my experience goes when using the chat from the app to my locally hosted ollama when typing the app sends HEAD requests to the ollama server - my server doesn’t like that and stops responding and I have to restart the ollama service .

So this is a very welcome fix!