Skip to main content

Crate bigrag

Crate bigrag 

Source
Expand description

§bigrag

Rust client for bigRAG — a self-hostable RAG platform.

§Installation

[dependencies]
bigrag = "0.1"
tokio = { version = "1", features = ["full"] }

§Quick Start

use bigrag::BigRag;

#[tokio::main]
async fn main() -> Result<(), bigrag::BigRagError> {
    let client = BigRag::new("http://localhost:6100", "your-api-key");

    // Create a collection
    let collection = client.collections().create(bigrag::types::collections::CreateCollectionBody {
        name: "my-docs".into(),
        ..Default::default()
    }).await?;

    // Upload a document
    let doc = client.documents().upload("my-docs", "/path/to/file.pdf", None).await?;

    // Query
    let results = client.queries().query("my-docs", bigrag::types::query::QueryBody {
        query: "How does it work?".into(),
        ..Default::default()
    }).await?;

    for result in results.results {
        println!("[{:.2}] {}", result.score, result.text);
    }

    Ok(())
}

§Environment Variables

VariableDefaultDescription
BIGRAG_BASE_URLhttp://localhost:6100Base URL of the bigRAG API
BIGRAG_API_KEYAPI key for authentication

Use BigRag::from_env() to read these automatically.

§Builder API

use std::time::Duration;
use bigrag::BigRag;

let client = BigRag::builder()
    .base_url("https://my-bigrag.example.com")
    .api_key("sk-...")
    .timeout(Duration::from_secs(60))
    .max_retries(3)
    .build()?;

§Collection-Scoped Client

use bigrag::BigRag;

let client = BigRag::new("http://localhost:6100", "sk-...");
let col = client.collection("my-docs");

// All methods scoped to "my-docs"
let docs = col.list_documents(None).await?;
let stats = col.stats().await?;

Re-exports§

pub use error::BigRagError;
pub use resources::Collections;
pub use resources::Documents;
pub use resources::Queries;
pub use resources::Vectors;
pub use resources::Webhooks;

Modules§

error
Error types.
resources
Resource namespaces for interacting with the bigRAG API.
types
Request and response types.

Structs§

BigRag
The bigRAG client.
BigRagBuilder
Builder for creating a BigRag client with custom configuration.
BigRagConfig
Configuration for the bigRAG client.
CollectionClient
A collection-scoped client for convenience.
SseStream
A stream of SSE progress events from the bigRAG API.

Enums§

FileInput
Input for file upload operations.