(data: &str)
| 323 | } |
| 324 | |
| 325 | fn parse_gitlab_sse(data: &str) -> Option<StreamEvent> { |
| 326 | if data.is_empty() { |
| 327 | return None; |
| 328 | } |
| 329 | |
| 330 | let response: GitLabStreamResponse = serde_json::from_str(data).ok()?; |
| 331 | |
| 332 | let choice = response.choices.first()?; |
| 333 | |
| 334 | if let Some(content) = &choice.delta.content { |
| 335 | if !content.is_empty() { |
| 336 | return Some(StreamEvent::TextDelta(content.clone())); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if let Some(reason) = &choice.finish_reason { |
| 341 | if reason == "tool_calls" { |
| 342 | return Some(StreamEvent::Done); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | None |
| 347 | } |
no test coverage detected