use zai_rs::file::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
if std::env::var_os("RUST_LOG").is_some() {
let _ = tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.try_init();
}
let key = std::env::var("ZHIPU_API_KEY").expect("Please set ZHIPU_API_KEY env var");
let path = std::env::args()
.nth(1)
.unwrap_or_else(|| "data/file_test.md".to_string());
let purpose = FilePurpose::FileExtract;
let client = FileUploadRequest::new(key, purpose, &path)
;
let body: FileObject = client.send().await?;
tracing::trace!(
"Uploaded file: id={:?} filename={:?} bytes={:?} purpose={:?}",
body.id,
body.filename,
body.bytes,
body.purpose
);
Ok(())
}