-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Add commands to interactive mode. #924
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
Conversation
… for everything in params during rumtime.
Factor out this in a separate helper function and maybe put it behind a cmd arg flag |
@ggerganov I refactored to a function. |
examples/main/main.cpp
Outdated
@@ -47,6 +47,53 @@ void sigint_handler(int signo) { | |||
} | |||
#endif | |||
|
|||
void command(std::string buffer, gpt_params params, const int n_ctx ) { | |||
// check buffer's first 3 chars equal '???' to enter command mode. | |||
if (strncmp(buffer.c_str(), "???", 3) == 0 && buffer.length() > 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please negate this condition and do an easy return so the function body doesn't have to be indented again:
if (strncmp(buffer.c_str(), "???", 3) == 0 && buffer.length() > 3) { | |
if (buffer.length() <= 3 || strncmp(buffer.c_str(), "???", 3) != 0) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done mate.
It would print random gibberish after entering a command. This is now fixed. I also cleaned up the code and changed a few prints to make more sense. This should be ready for review now. |
pull down new code
merge command line code
merge new code
I thought of this while working on something else.
Its super useful. You can change startup params on the fly using the command:
??? CMD param
where CMD is a command line argument, and params is the number following each argument.
In my testing so far changing values has changed the models output.
This should enable users to test different params in run time against a single prompt. We can now fine tune the params using a single prompt. Simply copy and paste the prompt over and over after changing the param and compare the output.