| |
- builtins.object
-
- EpistemicAPI
class EpistemicAPI(builtins.object) |
|
EpistemicAPI(config: episemic.config.EpistemicConfig | None = None)
High-level API for Episemic Core memory system.
This class provides a simple interface for using Episemic as a Python library.
Example:
>>> api = EpistemicAPI()
>>> await api.initialize()
>>>
>>> # Store a memory
>>> memory_id = await api.store_memory(
... "This is important information",
... title="Important Note",
... tags=["important", "note"]
... )
>>>
>>> # Search for memories
>>> results = await api.search("important information", top_k=5)
>>>
>>> # Get a specific memory
>>> memory = await api.get_memory(memory_id) |
|
Methods defined here:
- async __aenter__(self)
- Async context manager entry.
- async __aexit__(self, exc_type, exc_val, exc_tb)
- Async context manager exit.
- __init__(self, config: episemic.config.EpistemicConfig | None = None)
- Initialize Episemic API.
Args:
config: Configuration object. If None, uses default configuration.
- async consolidate_memory(self, memory_id: str) -> bool
- Manually trigger consolidation for a specific memory.
Args:
memory_id: The memory ID to consolidate
Returns:
True if consolidation successful, False otherwise.
- async get_memory(self, memory_id: str) -> episemic.models.Memory | None
- Retrieve a specific memory by ID.
Args:
memory_id: The memory ID to retrieve
Returns:
Memory object if found, None otherwise.
- async get_related_memories(self, memory_id: str, max_related: int = 5) -> list[episemic.models.SearchResult]
- Get memories related to a specific memory.
Args:
memory_id: The reference memory ID
max_related: Maximum number of related memories to return
Returns:
List of related memories with relevance scores.
- async health_check(self) -> dict[str, bool]
- Check the health status of all components.
Returns:
Dictionary with health status of each component.
- async initialize(self) -> bool
- Initialize all system components.
Returns:
True if initialization successful, False otherwise.
- async run_auto_consolidation(self) -> int
- Run automatic consolidation sweep.
Returns:
Number of memories processed.
- async search(self, query: str, top_k: int = 10, tags: list[str] | None = None, include_quarantined: bool = False, embedding: list[float] | None = None) -> list[episemic.models.SearchResult]
- Search for memories using multiple retrieval strategies.
Args:
query: Search query text
top_k: Maximum number of results to return
tags: Optional tag filters
include_quarantined: Whether to include quarantined memories
embedding: Optional pre-computed query embedding
Returns:
List of search results with relevance scores.
- async store_memory(self, text: str, title: str | None = None, source: str = 'api', tags: list[str] | None = None, embedding: list[float] | None = None, metadata: dict | None = None, store_in_hippocampus: bool = True, store_in_cortex: bool = True) -> str | None
- Store a new memory in the system.
Args:
text: The main content of the memory
title: Optional title for the memory
source: Source identifier (default: "api")
tags: Optional list of tags
embedding: Optional pre-computed embedding vector
metadata: Optional additional metadata
store_in_hippocampus: Whether to store in fast hippocampus layer
store_in_cortex: Whether to store in persistent cortex layer
Returns:
Memory ID if successful, None otherwise.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |