Skip to content

Commit e1ec489

Browse files
committed
Use existing session behavior when in instruct or interact first mode
1 parent 2d79928 commit e1ec489

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/main/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int main(int argc, char ** argv) {
166166
// tokenize the prompt
167167
std::vector<llama_token> embd_inp;
168168

169-
if (!params.prompt.empty() || session_tokens.empty()) {
169+
if (params.interactive_first || params.instruct || !params.prompt.empty() || session_tokens.empty()) {
170170
// Add a space in front of the first character to match OG llama tokenizer behavior
171171
params.prompt.insert(0, 1, ' ');
172172

@@ -191,7 +191,9 @@ int main(int argc, char ** argv) {
191191
}
192192
n_matching_session_tokens++;
193193
}
194-
if (n_matching_session_tokens >= embd_inp.size()) {
194+
if (params.prompt.empty() && n_matching_session_tokens == embd_inp.size()) {
195+
fprintf(stderr, "%s: using full prompt from session file\n", __func__);
196+
} else if (n_matching_session_tokens >= embd_inp.size()) {
195197
fprintf(stderr, "%s: session file has exact match for prompt!\n", __func__);
196198
} else if (n_matching_session_tokens < (embd_inp.size() / 2)) {
197199
fprintf(stderr, "%s: warning: session file has low similarity to prompt (%zu / %zu tokens); will mostly be reevaluated\n",

0 commit comments

Comments
 (0)