Retrieve Service
Bases: Service
Manages semantic prompt retrieval and indexing by coordinating between vector/document databases, tracking metrics, and responding to system events.
This service is responsible for receiving prompt submissions, retrieving relevant information using vector similarity, and handling the indexing and metadata enrichment process. It interfaces with plugin-managed databases and provides observability through metrics tracking.
Attributes:
Name | Type | Description |
---|---|---|
plugin_manager |
PluginManager
|
Access point for system plugins, including vector and document DBs. |
vector_db_plugin |
dict
|
Plugin used for vector database operations (e.g., semantic search). |
db_plugin |
dict
|
Plugin for interacting with the document database. |
metrics_tracker |
MetricsTracker[RetrieveMetric]
|
Collects and resets retrieval-related metrics for monitoring. |
meta_repository |
MetaRepository
|
Handles Meta object persistence and transformation. |
repo_folders |
dict[str, Any]
|
Dictionary containing repository folder information. |
default_repos |
dict[str, Any]
|
Dictionary of default repositories that are always included in prompts. |
Methods:
Name | Description |
---|---|
init_async |
Initializes database connections and plugin setup asynchronously. |
start |
Subscribes to system topics for prompt processing and indexing lifecycle. |
stop |
Cleans up the service and halts processing. |
submit |
Prompt): Begins the retrieval process, handles default repos, and logs submission metrics. |
on_submit_prompt |
dict[Any, Any]): Processes a prompt message from monitor service and submits for processing. |
_on_repo_folders |
dict[str, Any]): Updates repository folder information and identifies default repositories. |
on_indices_complete |
dict): Converts index payload into Index objects and queues for insertion. |
_insert_engram_vector |
list[Index], engram_id: str, repo_ids: str, tracking_id: str, engram_type: str): Asynchronously inserts semantic indices into vector DB with repository and type filters. |
on_meta_complete |
dict): Loads and inserts metadata summary into the vector DB. |
insert_meta_vector |
Meta): Runs metadata vector insertion in a background thread using asyncio.to_thread. |
on_acknowledge |
str): Emits service metrics to the status channel and resets the tracker. |
Source code in src/engramic/application/retrieve/retrieve_service.py
33 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|