MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / __init__

Method __init__

llama_cpp/_internals.py:676–690  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

674
675class LlamaSampler:
676 def __init__(self):
677 params = llama_cpp.llama_sampler_chain_default_params()
678 self.sampler = llama_cpp.llama_sampler_chain_init(params)
679 self.custom_samplers: List[Tuple[int, CustomSampler]] = []
680 self._exit_stack = ExitStack()
681
682 def free_sampler():
683 if self.sampler is not None:
684 # NOTE: Must remove custom samplers before free or llama.cpp will try to free them
685 for i, _ in reversed(self.custom_samplers):
686 llama_cpp.llama_sampler_chain_remove(self.sampler, i)
687 llama_cpp.llama_sampler_free(self.sampler)
688 self.sampler = None
689
690 self._exit_stack.callback(free_sampler)
691
692 def close(self):
693 self._exit_stack.close()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected