| 48 | return reasoning_parser_result |
| 49 | |
| 50 | def parse(self, text: str) -> ReasoningParserResult: |
| 51 | if not self.reasoning_at_start: |
| 52 | splits = text.partition(self.reasoning_start) |
| 53 | if splits[1] == "": |
| 54 | # no reasoning start tag found |
| 55 | return ReasoningParserResult(content=text) |
| 56 | # reasoning start tag found |
| 57 | # text before reasoning start tag is dropped |
| 58 | text = splits[2] |
| 59 | splits = text.partition(self.reasoning_end) |
| 60 | reasoning_content, content = splits[0], splits[2] |
| 61 | return ReasoningParserResult(content=content, |
| 62 | reasoning_content=reasoning_content) |
| 63 | |
| 64 | def parse_delta(self, delta_text: str) -> ReasoningParserResult: |
| 65 | self._buffer += delta_text |