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

Method truncate

examples/server/server.py:2398–2413  ·  view source on GitHub ↗
(self, seq_id: int, keep_len: int)

Source from the content-addressed store, hash-verified

2396 self.context_pos[seq_id] = min(self.context_pos[seq_id], keep_len)
2397
2398 def truncate(self, seq_id: int, keep_len: int) -> None:
2399 if seq_id < 0 or seq_id >= self.n_seq_max:
2400 return
2401 self._truncate_memory(seq_id, keep_len)
2402 if keep_len <= 0:
2403 self.pending_h[seq_id].fill(0.0)
2404 self.verify_h[seq_id] = np.empty((0, self.n_embd), dtype=np.float32)
2405 self.verify_h_pos[seq_id] = []
2406 self.verify_h_rows[seq_id] = 0
2407 self.ready[seq_id] = False
2408 self.ready_pos[seq_id] = 0
2409 self.context_pos[seq_id] = 0
2410 return
2411
2412 if self.ready_pos[seq_id] != keep_len:
2413 self.ready[seq_id] = False
2414
2415 def copy_sequence(
2416 self,

Callers 3

_draft_chain_headsMethod · 0.95
draftMethod · 0.95
draft_manyMethod · 0.95

Calls 1

_truncate_memoryMethod · 0.95

Tested by

no test coverage detected