repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | from typing import Literal, Optional |
| #2 | |
| #3 | from mem0.configs.embeddings.base import BaseEmbedderConfig |
| #4 | from mem0.embeddings.base import EmbeddingBase |
| #5 | |
| #6 | try: |
| #7 | from langchain.embeddings.base import Embeddings |
| #8 | except ImportError: |
| #9 | raise ImportError("langchain is not installed. Please install it using `pip install langchain`") |
| #10 | |
| #11 | |
| #12 | class LangchainEmbedding(EmbeddingBase): |
| #13 | def __init__(self, config: Optional[BaseEmbedderConfig] = None): |
| #14 | super().__init__(config) |
| #15 | |
| #16 | if self.config.model is None: |
| #17 | raise ValueError("`model` parameter is required") |
| #18 | |
| #19 | if not isinstance(self.config.model, Embeddings): |
| #20 | raise ValueError("`model` must be an instance of Embeddings") |
| #21 | |
| #22 | self.langchain_model = self.config.model |
| #23 | |
| #24 | def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None): |
| #25 | """ |
| #26 | Get the embedding for the given text using Langchain. |
| #27 | |
| #28 | Args: |
| #29 | text (str): The text to embed. |
| #30 | memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None. |
| #31 | Returns: |
| #32 | list: The embedding vector. |
| #33 | """ |
| #34 | |
| #35 | return self.langchain_model.embed_query(text) |
| #36 |