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

Method insert

src/common/AutoModel/modeling_phi4.cpp:90–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool Phi4::insert(chat_meta_info_t& meta_info, lm_uniform_input_t& input, std::function<bool()> is_cancelled) {
91 // preprocess
92 this->profiler_list[TKOEN_ENCODE_TIME].start();
93 std::string templated_text;
94 if (input.messages.empty() && input.prompt.empty()) {
95 header_print("WARNING", "No messages or prompt provided");
96 return false;
97 }
98 if (!input.messages.empty()) { // already a formated messages, usually from REST API
99 templated_text = this->apply_chat_template(input.messages);
100 }
101 else if (!input.prompt.empty()) { // a pure text, usually from the cli
102 nlohmann::ordered_json messages;
103
104 messages.push_back({ {"role", "user"}, {"content", input.prompt} });
105 templated_text = this->apply_chat_template(messages);
106 }
107
108 std::vector<int> tokens = this->tokenizer->encode(templated_text);
109 this->profiler_list[TKOEN_ENCODE_TIME].stop(tokens.size());
110 // hardware
111
112 return this->_shared_insert(meta_info, tokens, is_cancelled);
113}
114
115
116std::string Phi4::generate(chat_meta_info_t& meta_info, int length_limit, std::ostream& os, std::function<bool()> is_cancelled) {

Callers 4

generate_with_promptMethod · 0.95
decode_audioMethod · 0.45
generateMethod · 0.45
_preprocess_audioMethod · 0.45

Calls 8

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

Tested by

no test coverage detected