summaryrefslogtreecommitdiff
path: root/examples/common.cpp
diff options
context:
space:
mode:
authorEvan Jones <evan.q.jones@gmail.com>2023-05-10 11:37:14 -0400
committerGitHub <noreply@github.com>2023-05-10 11:37:14 -0400
commitcf348a60e0af3905acd1d297cb064b918265b7ac (patch)
treeb5480b47918c0d1f386db71a195028fd5ca095be /examples/common.cpp
parente6a46b0ed1884c77267dc70693183e3b7164e0e0 (diff)
main : add option to save full output to session (#1338)
* main : add option to save full output to session * split behavior into --session and --prompt-cache * restore original implementation with new names * PR comments * move the check for incompatible parameters to gpt_params_parse * Fix whitespace Co-authored-by: DannyDaemonic <DannyDaemonic@gmail.com> --------- Co-authored-by: DannyDaemonic <DannyDaemonic@gmail.com>
Diffstat (limited to 'examples/common.cpp')
-rw-r--r--examples/common.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/common.cpp b/examples/common.cpp
index 7aa77587..f3085b08 100644
--- a/examples/common.cpp
+++ b/examples/common.cpp
@@ -118,12 +118,14 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
params.prompt = argv[i];
} else if (arg == "-e") {
escape_prompt = true;
- } else if (arg == "--session") {
+ } else if (arg == "--prompt-cache") {
if (++i >= argc) {
invalid_param = true;
break;
}
- params.path_session = argv[i];
+ params.path_prompt_cache = argv[i];
+ } else if (arg == "--prompt-cache-all") {
+ params.prompt_cache_all = true;
} else if (arg == "-f" || arg == "--file") {
if (++i >= argc) {
invalid_param = true;
@@ -342,6 +344,13 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
gpt_print_usage(argc, argv, default_params);
exit(1);
}
+ if (params.prompt_cache_all &&
+ (params.interactive || params.interactive_first ||
+ params.instruct || params.antiprompt.size())) {
+ fprintf(stderr, "error: --prompt-cache-all not supported in interactive mode yet\n");
+ gpt_print_usage(argc, argv, default_params);
+ exit(1);
+ }
if (escape_prompt) {
process_escapes(params.prompt);
}
@@ -367,7 +376,9 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
fprintf(stderr, " -p PROMPT, --prompt PROMPT\n");
fprintf(stderr, " prompt to start generation with (default: empty)\n");
fprintf(stderr, " -e process prompt escapes sequences (\\n, \\r, \\t, \\', \\\", \\\\)\n");
- fprintf(stderr, " --session FNAME file to cache model state in (may be large!) (default: none)\n");
+ fprintf(stderr, " --prompt-cache FNAME file to cache prompt state for faster startup (default: none)\n");
+ fprintf(stderr, " --prompt-cache-all if specified, saves user input and generations to cache as well.\n");
+ fprintf(stderr, " not supported with --interactive or other interactive options\n");
fprintf(stderr, " --random-prompt start with a randomized prompt.\n");
fprintf(stderr, " --in-prefix STRING string to prefix user inputs with (default: empty)\n");
fprintf(stderr, " --in-suffix STRING string to suffix after user inputs with (default: empty)\n");