Skip to main content
Chunking splits documents into pieces for better retrieval.

Quick Start

1

Create Agent with Chunked Knowledge

use praisonai::{Agent, Knowledge, ChunkingConfig};

// Configure chunking for knowledge base
let knowledge = Knowledge::new()
    .source("docs/")
    .chunking(ChunkingConfig::semantic()
        .chunk_size(1000)
        .overlap(200))
    .build()?;

// Add documents - they'll be automatically chunked
knowledge.add_file("guide.pdf").await?;

// Create agent that uses chunked knowledge
let agent = Agent::new()
    .name("Assistant")
    .instructions("You answer questions using the knowledge base")
    .build()?;

// Search returns relevant chunks
let chunks = knowledge.search("How do I get started?").await?;

Chunking Strategies

StrategyBest For
FixedCode, technical docs
SemanticArticles, narratives
SentenceQ&A, FAQs
ParagraphStructured documents

Configuration

OptionTypeDefaultDescription
chunk_sizeusize1000Characters per chunk
chunk_overlapusize200Overlap between chunks
strategyChunkingStrategySemanticHow to split