(text, enable_think)
| 107 | |
| 108 | |
| 109 | def post_process_text(text, enable_think): |
| 110 | text = text.replace('assistantfinal', '</think>') |
| 111 | text = text.replace('\n\n</think>', '\n</think>') |
| 112 | if enable_think: |
| 113 | if "<think>" in text: |
| 114 | return "<think>" + text.split("<think>")[-1] |
| 115 | else: |
| 116 | return "<think>\n" + text.strip() |
| 117 | else: |
| 118 | return text.strip() |
| 119 | |
| 120 | |
| 121 | def append_jsonl(path: str, data: dict) -> None: |