Skip to content

Commit 8894034

Browse files
committed
run: allow to customize prompt by env var LLAMA_PROMPT_PREFIX
Signed-off-by: Florent Benoit <[email protected]>
1 parent f777a73 commit 8894034

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/run/run.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,16 @@ static int generate(LlamaData & llama_data, const std::string & prompt, std::str
975975
printf(LOG_COL_DEFAULT);
976976
return 0;
977977
}
978+
static const char *default_prompt_prefix = "> ";
979+
static const char *prompt_prefix = nullptr;
980+
981+
static void initialize_prompt_prefix() {
982+
const char *llama_prompt_prefix = std::getenv("LLAMA_PROMPT_PREFIX");
983+
prompt_prefix = (llama_prompt_prefix != nullptr) ? llama_prompt_prefix : default_prompt_prefix;
984+
}
985+
978986

979987
static int read_user_input(std::string & user_input) {
980-
static const char * prompt_prefix = "> ";
981988
#ifdef WIN32
982989
printf("\r" LOG_CLR_TO_EOL LOG_COL_DEFAULT "%s", prompt_prefix);
983990

@@ -1185,6 +1192,7 @@ static void ctrl_c_handling() {
11851192

11861193
int main(int argc, const char ** argv) {
11871194
ctrl_c_handling();
1195+
initialize_prompt_prefix();
11881196
Opt opt;
11891197
const int ret = opt.init(argc, argv);
11901198
if (ret == 2) {

0 commit comments

Comments
 (0)