Knowledge • Rust AI Agent SDK

Knowledge: Main knowledge manager.

Knowledge

Defined in the knowledge module.

Rust AI Agent SDK

Main knowledge manager.

Fields

NameTypeDescription
configKnowledgeConfigConfiguration
documentsVec<Document>Documents
chunkingChunkingChunking utility

Methods

new

rust
fn new() -> KnowledgeBuilder

Create a new knowledge builder

add

rust
fn add(&mut self, content: &str, metadata: Option<HashMap<String, String>>) -> Result<AddResult>

Add content to knowledge base

Parameters:

NameType
content&str
metadataOption&lt;HashMap&lt;String

add_document

rust
fn add_document(&mut self, document: Document) -> Result<AddResult>

Add a document

Parameters:

NameType
documentDocument

search

rust
fn search(&self, query: &str, limit: usize) -> Result<SearchResult>

Search knowledge base (placeholder – would use embeddings in real impl)

Parameters:

NameType
query&str
limitusize

get

rust
fn get(&self, id: &str) -> Option<&Document>

Get document by ID

Parameters:

NameType
id&str

delete

rust
fn delete(&mut self, id: &str) -> bool

Delete document by ID

Parameters:

NameType
id&str

clear

rust
fn clear(&mut self) -> ()

Clear all documents

len

rust
fn len(&self) -> usize

Get document count

is_empty

rust
fn is_empty(&self) -> bool

Check if empty

chunk

rust
fn chunk(&self, text: &str) -> Vec<String>

Chunk text using configured strategy

Parameters:

NameType
text&str

Source

View on GitHub

praisonai/src/knowledge/mod.rs at line 756


Related Documentation