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

Method insert

src/common/AutoModel/modeling_lfm2.cpp:58–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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

Tested by

no test coverage detected