Fix Codex transcript streaming and images
This commit is contained in:
1 parent
14dd520719
commit
4dc3e3d784
7 files changed
+422
-53
No files matched your search
@@ -1148,23 +1148,13 @@ pub(in crate::session) fn save_image(session_dir: &Path, part: &Value) -> Option
|
||||
let bytes = base64::engine::general_purpose::STANDARD
|
||||
.decode(data)
|
||||
.ok()?;
|
||||
// Screenshots are the overwhelming case and they are PNG; an unrecognized
|
||||
// type is more likely a dialect change than a JPEG.
|
||||
let extension = source
|
||||
// Screenshots are the overwhelming case and they are PNG; an unrecognized type is more likely
|
||||
// a dialect change than a JPEG. `store_image` owns that fallback.
|
||||
let media_type = source
|
||||
.get("media_type")
|
||||
.and_then(Value::as_str)
|
||||
.and_then(crate::media::extension_for)
|
||||
.unwrap_or("png");
|
||||
let name = format!("{}.{extension}", super::super::random_hex());
|
||||
let dir = session_dir.join("files");
|
||||
if let Err(err) = wg_app_link::private::create_dir(&dir)
|
||||
.map_err(std::io::Error::other)
|
||||
.and_then(|()| std::fs::write(dir.join(&name), bytes))
|
||||
{
|
||||
tracing::error!("couldn't save produced image: {err}");
|
||||
return None;
|
||||
}
|
||||
Some(name)
|
||||
.unwrap_or("image/png");
|
||||
super::super::driver::store_image(session_dir, media_type, &bytes)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user