| 913 | } |
| 914 | |
| 915 | static size_t find_stopping_strings(const std::string &text, const size_t last_token_size, |
| 916 | const stop_type type, llama_client_slot &slot) |
| 917 | { |
| 918 | size_t stop_pos = std::string::npos; |
| 919 | |
| 920 | for (const std::string &word : slot.params.antiprompt) |
| 921 | { |
| 922 | size_t pos; |
| 923 | if (type == STOP_FULL) |
| 924 | { |
| 925 | const size_t tmp = word.size() + last_token_size; |
| 926 | const size_t from_pos = text.size() > tmp ? text.size() - tmp : 0; |
| 927 | pos = text.find(word, from_pos); |
| 928 | } |
| 929 | else |
| 930 | { |
| 931 | pos = find_partial_stop_string(word, text); |
| 932 | } |
| 933 | if (pos != std::string::npos && |
| 934 | (stop_pos == std::string::npos || pos < stop_pos)) |
| 935 | { |
| 936 | if (type == STOP_FULL) |
| 937 | { |
| 938 | slot.stopped_word = true; |
| 939 | slot.stopping_word = word; |
| 940 | slot.has_next_token = false; |
| 941 | } |
| 942 | stop_pos = pos; |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | return stop_pos; |
| 947 | } |
| 948 | |
| 949 | bool process_token(completion_token_output &result, llama_client_slot &slot) { |
| 950 | // remember which tokens were sampled - used for repetition penalties during sampling |
nothing calls this directly
no test coverage detected