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 | import os |
| #2 | from typing import Literal, Optional |
| #3 | |
| #4 | from together import Together |
| #5 | |
| #6 | from mem0.configs.embeddings.base import BaseEmbedderConfig |
| #7 | from mem0.embeddings.base import EmbeddingBase |
| #8 | |
| #9 | |
| #10 | class TogetherEmbedding(EmbeddingBase): |
| #11 | def __init__(self, config: Optional[BaseEmbedderConfig] = None): |
| #12 | super().__init__(config) |
| #13 | |
| #14 | self.config.model = self.config.model or "togethercomputer/m2-bert-80M-8k-retrieval" |
| #15 | api_key = self.config.api_key or os.getenv("TOGETHER_API_KEY") |
| #16 | # TODO: check if this is correct |
| #17 | self.config.embedding_dims = self.config.embedding_dims or 768 |
| #18 | self.client = Together(api_key=api_key) |
| #19 | |
| #20 | def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None): |
| #21 | """ |
| #22 | Get the embedding for the given text using OpenAI. |
| #23 | |
| #24 | Args: |
| #25 | text (str): The text to embed. |
| #26 | memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None. |
| #27 | Returns: |
| #28 | list: The embedding vector. |
| #29 | """ |
| #30 | |
| #31 | return self.client.embeddings.create(model=self.config.model, input=text).data[0].embedding |
| #32 |