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 openai import OpenAI |
| #4 | |
| #5 | from mem0.configs.embeddings.base import BaseEmbedderConfig |
| #6 | from mem0.embeddings.base import EmbeddingBase |
| #7 | |
| #8 | |
| #9 | class LMStudioEmbedding(EmbeddingBase): |
| #10 | def __init__(self, config: Optional[BaseEmbedderConfig] = None): |
| #11 | super().__init__(config) |
| #12 | |
| #13 | self.config.model = self.config.model or "nomic-ai/nomic-embed-text-v1.5-GGUF/nomic-embed-text-v1.5.f16.gguf" |
| #14 | self.config.embedding_dims = self.config.embedding_dims or 1536 |
| #15 | self.config.api_key = self.config.api_key or "lm-studio" |
| #16 | |
| #17 | self.client = OpenAI(base_url=self.config.lmstudio_base_url, api_key=self.config.api_key) |
| #18 | |
| #19 | def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None): |
| #20 | """ |
| #21 | Get the embedding for the given text using LM Studio. |
| #22 | Args: |
| #23 | text (str): The text to embed. |
| #24 | memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None. |
| #25 | Returns: |
| #26 | list: The embedding vector. |
| #27 | """ |
| #28 | text = text.replace("\n", " ") |
| #29 | return self.client.embeddings.create(input=[text], model=self.config.model).data[0].embedding |
| #30 |