rho-coding-agent 0.15.1

A lightweight agent harness inspired by Pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub use crate::provider_backend::ImageContent;

pub fn image_summary(image: &ImageContent) -> String {
    let bytes = base64::Engine::decode(&base64::engine::general_purpose::STANDARD, &image.data)
        .map(|bytes| bytes.len())
        .unwrap_or_default();
    format!("{} {}", image.mime_type, format_bytes(bytes))
}

fn format_bytes(bytes: usize) -> String {
    if bytes >= 1024 * 1024 {
        format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0))
    } else if bytes >= 1024 {
        format!("{:.1} KB", bytes as f64 / 1024.0)
    } else {
        format!("{bytes} B")
    }
}