MCPcopy
hub / github.com/InternLM/lmdeploy / extend

Method extend

lmdeploy/messages.py:570–594  ·  view source on GitHub ↗

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')

Source from the content-addressed store, hash-verified

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

Callers 15

gen_packages_itemsFunction · 0.80
compute_metricsMethod · 0.80
inferMethod · 0.80
_genMethod · 0.80
get_pplMethod · 0.80
_get_long_text_pplMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
preprocessMethod · 0.80
forwardMethod · 0.80

Calls

no outgoing calls

Tested by 3

_postMethod · 0.64
__call__Method · 0.64