Accumulate RequestOutput
(self, next_output: RequestOutput)
| 1059 | self.outputs.speculate_metrics = next_output.metrics.speculate_metrics |
| 1060 | |
| 1061 | def accumulate(self, next_output: RequestOutput) -> None: |
| 1062 | """Accumulate RequestOutput""" |
| 1063 | if self.outputs.text is None: |
| 1064 | self.outputs.text = next_output.outputs.text |
| 1065 | elif next_output.outputs.text: |
| 1066 | self.outputs.text += next_output.outputs.text |
| 1067 | if self.outputs.reasoning_content is None: |
| 1068 | self.outputs.reasoning_content = next_output.outputs.reasoning_content |
| 1069 | elif next_output.outputs.reasoning_content: |
| 1070 | self.outputs.reasoning_content += next_output.outputs.reasoning_content |
| 1071 | |
| 1072 | if self.outputs.completion_tokens is None: |
| 1073 | self.outputs.completion_tokens = next_output.outputs.completion_tokens |
| 1074 | elif next_output.outputs.completion_tokens: |
| 1075 | self.outputs.completion_tokens += next_output.outputs.completion_tokens |
| 1076 | |
| 1077 | if next_output.outputs.tool_calls: |
| 1078 | if self.accumulate_tool_calls is None: |
| 1079 | self.accumulate_tool_calls = [] |
| 1080 | self.accumulate_tool_calls.append(next_output.outputs.tool_calls) |
| 1081 | self.add(next_output) |
| 1082 | |
| 1083 | def __repr__(self) -> str: |
| 1084 | return ( |