Skip to main content

Knowledge

Defined in the knowledge module.
Rust AI Agent SDK Main knowledge manager.

Fields

NameTypeDescription
configKnowledgeConfigConfiguration
documentsVec<Document>Documents
chunkingChunkingChunking utility

Methods

new

fn new() -> KnowledgeBuilder
Create a new knowledge builder

add

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

fn add_document(&mut self, document: Document) -> Result<AddResult>
Add a document Parameters:
NameType
documentDocument
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

fn get(&self, id: &str) -> Option<&Document>
Get document by ID Parameters:
NameType
id&str

delete

fn delete(&mut self, id: &str) -> bool
Delete document by ID Parameters:
NameType
id&str

clear

fn clear(&mut self) -> ()
Clear all documents

len

fn len(&self) -> usize
Get document count

is_empty

fn is_empty(&self) -> bool
Check if empty

chunk

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