MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / tokenize_mixed

Function tokenize_mixed

tools/server/server-common.cpp:641–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641llama_tokens tokenize_mixed(const llama_vocab * vocab, const json & json_prompt, bool add_special, bool parse_special) {
642 // If `add_bos` is true, we only add BOS, when json_prompt is a string,
643 // or the first element of the json_prompt array is a string.
644 llama_tokens prompt_tokens;
645
646 if (json_prompt.is_array()) {
647 bool first = true;
648 for (const auto & p : json_prompt) {
649 if (p.is_string()) {
650 auto s = p.template get<std::string>();
651
652 llama_tokens p;
653 if (first) {
654 p = common_tokenize(vocab, s, add_special, parse_special);
655 first = false;
656 } else {
657 p = common_tokenize(vocab, s, false, parse_special);
658 }
659
660 prompt_tokens.insert(prompt_tokens.end(), p.begin(), p.end());
661 } else {
662 if (first) {
663 first = false;
664 }
665
666 prompt_tokens.push_back(p.template get<llama_token>());
667 }
668 }
669 } else {
670 auto s = json_prompt.template get<std::string>();
671 prompt_tokens = common_tokenize(vocab, s, add_special, parse_special);
672 }
673
674 return prompt_tokens;
675}
676
677size_t validate_utf8(const std::string& text) {
678 size_t len = text.size();

Callers 3

init_routesMethod · 0.85
tokenize_input_subpromptFunction · 0.85
format_prompt_infillFunction · 0.85

Calls 5

common_tokenizeFunction · 0.85
endMethod · 0.80
insertMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected