use bigrag::types::{CreateCollectionBody, QueryBody};
use bigrag::BigRag;
#[tokio::main]
async fn main() -> Result<(), bigrag::BigRagError> {
let client = BigRag::from_env()?;
let health = client.health().await?;
println!("Server: {} ({})", health.status, health.version);
let collection = client
.collections()
.create(CreateCollectionBody {
name: "example_docs".into(),
description: Some("Example collection".into()),
..Default::default()
})
.await?;
println!("Created collection: {}", collection.name);
let doc = client
.documents()
.upload("example_docs", "README.md", None)
.await?;
println!("Uploaded: {} ({})", doc.filename, doc.id);
println!("Waiting for processing...");
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
let results = client
.queries()
.query(
"example_docs",
QueryBody {
query: "What is bigRAG?".into(),
top_k: Some(3),
..Default::default()
},
)
.await?;
println!("\nResults ({} total):", results.total);
for r in &results.results {
println!(" [{:.3}] {}", r.score, &r.text[..r.text.len().min(100)]);
}
client.collections().delete("example_docs").await?;
println!("\nCleaned up.");
Ok(())
}