RAG & Embeddings Reference¶
This section documents the Retrieval-Augmented Generation (RAG) pipeline, document chunk representation, vector store backends, and embedding generators.
DocumentChunk¶
edgevoiceai.rag.chunk ¶
Document chunk representation for Voice AI RAG pipeline.
DocumentChunk
dataclass
¶
Standardized knowledge chunk retrieved from any vector database.
Source code in edgevoiceai/rag/chunk.py
from_dict
classmethod
¶
Constructs a DocumentChunk from dictionary data.
Source code in edgevoiceai/rag/chunk.py
to_dict ¶
Converts chunk to dictionary representation.
Source code in edgevoiceai/rag/chunk.py
RAGRetriever¶
edgevoiceai.rag.retriever ¶
RAG Retriever for Voice AI Framework. Orchestrates dense embedding generation, vector store lookup, and automated fallback to local/in-memory knowledge when networks are offline.
RAGRetriever ¶
Modular RAG retrieval engine. Connects any embedding model with primary and fallback vector stores.
Source code in edgevoiceai/rag/retriever.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 | |
__call__
async
¶
Callable interface directly compatible with KnowledgeBaseTool's retriever_func. Returns list of dicts.
Source code in edgevoiceai/rag/retriever.py
build_context_text ¶
Formats retrieved chunks into a standardized context block for LLM prompts.
Source code in edgevoiceai/rag/retriever.py
retrieve
async
¶
Retrieves relevant document chunks for a natural language voice query. Falls back to fallback_store if primary store is unreachable or yields no matches.
Source code in edgevoiceai/rag/retriever.py
Vector Stores¶
BaseVectorStore¶
edgevoiceai.rag.stores.base ¶
Base interface for Vector Database Stores.
BaseVectorStore ¶
Bases: ABC
Abstract Base Class for vector storage and semantic retrieval backends.
Source code in edgevoiceai/rag/stores/base.py
name
abstractmethod
property
¶
Name of the vector database backend (e.g. In-Memory, Qdrant, Pinecone).
delete_by_filter
async
¶
delete_points
async
¶
get_stats
async
¶
Returns collection/index statistics (point counts, dimensions, status).
Source code in edgevoiceai/rag/stores/base.py
init_collection
async
¶
is_available
abstractmethod
async
¶
search
abstractmethod
async
¶
Searches the vector store using dense query vectors. Returns matched DocumentChunks ranked by descending similarity score.
Source code in edgevoiceai/rag/stores/base.py
upsert
abstractmethod
async
¶
Stores or updates document chunks with their dense vector embeddings.
InMemoryVectorStore¶
edgevoiceai.rag.stores.memory ¶
In-Memory & Local File Vector Store. Provides pure-Python vector search with cosine similarity and keyword fallback. Zero external services or Docker containers required. Ideal for edge devices and offline testing.
InMemoryVectorStore ¶
Bases: BaseVectorStore
In-memory vector store with optional JSON persistence.
Source code in edgevoiceai/rag/stores/memory.py
29 30 31 32 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
delete_by_filter
async
¶
Deletes chunks matching filter.
Source code in edgevoiceai/rag/stores/memory.py
delete_points
async
¶
Deletes points by ID.
Source code in edgevoiceai/rag/stores/memory.py
from_json_file
classmethod
¶
Loads document chunks and vectors from a structured JSON file. Accepts list of dictionaries with {title, text, metadata, audio_url, vector?}.
Source code in edgevoiceai/rag/stores/memory.py
get_stats
async
¶
Returns statistics of in-memory store.
search
async
¶
Performs cosine similarity search against stored vectors.
Source code in edgevoiceai/rag/stores/memory.py
search_keyword ¶
Fast token-based lexical search fallback when embeddings are unavailable.
Source code in edgevoiceai/rag/stores/memory.py
upsert
async
¶
Stores chunks with their corresponding vectors.
Source code in edgevoiceai/rag/stores/memory.py
QdrantVectorStore¶
edgevoiceai.rag.stores.qdrant ¶
Qdrant Vector Database Store Adapter. Supports local, on-premise, and cloud Qdrant instances.
QdrantVectorStore ¶
Bases: BaseVectorStore
Qdrant vector database store adapter.
Source code in edgevoiceai/rag/stores/qdrant.py
23 24 25 26 27 28 29 30 31 32 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
delete_by_filter
async
¶
Deletes all points matching the given metadata filter.
Source code in edgevoiceai/rag/stores/qdrant.py
delete_points
async
¶
Deletes specific point IDs from Qdrant.
Source code in edgevoiceai/rag/stores/qdrant.py
get_stats
async
¶
Retrieves collection statistics (point counts, indexed vectors, dimension).
Source code in edgevoiceai/rag/stores/qdrant.py
init_collection
async
¶
Ensures the collection exists with the required vector dimension and distance metric.
Source code in edgevoiceai/rag/stores/qdrant.py
is_available
async
¶
Checks if Qdrant server is reachable and collection exists.
Source code in edgevoiceai/rag/stores/qdrant.py
search
async
¶
Executes vector similarity search on Qdrant collection.
Source code in edgevoiceai/rag/stores/qdrant.py
upsert
async
¶
Upserts document chunks and embeddings into Qdrant in batches.
Source code in edgevoiceai/rag/stores/qdrant.py
PineconeVectorStore¶
edgevoiceai.rag.stores.pinecone ¶
Pinecone Serverless Cloud Vector Database Store Adapter.
PineconeVectorStore ¶
Bases: BaseVectorStore
Pinecone serverless cloud vector database store adapter.
Source code in edgevoiceai/rag/stores/pinecone.py
22 23 24 25 26 27 28 29 30 31 32 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
delete_by_filter
async
¶
Deletes all vectors in Pinecone matching metadata filter.
Source code in edgevoiceai/rag/stores/pinecone.py
delete_points
async
¶
Deletes specific vector IDs from Pinecone in batches.
Source code in edgevoiceai/rag/stores/pinecone.py
get_stats
async
¶
Retrieves Pinecone index statistics.
Source code in edgevoiceai/rag/stores/pinecone.py
invalidate_cache ¶
is_available
async
¶
Verifies connection to Pinecone cloud index with cached result.
Source code in edgevoiceai/rag/stores/pinecone.py
search
async
¶
Queries Pinecone index asynchronously via thread offload.
Source code in edgevoiceai/rag/stores/pinecone.py
upsert
async
¶
Upserts vectors and metadata into Pinecone.
Source code in edgevoiceai/rag/stores/pinecone.py
Embedding Services¶
BaseEmbeddingModel¶
edgevoiceai.rag.embeddings.base ¶
Base interface for RAG embedding models.
BaseEmbeddingModel ¶
Bases: ABC
Abstract Base Class for text embedding generators.
Source code in edgevoiceai/rag/embeddings/base.py
GeminiEmbeddings¶
edgevoiceai.rag.embeddings.gemini ¶
Gemini Embeddings Generator. Produces high-quality 768-dimensional dense vectors using Google Gemini API.
GeminiEmbeddings ¶
Bases: BaseEmbeddingModel
Asynchronous embedding generator powered by Google Gemini API. Reuses persistent HTTP connections to eliminate TLS handshake latency on edge devices.
Source code in edgevoiceai/rag/embeddings/gemini.py
24 25 26 27 28 29 30 31 32 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 | |
close
async
¶
embed_batch
async
¶
Generates dense vector embeddings for multiple texts using Gemini batchEmbedContents API. Includes automatic batch chunking, rate-limiting delays, and exponential backoff on HTTP 429.
Source code in edgevoiceai/rag/embeddings/gemini.py
embed_query
async
¶
embed_text
async
¶
Generates embedding vector for a given text.