MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / add_custom

Method add_custom

llama_cpp/_internals.py:843–852  ·  view source on GitHub ↗
(
        self, apply_func: Callable[[llama_cpp.llama_token_data_array], None]
    )

Source from the content-addressed store, hash-verified

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)

Callers 1

_init_samplerMethod · 0.95

Calls 3

get_samplerMethod · 0.95
CustomSamplerClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected