diff --git a/common/chaton.hpp b/common/chaton.hpp index cd3679409a..a9af7a565e 100644 --- a/common/chaton.hpp +++ b/common/chaton.hpp @@ -19,4 +19,34 @@ * */ +#include +#include +#include +#include +#include "log.h" + +using json = nlohmann::json; + +json conMeta; + +inline bool chaton_meta_load(std::string &fname) { + std::ifstream f(fname); + conMeta = json::parse(f); + return true; +} + +inline bool chaton_meta_ok() { + if (conMeta == nullptr) { + return false; + } + return true; +} + +inline void chaton_meta_dump() { + if (!chaton_meta_ok()) { + LOG_TEELN("ERRR:%s:ChatOn Meta: Not loaded yet...", __func__); + return; + } + LOG_TEELN("\n\nINFO:%s:ChatOn Meta\n%s", __func__, conMeta.dump(4).c_str()); +} diff --git a/examples/chaton_meta.json b/examples/chaton_meta.json new file mode 100644 index 0000000000..77e4595d6c --- /dev/null +++ b/examples/chaton_meta.json @@ -0,0 +1,42 @@ + +{ + "llama2": { + "global": { + "prefix": "[INST] ", + "suffix": " [/INST]", + }, + "system": { + "prefix": " <>\n", + "suffix": "\n<>\n\n", + }, + "user": { + "prefix": "", + "suffix": "", + }, + "assistant": { + "prefix": "", + "suffix": "", + }, + "reverse-prompt": "", + }, + "llama3": { + "global": { + "prefix": "", + "suffix": "", + }, + "system": { + "prefix": "<|start_header_id|>system<|end_header_id|>\n\n", + "suffix": "<|eot_id|>\n\n", + }, + "user": { + "prefix": "<|start_header_id|>user<|end_header_id|>\n\n", + "suffix": "<|eot_id|>\n\n", + }, + "assistant": { + "prefix": "<|start_header_id|>assistant<|end_header_id|>\n\n", + "suffix": "", + }, + "reverse-prompt": "<|eot_id|>", + }, +} + diff --git a/examples/main/main.cpp b/examples/main/main.cpp index eabbc2db38..3432cb9f1f 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include "chaton.hpp" #include "console.h" #include "llama.h" @@ -141,6 +142,11 @@ int main(int argc, char ** argv) { console::init(params.simple_io, params.use_color); atexit([]() { console::cleanup(); }); + if (params.chaton) { + chaton_meta_load(params.chaton_json); + chaton_meta_dump(); + } + if (params.logits_all) { printf("\n************\n"); printf("%s: please use the 'perplexity' tool for perplexity calculations\n", __func__);