30 lines
783 B
Python
30 lines
783 B
Python
from typing import Optional
|
|
from abc import ABC, abstractmethod
|
|
|
|
from mem0.configs.embeddings.base import BaseEmbedderConfig
|
|
|
|
class EmbeddingBase(ABC):
|
|
"""Initialized a base embedding class
|
|
|
|
:param config: Embedding configuration option class, defaults to None
|
|
:type config: Optional[BaseEmbedderConfig], optional
|
|
"""
|
|
def __init__(self, config: Optional[BaseEmbedderConfig] = None):
|
|
if config is None:
|
|
self.config = BaseEmbedderConfig()
|
|
else:
|
|
self.config = config
|
|
|
|
@abstractmethod
|
|
def embed(self, text):
|
|
"""
|
|
Get the embedding for the given text.
|
|
|
|
Args:
|
|
text (str): The text to embed.
|
|
|
|
Returns:
|
|
list: The embedding vector.
|
|
"""
|
|
pass
|