Skip to content

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

Closed
wants to merge 14 commits into from

Conversation

wbpxre150
Copy link
Contributor

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.

@ggerganov
Copy link
Member

Factor out this in a separate helper function and maybe put it behind a cmd arg flag

@wbpxre150
Copy link
Contributor Author

@ggerganov I refactored to a function.

@@ -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) {
Copy link
Collaborator

@j-f1 j-f1 Apr 13, 2023

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:

Suggested change
if (strncmp(buffer.c_str(), "???", 3) == 0 && buffer.length() > 3) {
if (buffer.length() <= 3 || strncmp(buffer.c_str(), "???", 3) != 0) return;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done mate.

@wbpxre150
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants