(
self, apply_func: Callable[[llama_cpp.llama_token_data_array], None]
)
| 841 | llama_cpp.llama_sampler_chain_add(self.sampler, sampler) |
| 842 | |
| 843 | def add_custom( |
| 844 | self, apply_func: Callable[[llama_cpp.llama_token_data_array], None] |
| 845 | ): |
| 846 | custom_sampler = CustomSampler(apply_func) |
| 847 | sampler = custom_sampler.get_sampler() |
| 848 | llama_cpp.llama_sampler_chain_add(self.sampler, sampler) |
| 849 | # NOTE: Must remove custom samplers before free or llama.cpp will try to free them |
| 850 | self.custom_samplers.append( |
| 851 | (llama_cpp.llama_sampler_chain_n(self.sampler) - 1, custom_sampler) |
| 852 | ) |
| 853 | |
| 854 | def get_seed(self) -> int: |
| 855 | return llama_cpp.llama_sampler_get_seed(self.sampler) |
no test coverage detected