MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / insert

Method insert

src/common/AutoModel/modeling_llama3.cpp:53–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53bool Llama3::insert(chat_meta_info_t& meta_info, lm_uniform_input_t& input, std::function<bool()> is_cancelled) {
54 // preprocess
55 this->profiler_list[TKOEN_ENCODE_TIME].start();
56 std::string templated_text;
57 if (input.messages.empty() && input.prompt.empty()) {
58 header_print("WARNING", "No messages or prompt provided");
59 return false;
60 }
61 if (!input.messages.empty()) { // already a formated messages, usually from REST API
62 templated_text = this->apply_chat_template(input.messages);
63 }
64 else if (!input.prompt.empty()) { // a pure text, usually from the cli
65 nlohmann::ordered_json messages;
66
67 messages.push_back({ {"role", "user"}, {"content", input.prompt} });
68 templated_text = this->apply_chat_template(messages);
69 }
70
71 std::vector<int> tokens = this->tokenizer->encode(templated_text);
72
73 this->profiler_list[TKOEN_ENCODE_TIME].stop(tokens.size());
74 // hardware
75
76 return this->_shared_insert(meta_info, tokens, is_cancelled);
77}
78
79
80std::string Llama3::generate(chat_meta_info_t& meta_info, int length_limit, std::ostream& os, std::function<bool()> is_cancelled) {

Callers 1

generate_with_promptMethod · 0.95

Calls 11

apply_chat_templateMethod · 0.95
push_backMethod · 0.80
encodeMethod · 0.80
_shared_insertMethod · 0.80
eraseMethod · 0.80
startMethod · 0.45
emptyMethod · 0.45
stopMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected