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

Class Completion

examples/server/server.py:3807–3846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3805
3806@dataclass
3807class Completion:
3808 request_id: str
3809 index: int
3810 seq_id: int
3811 sampler: "Sampler"
3812 prompt_tokens: List[int]
3813 prompt_length: int
3814 prompt_text: str
3815 multimodal_prompt: bool
3816 max_total_tokens: int
3817 stop_sequences: List[bytes]
3818 logprobs: Optional[int]
3819 completion_tokens: List[int] = field(default_factory=list)
3820 token_records: List[Token] = field(default_factory=list)
3821 rendered_bytes: bytearray = field(default_factory=bytearray)
3822 detokenized_prefix_bytes: bytearray = field(default_factory=bytearray)
3823 pending_input_tokens: List[int] = field(default_factory=list)
3824 draft_tokens: List[int] = field(default_factory=list)
3825 pending_finish_reason: Optional[str] = None
3826 returned_token_count: int = 0
3827 finished: bool = False
3828 finish_reason: Optional[str] = None
3829 score_sum: float = 0.0
3830 rank_by_score: bool = False
3831
3832 @property
3833 def total_tokens(self) -> int:
3834 return self.prompt_length + len(self.completion_tokens)
3835
3836 @property
3837 def completion_token_count(self) -> int:
3838 return len(self.completion_tokens)
3839
3840 @property
3841 def needs_token_logprob(self) -> bool:
3842 return self.logprobs is not None or self.rank_by_score
3843
3844 @property
3845 def max_stop_sequence_length(self) -> int:
3846 return max((len(stop) for stop in self.stop_sequences), default=0)
3847
3848
3849@dataclass

Callers 1

start_completionsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…