MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_gitlab_sse

Function parse_gitlab_sse

crates/opencode-provider/src/gitlab.rs:325–347  ·  view source on GitHub ↗
(data: &str)

Source from the content-addressed store, hash-verified

323}
324
325fn 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}

Callers 1

chat_streamMethod · 0.85

Calls 2

is_emptyMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected