MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / CompletionOutput

Class CompletionOutput

fastdeploy/engine/request.py:702–798  ·  view source on GitHub ↗

The output data of one completion output of a request. Args: index: The index of the output in the request. text: The generated output text. token_ids: The token IDs of the generated output text.

Source from the content-addressed store, hash-verified

700
701@dataclass(slots=True)
702class CompletionOutput:
703 """The output data of one completion output of a request.
704
705 Args:
706 index: The index of the output in the request.
707 text: The generated output text.
708 token_ids: The token IDs of the generated output text.
709 """
710
711 index: int
712 send_idx: int
713 token_ids: list[Any]
714 decode_type: int = 0
715 logprob: Optional[float] = None
716 top_logprobs: Optional[LogprobsLists] = None
717 draft_top_logprobs: Optional[LogprobsLists] = None
718 logprobs: Optional[SampleLogprobs] = None
719 draft_token_ids: list[int] = None
720 text: Optional[str] = None
721 reasoning_content: Optional[str] = None
722 reasoning_token_num: Optional[int] = 0
723 tool_calls: Optional[ToolCall] = None
724 speculate_metrics: Optional[SpeculateMetrics] = None
725 completion_tokens: Optional[str] = None
726 delta_message: Optional[DeltaMessage] = None
727 multipart: Optional[list[Any]] = None
728 num_image_tokens: Optional[int] = None
729 enable_parser: bool = False
730 # Sparse indices of retained vocab ids:
731 # - Non-MTP: list[int]
732 # - MTP: list[list[int]]
733 sampling_mask: Optional[Any] = None
734
735 def to_dict(self):
736 """
737 convert CompletionOutput to a serialized dict
738 """
739 return {
740 "index": self.index,
741 "send_idx": self.send_idx,
742 "token_ids": self.token_ids,
743 "decode_type": self.decode_type,
744 "logprob": self.logprob,
745 "top_logprobs": self.top_logprobs,
746 "draft_top_logprobs": self.draft_top_logprobs,
747 "logprobs": self.logprobs,
748 "draft_token_ids": self.draft_token_ids,
749 "text": self.text,
750 "reasoning_content": self.reasoning_content,
751 "reasoning_token_num": self.reasoning_token_num,
752 "sampling_mask": self.sampling_mask,
753 }
754
755 @classmethod
756 def from_dict(cls, req_dict: dict[str, Any]) -> CompletionOutput:
757 """Create instance from dict arguments"""
758 return cls(
759 **{

Calls

no outgoing calls