Extract NEED_DOCS markers from critique text for targeted retrieval. The model should emit lines like: NEED_DOCS: Flask error handler decorator syntax Returns the joined query string, or None if no markers found.
(critique: str)
| 182 | |
| 183 | |
| 184 | def extract_doc_needs(critique: str) -> Optional[str]: |
| 185 | """ |
| 186 | Extract NEED_DOCS markers from critique text for targeted retrieval. |
| 187 | |
| 188 | The model should emit lines like: |
| 189 | NEED_DOCS: Flask error handler decorator syntax |
| 190 | |
| 191 | Returns the joined query string, or None if no markers found. |
| 192 | """ |
| 193 | matches = re.findall(r'NEED_DOCS:\s*(.+?)(?:\n|$)', critique, re.IGNORECASE) |
| 194 | if matches: |
| 195 | return " ".join(m.strip() for m in matches) |
| 196 | return None |
| 197 | |
| 198 | |
| 199 | _CRITICAL_MARKERS = [ |