gproxy_protocol/transform/gemini/stream_generate_content/utils.rs
1use crate::gemini::generate_content::response::ResponseBody as GeminiGenerateContentResponseBody;
2use crate::gemini::types::JsonObject;
3
4pub fn parse_json_object_or_empty(input: &str) -> JsonObject {
5 serde_json::from_str::<JsonObject>(input).unwrap_or_default()
6}
7
8/// Placeholder "done" sentinel — callers that need to signal stream end
9/// can use `is_finished()` on the converter instead. This is kept only
10/// for the `nonstream_to_stream` path that still needs to materialise a
11/// final chunk, which is simply an empty body.
12pub fn empty_chunk() -> GeminiGenerateContentResponseBody {
13 GeminiGenerateContentResponseBody::default()
14}