Skip to content

Commit 645106e

Browse files
committed
Copy missing _keep_alive and custom_samplers list to new sampler
1 parent 8f5c9b6 commit 645106e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

llama_cpp/_internals.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,16 @@ def clone(self) -> 'LlamaSampler':
14881488
if not new_sampler_p:
14891489
raise RuntimeError("llama_sampler_clone failed")
14901490

1491-
return LlamaSampler(existing_sampler_p=new_sampler_p)
1491+
new_sampler = LlamaSampler(existing_sampler_p=new_sampler_p)
1492+
1493+
# copy _keep_alive and custom_samplers list to new sampler
1494+
if self._keep_alive:
1495+
new_sampler._keep_alive = self._keep_alive.copy()
1496+
1497+
if self.custom_samplers:
1498+
new_sampler.custom_samplers = self.custom_samplers.copy()
1499+
1500+
return new_sampler
14921501

14931502
def sample(self, ctx: LlamaContext, idx: int = -1) -> int:
14941503
"""

0 commit comments

Comments
 (0)