Extend this response with another response. This method merges the content of another Response into this one, similar to list.extend(). The text, token_ids, and logprobs are concatenated, while other fields are updated from the other response. Args: othe
(self, other: 'Response')
| 568 | return '\n'.join(fields) |
| 569 | |
| 570 | def extend(self, other: 'Response') -> 'Response': |
| 571 | """Extend this response with another response. |
| 572 | |
| 573 | This method merges the content of another Response into this one, |
| 574 | similar to list.extend(). The text, token_ids, and logprobs are |
| 575 | concatenated, while other fields are updated from the other response. |
| 576 | |
| 577 | Args: |
| 578 | other: Another Response to append to this one. |
| 579 | |
| 580 | Returns: |
| 581 | Self (for method chaining). |
| 582 | """ |
| 583 | self.text += other.text |
| 584 | self.generate_token_len = other.generate_token_len |
| 585 | self.input_token_len = other.input_token_len |
| 586 | self.finish_reason = other.finish_reason |
| 587 | self.index = other.index |
| 588 | if other.token_ids: |
| 589 | self.token_ids += other.token_ids |
| 590 | if other.logprobs: |
| 591 | self.logprobs = self.logprobs or [] |
| 592 | self.logprobs += other.logprobs |
| 593 | self.routed_experts = other.routed_experts |
| 594 | return self |
| 595 | |
| 596 | |
| 597 | # modified from https://github.com/vllm-project/vllm/blob/main/vllm/v1/engine/__init__.py |
no outgoing calls