pub struct FileDelivery {
pub filename: String,
pub delivered_as: DeliveredAs,
pub pages: Option<Pages>,
pub transcribed_pages: Vec<u32>,
pub fallback: Option<DeliveryFallback>,
}Expand description
How one file an operation carried reached the model.
A file asked for as text is not always sent as text. A page with no text of its own is read from its image, and when that reading fails the document is sent instead, so the answer is never built on text with a hole in it. This is how a caller finds out which happened, without reading a platform log.
Page numbers are the original document’s, whatever range was cut from it, so a page named here is the page a person would turn to.
let read = simple::ai::summarize(
json!({
"file_hash": "9f2c…",
"filename": "contract.pdf",
"mime_type": "application/pdf",
"first_page": 40,
"last_page": 52,
"deliver_as": "text"
}),
"Say what it commits us to.",
Options::default(),
)?;
for file in &read.metadata.delivery {
if let Some(fallback) = &file.fallback {
println!("{} was read as a PDF: {}", file.filename, fallback.message);
}
}
let contract = &read.metadata.delivery[0];
assert_eq!(contract.delivered_as, DeliveredAs::Document);
assert_eq!(contract.pages, Some(Pages::new(40, 52)));Fields§
§filename: StringThe file’s name.
delivered_as: DeliveredAsHow the file travelled.
pages: Option<Pages>The range the file was cut to, when one was asked for. Unset when the whole file travelled.
transcribed_pages: Vec<u32>The pages whose text was read from their images rather than from their text layer. Empty when none were.
fallback: Option<DeliveryFallback>Set only when text was asked for and the document travelled instead: which pages could not be read, and why.