AgentKnolwedge is the base class for all knowledge base classes in Agno. It provides common functionality and parameters that are inherited by all other knowledge base classes.

ParameterTypeDefaultDescription
readerOptional[Reader]NoneReader to read the documents
vector_dbOptional[VectorDb]NoneVector db to store the knowledge base
num_documentsint2Number of relevant documents to return on search
optimize_onOptional[int]1000Number of documents to optimize the vector db on
driverstr"knowledge"Driver for the Assistant knowledge

Function Reference

Properties

PropertyTypeDescription
document_listsIterator[List[Document]]Iterator that yields lists of documents in the knowledge base
async_document_listsAsyncIterator[List[Document]]Async iterator that yields lists of documents in the knowledge base

Search Methods

MethodParametersReturn TypeDescription
searchquery: str, num_documents: Optional[int] = None, filters: Optional[Dict[str, Any]] = NoneList[Document]Returns relevant documents matching a query
async_searchquery: str, num_documents: Optional[int] = None, filters: Optional[Dict[str, Any]] = NoneList[Document]Asynchronously returns relevant documents matching a query

Loading Methods

MethodParametersReturn TypeDescription
loadrecreate: bool = False, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad the knowledge base to the vector db
aloadrecreate: bool = False, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneAsynchronously load the knowledge base to the vector db
load_documentsdocuments: List[Document], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad documents to the knowledge base
async_load_documentsdocuments: List[Document], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneAsynchronously load documents to the knowledge base
load_documentdocument: Document, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad a single document to the knowledge base
async_load_documentdocument: Document, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneAsynchronously load a single document to the knowledge base
load_dictdocument: Dict[str, Any], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad a dictionary representation of a document to the knowledge base
load_jsondocument: str, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad a JSON representation of a document to the knowledge base
load_texttext: str, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = NoneNoneLoad a text to the knowledge base

Utility Methods

MethodParametersReturn TypeDescription
existsNoneboolReturns True if the knowledge base exists
deleteNoneboolClear the knowledge base