gemma.cpp icon indicating copy to clipboard operation
gemma.cpp copied to clipboard

Wrong keyboard mapping in command line

Open kaieberl opened this issue 11 months ago • 2 comments

System: macOS 14.3.1 on Macbook Air M2 Terminal: reproduced in iTerm as well as native Terminal Command:

./gemma \
--tokenizer tokenizer.spm \
--compressed_weights 2b-it-sfp.sbs \
--model 2b-it

When I try to navigate in the chat input using the arrow keys, it doesn't work and I get codes like ^[[D for the left arrow key. Also, I cannot add new lines in my prompt using Shift+Enter, and when I insert text from the clipboard containing new lines, I get multiple invocations.

kaieberl avatar Feb 27 '24 08:02 kaieberl

Just saw this, which resolves the second part: https://github.com/google/gemma.cpp/pull/33

kaieberl avatar Feb 27 '24 08:02 kaieberl

Hi, we are just using std::getline for input. Does anyone have experience with handling array keys on OSX?

jan-wassenberg avatar Feb 27 '24 09:02 jan-wassenberg

I've looked into this a bit more and there is a workaround, installing rlwrap: https://stackoverflow.com/questions/21384040/why-does-the-terminal-show-a-b-c-d-when-pressing-the-arrow-k/76418140#76418140

It seems that's about all we can do when using standard C or C++ libraries without other dependencies such as readline/ncurses, which we'd like to avoid. Closing :)

jan-wassenberg avatar May 07 '24 09:05 jan-wassenberg