Release remaining buffer content and perform final cleanup at stream end.
(self)
| 1073 | return "".join(output) |
| 1074 | |
| 1075 | def flush(self) -> str: |
| 1076 | """Release remaining buffer content and perform final cleanup at stream end.""" |
| 1077 | res = "" |
| 1078 | if self._is_outputting(): |
| 1079 | res = self.buffer |
| 1080 | tail_match = STREAM_TAIL_RE.search(res) |
| 1081 | if tail_match: |
| 1082 | res = res[: -len(tail_match.group(0))] |
| 1083 | |
| 1084 | self.buffer = "" |
| 1085 | self.stack = ["NORMAL"] |
| 1086 | self.current_role = "" |
| 1087 | return strip_system_hints(res) |
| 1088 | |
| 1089 | |
| 1090 | # --- Response Builders & Streaming --- |
no test coverage detected