Embeddings¶
embedders
¶
Assembly: Mappy Filename: embedders.py Author: Terry D. Eppler Created: 09-08-2026 Last Modified By: Terry D. Eppler Last Modified On: 09-09-2026
Mappy is a Python framework for geospatial and data workflows.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classes¶
LocalGGUFEmbeddings
¶
Bases: Embeddings
LangChain-compatible local GGUF embedding implementation.
Initialize the local GGUF embedding implementation.
Purpose
Stores the configured model path and initializes lazy llama.cpp client state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Filesystem path to a local GGUF embedding model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This method initializes instance state. |
Source code in embedders.py
Methods:¶
load
¶
Load the configured local GGUF model once.
Purpose
Verifies the model path and lazily creates a llama.cpp client configured for embedding generation. Repeated calls reuse the loaded client.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This method initializes the local model client when needed. |
Source code in embedders.py
embed_documents
¶
Create embeddings for document text.
Purpose
Generates one local embedding vector for every supplied text value while preserving positional correspondence between source chunks and returned vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
List[str]
|
Chunk text values to embed. |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: One numeric vector for each supplied text value. |
Source code in embedders.py
embed_query
¶
Create an embedding for query text.
Purpose
Implements the LangChain query-embedding contract using the same local GGUF model used for document embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Query text to embed. |
required |
Returns:
| Type | Description |
|---|---|
List[float]
|
List[float]: Numeric embedding vector for the supplied query. |
Source code in embedders.py
EmbeddingFactory
¶
Factory for Mappy's supported LangChain embedding implementations.
Initialize embedding provider state.
Purpose
Initializes reusable provider and model state without importing optional provider SDKs.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This method initializes instance state. |
Source code in embedders.py
Methods:¶
create
¶
Create the selected LangChain embedding implementation.
Purpose
Lazily resolves hosted OpenAI, Google Generative AI, Mistral AI, Hugging Face, or local GGUF embeddings behind one common LangChain Embeddings interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Embedding provider selected by the user. |
required |
model
|
str
|
Hosted or Hugging Face embedding model name. |
required |
model_path
|
str
|
Local GGUF model path used only by the Local GGUF provider. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
Embeddings |
Embeddings
|
Configured LangChain embedding implementation. |
Source code in embedders.py
Functions:¶
throw_if
¶
Validate a required runtime value.
Purpose
Ensures required embedding configuration and input values are present before provider or local-model work begins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Argument name included in validation errors. |
required |
value
|
object
|
Runtime value to validate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function validates input and does not return a value. |