26 lines
765 B
Rust
26 lines
765 B
Rust
|
|
use mistralai_client::v1::{
|
||
|
|
client::Client,
|
||
|
|
constants::Model,
|
||
|
|
ocr::{OcrDocument, OcrRequest},
|
||
|
|
};
|
||
|
|
|
||
|
|
fn main() {
|
||
|
|
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
|
||
|
|
let client = Client::new(None, None, None, None).unwrap();
|
||
|
|
|
||
|
|
let request = OcrRequest {
|
||
|
|
model: Model::mistral_ocr_latest(),
|
||
|
|
document: OcrDocument::from_url("https://arxiv.org/pdf/2201.04234"),
|
||
|
|
pages: Some(vec![0]),
|
||
|
|
table_format: None,
|
||
|
|
include_image_base64: None,
|
||
|
|
image_limit: None,
|
||
|
|
};
|
||
|
|
|
||
|
|
let response = client.ocr(&request).unwrap();
|
||
|
|
for page in &response.pages {
|
||
|
|
println!("--- Page {} ---", page.index);
|
||
|
|
println!("{}", &page.markdown[..200.min(page.markdown.len())]);
|
||
|
|
}
|
||
|
|
}
|