Extract the text inside an open (unclosed) ` ` block, if any. Returns empty string if there's no open think block.
(content: &str)
| 275 | /// Extract the text inside an open (unclosed) `<think>` block, if any. |
| 276 | /// Returns empty string if there's no open think block. |
| 277 | fn extract_open_think(content: &str) -> String { |
| 278 | let mut rest = content; |
| 279 | loop { |
| 280 | match rest.find("<think>") { |
| 281 | Some(pos) => { |
| 282 | rest = &rest[pos + 7..]; |
| 283 | match rest.find("</think>") { |
| 284 | Some(end) => { |
| 285 | rest = &rest[end + 8..]; |
| 286 | } |
| 287 | None => { |
| 288 | // This is the open block |
| 289 | return rest.trim().to_string(); |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | None => return String::new(), |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /// Remove all `<think>...</think>` blocks (closed) and any trailing open |
| 299 | /// `<think>...` (still thinking) from the displayed content. |
no outgoing calls
no test coverage detected