From Knowledge Bases
In memory
The InMemoryKnowledgeBase
class is an in-memory implementation of the KnowledgeBase
interface. It provides fast, local storage for documents with support for topic-based organization. This implementation is ideal for lightweight applications that do not require a persistent database or cloud-based storage. Unlike cloud-based solutions, this implementation stores all documents in memory, making it extremely fast but limited by system memory.
Key Features
- In-Memory Storage: Stores all documents in Python dictionaries for quick access.
- Topic-Based Organization: Documents are grouped by topics for easy categorization.
- Fast Document Retrieval: Provides quick access to retrieving documents by ID.
- Random Document Selection: Supports random selection of documents from the filtered set.
- Basic Similarity Search: Returns random documents from the same topic as a given seed document.