Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
```rust title="cli_with_config.rs"
use std::process::Command;
use anyhow::Result;
fn extract_with_config(file_path: &str, config_path: &str) -> Result<serde_json::Value> {
let output = Command::new("kreuzberg")
.args(&[
"extract",
file_path,
"--config",
config_path,
"--format",
"json",
])
.output()?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
anyhow::bail!("CLI error: {}", stderr);
}
let result: serde_json::Value = serde_json::from_slice(&output.stdout)?;
Ok(result)
}
fn main() -> Result<()> {
let config_file = "kreuzberg.toml";
let document = "document.pdf";
println!("Extracting {} with config {}", document, config_file);
let result = extract_with_config(document, config_file)?;
println!("Content length: {}", result["content"].as_str().unwrap_or("").len());
println!("Format: {}", result["format"].as_str().unwrap_or("unknown"));
println!("Languages: {}", result["languages"].to_string());
Ok(())
}
```