ChatON: Use the constants defined for the keys

This commit is contained in:
HanishKVC 2024-04-23 09:26:46 +05:30
parent efb758ba7d
commit 42f6b45547
2 changed files with 6 additions and 5 deletions

View file

@ -69,6 +69,7 @@ const auto K_BEGIN = "begin";
const auto K_END = "end"; const auto K_END = "end";
const auto K_GLOBAL = "global"; const auto K_GLOBAL = "global";
const auto K_SYSTEMUSER_1ST_USER_HAS_PREFIX = "systemuser-1st-user-has-prefix"; const auto K_SYSTEMUSER_1ST_USER_HAS_PREFIX = "systemuser-1st-user-has-prefix";
const auto K_REVERSE_PROMPT = "reverse-prompt";
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -264,7 +264,7 @@ int main(int argc, char ** argv) {
params.prompt = "<|im_start|>system\n" + params.prompt + "<|im_end|>"; params.prompt = "<|im_start|>system\n" + params.prompt + "<|im_end|>";
} }
if (params.chaton) { if (params.chaton) {
params.prompt = chaton_tmpl_apply_single(params.chaton_template_id, "system", params.prompt); params.prompt = chaton_tmpl_apply_single(params.chaton_template_id, K_SYSTEM, params.prompt);
} }
embd_inp = ::llama_tokenize(ctx, params.prompt, true, true); embd_inp = ::llama_tokenize(ctx, params.prompt, true, true);
} else { } else {
@ -375,13 +375,13 @@ int main(int argc, char ** argv) {
} }
// chaton mode // chaton mode
const auto chaton_assitant_prefix = ::llama_tokenize(ctx, chaton_tmpl_role_kv(params.chaton_template_id, "assistant", "prefix"), false, true); const auto chaton_assitant_prefix = ::llama_tokenize(ctx, chaton_tmpl_role_kv(params.chaton_template_id, K_ASSISTANT, K_PREFIX), false, true);
if (params.chaton) { if (params.chaton) {
params.interactive = true; // may remove later, by requiring user to explicitly request interactive mode params.interactive = true; // may remove later, by requiring user to explicitly request interactive mode
params.interactive_first = true; params.interactive_first = true;
params.input_prefix = chaton_tmpl_role_kv(params.chaton_template_id, "user", "prefix"); params.input_prefix = chaton_tmpl_role_kv(params.chaton_template_id, K_USER, K_PREFIX);
params.input_suffix = chaton_tmpl_role_kv(params.chaton_template_id, "user", "suffix"); params.input_suffix = chaton_tmpl_role_kv(params.chaton_template_id, K_USER, K_SUFFIX);
params.antiprompt.emplace_back(chaton_tmpl_kv(params.chaton_template_id, "reverse-prompt")); params.antiprompt.emplace_back(chaton_tmpl_kv(params.chaton_template_id, K_REVERSE_PROMPT));
} }
// enable interactive mode if interactive start is specified // enable interactive mode if interactive start is specified