| 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 |
nothing calls this directly
no test coverage detected