Knowledge • Rust AI Agent SDK
Knowledge: Main knowledge manager.
Knowledge
Defined in the knowledge module.
Rust AI Agent SDK
Main knowledge manager.
Fields
| Name | Type | Description |
|---|---|---|
config | KnowledgeConfig | Configuration |
documents | Vec<Document> | Documents |
chunking | Chunking | Chunking utility |
Methods
new
fn new() -> KnowledgeBuilderCreate a new knowledge builder
add
fn add(&mut self, content: &str, metadata: Option<HashMap<String, String>>) -> Result<AddResult>Add content to knowledge base
Parameters:
| Name | Type |
|---|---|
content | &str |
metadata | Option<HashMap<String |
add_document
fn add_document(&mut self, document: Document) -> Result<AddResult>Add a document
Parameters:
| Name | Type |
|---|---|
document | Document |
search
fn search(&self, query: &str, limit: usize) -> Result<SearchResult>Search knowledge base (placeholder – would use embeddings in real impl)
Parameters:
| Name | Type |
|---|---|
query | &str |
limit | usize |
get
fn get(&self, id: &str) -> Option<&Document>Get document by ID
Parameters:
| Name | Type |
|---|---|
id | &str |
delete
fn delete(&mut self, id: &str) -> boolDelete document by ID
Parameters:
| Name | Type |
|---|---|
id | &str |
clear
fn clear(&mut self) -> ()Clear all documents
len
fn len(&self) -> usizeGet document count
is_empty
fn is_empty(&self) -> boolCheck if empty
chunk
fn chunk(&self, text: &str) -> Vec<String>Chunk text using configured strategy
Parameters:
| Name | Type |
|---|---|
text | &str |
Source
View on GitHubpraisonai/src/knowledge/mod.rs at line 756