Storage Service
Bases: Service
A service responsible for persisting runtime data artifacts within the Engramic system.
StorageService listens for various system events and saves corresponding data—including observations, engrams, metadata, and prompt histories—via plugin-based repositories. It also tracks metrics for each type of saved entity to facilitate performance monitoring and operational insights.
Attributes:
Name | Type | Description |
---|---|---|
plugin_manager |
PluginManager
|
Provides access to system plugins, including database integrations. |
db_document_plugin |
Plugin used by repositories for data persistence. |
|
history_repository |
HistoryRepository
|
Manages saving of prompt/response history data. |
observation_repository |
ObservationRepository
|
Handles saving of Observation entities. |
engram_repository |
EngramRepository
|
Handles saving of Engram entities. |
meta_repository |
MetaRepository
|
Handles saving of Meta configuration entities. |
metrics_tracker |
MetricsTracker
|
Tracks counts of saved items for metric reporting. |
Methods:
Name | Description |
---|---|
start |
Registers the service to relevant message topics and begins operation. |
init_async |
Connects to the database plugin asynchronously before full service startup. |
on_engram_complete |
Callback for storing completed engram batches. |
on_observation_complete |
Callback for storing completed observations. |
on_prompt_complete |
Callback for storing completed prompt/response history. |
on_meta_complete |
Callback for storing finalized meta configuration. |
save_observation |
Coroutine to persist observations and update metrics. |
save_history |
Coroutine to persist prompt/response history and update metrics. |
save_engram |
Coroutine to persist engram data and update metrics. |
save_meta |
Coroutine to persist metadata and update metrics. |
on_acknowledge |
Collects current metrics and publishes service status. |
Source code in src/engramic/application/storage/storage_service.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
save_observation(response)
async
Persists an observation to the database and updates the observation metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
Observation
|
The observation object to be saved. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in src/engramic/application/storage/storage_service.py
117 118 119 120 121 122 123 124 125 126 127 128 129 |
|