-
Notifications
You must be signed in to change notification settings - Fork 11.8k
User should be able to return control without inserting a newline #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, the length check isn't checking for zero-length input: The I did think about this and indeed had exactly the same thought of the current solution not being optimal, especially in the case of instruct mode. However, the problem is that is how terminals are supposed to work and there isn't really a good portable solution to this without going into platform specifics and even requiring extra libraries which seems to be more trouble than worth. As you would need to either read the keyboard input directly without using the For Windows I know how to proceed, the low-level keyboard input can be read using GetAsyncKeyState or the console equivalent _kbhit. That would negate the need for rolling back the terminal. Rolling back could also be done simply by using FillConsoleOutputCharacter and SetConsoleCursorPosition. However, those are for Windows only and I don't know how to implement those in Linux but a quick search shows me that it can be problematic and involves tricks or libraries Using kbhit() and getch() on Linux This code base doesn't implement any non-portable functionality (which is a good thing) so I haven't implemented this for now for Windows. I don't think a good, portable and easily maintainable solution exist for this, so you're kinda stuck with the newlines so far. But if someone else can think of one, that would be great. |
I don't think this is a buffering issue. Users probably don't want the characters to be sent to llama tokenizer as they type them in. @ScarletEmerald Some programming languages (C, Rust) actually use the syntax
to ignore the newline (after the How about
Other option would be to not insert the newline by default, but user would have to type out |
@anzz1 Regarding implementation, I think any of these proposals should be relatively easy to implement in a portable way by modifying the loop at I would not expect there would be any need to work with low-level keyboard input; just modifying @thement Regarding the desired behavior, the user may want to
The current behavior is that My original proposal was to change But, we could also do the other way around, where Those are the only two options I see though which will give the user full control. Any scheme with an option to insert a newline and return control at the same time (case 3) won't be able to cover case 1 and case 2 without having two other input commands. But perhaps a third input command is ok? |
After thinking about this some more, I think the desired behavior should be that if the user sends EOF ( However, all my attempts to implement this have somehow broken the feature of using |
The way canonical mode works is the input line you're typing is buffered by the kernel. If To support this design, you'd have to get rid of |
Aha! I didn't know it behaves like that already. Introducing different behavior on
Oh, I didn't know about that either, thanks! I always wondered why This would be easy to implement on Linux (just one |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
This issue was resolved by #1040 |
This restores the behavior from ggml-org#491. This does not affect Ctrl+D's ability to terminate --multiline-input lines (ggml-org#1040). This also actually implements ggml-org#587: "If the user wants the text to end in a newline, this should be accomplished by explicitly adding a newline by using \ followed by return, then returning control by pressing return again." Fixes ggml-org#12949
This restores the behavior from #491. This does not affect Ctrl+D's ability to terminate --multiline-input lines (#1040). This also actually implements #587: "If the user wants the text to end in a newline, this should be accomplished by explicitly adding a newline by using \ followed by return, then returning control by pressing return again." Fixes #12949
This restores the behavior from ggml-org#491. This does not affect Ctrl+D's ability to terminate --multiline-input lines (ggml-org#1040). This also actually implements ggml-org#587: "If the user wants the text to end in a newline, this should be accomplished by explicitly adding a newline by using \ followed by return, then returning control by pressing return again." Fixes ggml-org#12949
This restores the behavior from ggml-org#491. This does not affect Ctrl+D's ability to terminate --multiline-input lines (ggml-org#1040). This also actually implements ggml-org#587: "If the user wants the text to end in a newline, this should be accomplished by explicitly adding a newline by using \ followed by return, then returning control by pressing return again." Fixes ggml-org#12949
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
In Interactive mode, if the user presses return, a newline is entered into the input. This makes it impossible to return control without inserting a newline.
A special-case exception was recently added for when the user enters only a newline and no other text. #529 #571 This returns control without inserting a newline. However, this only works for the special case of zero length input.
Expected Behavior
The newline entered by the user to return control should never be included in the text. If the user wants the text to end in a newline, this should be accomplished by explicitly adding a newline by using \ followed by return, then returning control by pressing return again.
This is what would be desired in Interactive mode. In Instruct mode, perhaps the desired behavior would the current behavior of including the final newlines.
The text was updated successfully, but these errors were encountered: