MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / update_system_prompt

Method update_system_prompt

examples/server/server.cpp:866–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

864 }
865
866 void update_system_prompt() {
867 system_tokens = ::llama_tokenize(ctx, system_prompt, true);
868
869 llama_batch_clear(batch);
870
871 kv_cache_clear();
872
873 for (int i = 0; i < (int) system_tokens.size(); ++i)
874 {
875 llama_batch_add(batch, system_tokens[i], i, { 0 }, false);
876 }
877
878 if (llama_decode(ctx, batch) != 0)
879 {
880 LOG_TEE("%s: llama_decode() failed\n", __func__);
881 return;
882 }
883
884 // assign the system KV cache to all parallel sequences
885 for (int32_t i = 1; i < params.n_parallel; ++i)
886 {
887 llama_kv_cache_seq_cp(ctx, 0, i, 0, system_tokens.size());
888 }
889
890 LOG_TEE("system prompt updated\n");
891 system_need_update = false;
892 }
893
894 void notify_system_prompt_changed() {
895 // release all slots

Callers

nothing calls this directly

Calls 6

llama_batch_clearFunction · 0.85
llama_batch_addFunction · 0.85
llama_kv_cache_seq_cpFunction · 0.85
llama_tokenizeFunction · 0.50
llama_decodeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected