Spaces:
Sleeping
Sleeping
RhinoDevel
commited on
talk-llama : add optional CLI arg to set the bot name (#1764)
Browse files
examples/talk-llama/talk-llama.cpp
CHANGED
|
@@ -67,6 +67,7 @@ struct whisper_params {
|
|
| 67 |
bool use_gpu = true;
|
| 68 |
|
| 69 |
std::string person = "Georgi";
|
|
|
|
| 70 |
std::string language = "en";
|
| 71 |
std::string model_wsp = "models/ggml-base.en.bin";
|
| 72 |
std::string model_llama = "models/ggml-llama-7B.bin";
|
|
@@ -101,7 +102,8 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
|
| 101 |
else if (arg == "-vp" || arg == "--verbose-prompt") { params.verbose_prompt = true; }
|
| 102 |
else if (arg == "-ng" || arg == "--no-gpu") { params.use_gpu = false; }
|
| 103 |
else if (arg == "-p" || arg == "--person") { params.person = argv[++i]; }
|
| 104 |
-
else if (arg == "--
|
|
|
|
| 105 |
else if (arg == "-l" || arg == "--language") { params.language = argv[++i]; }
|
| 106 |
else if (arg == "-mw" || arg == "--model-whisper") { params.model_wsp = argv[++i]; }
|
| 107 |
else if (arg == "-ml" || arg == "--model-llama") { params.model_llama = argv[++i]; }
|
|
@@ -146,6 +148,7 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
|
|
| 146 |
fprintf(stderr, " -vp, --verbose-prompt [%-7s] print prompt at start\n", params.verbose_prompt ? "true" : "false");
|
| 147 |
fprintf(stderr, " -ng, --no-gpu [%-7s] disable GPU\n", params.use_gpu ? "false" : "true");
|
| 148 |
fprintf(stderr, " -p NAME, --person NAME [%-7s] person name (for prompt selection)\n", params.person.c_str());
|
|
|
|
| 149 |
fprintf(stderr, " -l LANG, --language LANG [%-7s] spoken language\n", params.language.c_str());
|
| 150 |
fprintf(stderr, " -mw FILE, --model-whisper [%-7s] whisper model file\n", params.model_wsp.c_str());
|
| 151 |
fprintf(stderr, " -ml FILE, --model-llama [%-7s] llama model file\n", params.model_llama.c_str());
|
|
@@ -323,12 +326,11 @@ int main(int argc, char ** argv) {
|
|
| 323 |
float prob0 = 0.0f;
|
| 324 |
|
| 325 |
const std::string chat_symb = ":";
|
| 326 |
-
const std::string bot_name = "LLaMA";
|
| 327 |
|
| 328 |
std::vector<float> pcmf32_cur;
|
| 329 |
std::vector<float> pcmf32_prompt;
|
| 330 |
|
| 331 |
-
const std::string prompt_whisper = ::replace(k_prompt_whisper, "{1}", bot_name);
|
| 332 |
|
| 333 |
// construct the initial prompt for LLaMA inference
|
| 334 |
std::string prompt_llama = params.prompt.empty() ? k_prompt_llama : params.prompt;
|
|
@@ -337,7 +339,7 @@ int main(int argc, char ** argv) {
|
|
| 337 |
prompt_llama.insert(0, 1, ' ');
|
| 338 |
|
| 339 |
prompt_llama = ::replace(prompt_llama, "{0}", params.person);
|
| 340 |
-
prompt_llama = ::replace(prompt_llama, "{1}", bot_name);
|
| 341 |
|
| 342 |
{
|
| 343 |
// get time string
|
|
@@ -524,7 +526,7 @@ int main(int argc, char ** argv) {
|
|
| 524 |
force_speak = false;
|
| 525 |
|
| 526 |
text_heard.insert(0, 1, ' ');
|
| 527 |
-
text_heard += "\n" + bot_name + chat_symb;
|
| 528 |
fprintf(stdout, "%s%s%s", "\033[1m", text_heard.c_str(), "\033[0m");
|
| 529 |
fflush(stdout);
|
| 530 |
|
|
|
|
| 67 |
bool use_gpu = true;
|
| 68 |
|
| 69 |
std::string person = "Georgi";
|
| 70 |
+
std::string bot_name = "LLaMA";
|
| 71 |
std::string language = "en";
|
| 72 |
std::string model_wsp = "models/ggml-base.en.bin";
|
| 73 |
std::string model_llama = "models/ggml-llama-7B.bin";
|
|
|
|
| 102 |
else if (arg == "-vp" || arg == "--verbose-prompt") { params.verbose_prompt = true; }
|
| 103 |
else if (arg == "-ng" || arg == "--no-gpu") { params.use_gpu = false; }
|
| 104 |
else if (arg == "-p" || arg == "--person") { params.person = argv[++i]; }
|
| 105 |
+
else if (arg == "-bn" || arg == "--bot-name") { params.bot_name = argv[++i]; }
|
| 106 |
+
else if (arg == "--session") { params.path_session = argv[++i]; }
|
| 107 |
else if (arg == "-l" || arg == "--language") { params.language = argv[++i]; }
|
| 108 |
else if (arg == "-mw" || arg == "--model-whisper") { params.model_wsp = argv[++i]; }
|
| 109 |
else if (arg == "-ml" || arg == "--model-llama") { params.model_llama = argv[++i]; }
|
|
|
|
| 148 |
fprintf(stderr, " -vp, --verbose-prompt [%-7s] print prompt at start\n", params.verbose_prompt ? "true" : "false");
|
| 149 |
fprintf(stderr, " -ng, --no-gpu [%-7s] disable GPU\n", params.use_gpu ? "false" : "true");
|
| 150 |
fprintf(stderr, " -p NAME, --person NAME [%-7s] person name (for prompt selection)\n", params.person.c_str());
|
| 151 |
+
fprintf(stderr, " -bn NAME, --bot-name NAME [%-7s] bot name (to display)\n", params.bot_name.c_str());
|
| 152 |
fprintf(stderr, " -l LANG, --language LANG [%-7s] spoken language\n", params.language.c_str());
|
| 153 |
fprintf(stderr, " -mw FILE, --model-whisper [%-7s] whisper model file\n", params.model_wsp.c_str());
|
| 154 |
fprintf(stderr, " -ml FILE, --model-llama [%-7s] llama model file\n", params.model_llama.c_str());
|
|
|
|
| 326 |
float prob0 = 0.0f;
|
| 327 |
|
| 328 |
const std::string chat_symb = ":";
|
|
|
|
| 329 |
|
| 330 |
std::vector<float> pcmf32_cur;
|
| 331 |
std::vector<float> pcmf32_prompt;
|
| 332 |
|
| 333 |
+
const std::string prompt_whisper = ::replace(k_prompt_whisper, "{1}", params.bot_name);
|
| 334 |
|
| 335 |
// construct the initial prompt for LLaMA inference
|
| 336 |
std::string prompt_llama = params.prompt.empty() ? k_prompt_llama : params.prompt;
|
|
|
|
| 339 |
prompt_llama.insert(0, 1, ' ');
|
| 340 |
|
| 341 |
prompt_llama = ::replace(prompt_llama, "{0}", params.person);
|
| 342 |
+
prompt_llama = ::replace(prompt_llama, "{1}", params.bot_name);
|
| 343 |
|
| 344 |
{
|
| 345 |
// get time string
|
|
|
|
| 526 |
force_speak = false;
|
| 527 |
|
| 528 |
text_heard.insert(0, 1, ' ');
|
| 529 |
+
text_heard += "\n" + params.bot_name + chat_symb;
|
| 530 |
fprintf(stdout, "%s%s%s", "\033[1m", text_heard.c_str(), "\033[0m");
|
| 531 |
fflush(stdout);
|
| 532 |
|