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 abc import ABC |
| #3 | from typing import Dict, Optional, Union |
| #4 | |
| #5 | import httpx |
| #6 | |
| #7 | from mem0.configs.base import AzureConfig |
| #8 | |
| #9 | |
| #10 | class BaseEmbedderConfig(ABC): |
| #11 | """ |
| #12 | Config for Embeddings. |
| #13 | """ |
| #14 | |
| #15 | def __init__( |
| #16 | self, |
| #17 | model: Optional[str] = None, |
| #18 | api_key: Optional[str] = None, |
| #19 | embedding_dims: Optional[int] = None, |
| #20 | # Ollama specific |
| #21 | ollama_base_url: Optional[str] = None, |
| #22 | # Openai specific |
| #23 | openai_base_url: Optional[str] = None, |
| #24 | # Huggingface specific |
| #25 | model_kwargs: Optional[dict] = None, |
| #26 | huggingface_base_url: Optional[str] = None, |
| #27 | # AzureOpenAI specific |
| #28 | azure_kwargs: Optional[AzureConfig] = {}, |
| #29 | http_client_proxies: Optional[Union[Dict, str]] = None, |
| #30 | # VertexAI specific |
| #31 | vertex_credentials_json: Optional[str] = None, |
| #32 | memory_add_embedding_type: Optional[str] = None, |
| #33 | memory_update_embedding_type: Optional[str] = None, |
| #34 | memory_search_embedding_type: Optional[str] = None, |
| #35 | # Gemini specific |
| #36 | output_dimensionality: Optional[str] = None, |
| #37 | # LM Studio specific |
| #38 | lmstudio_base_url: Optional[str] = "http://localhost:1234/v1", |
| #39 | # AWS Bedrock specific |
| #40 | aws_access_key_id: Optional[str] = None, |
| #41 | aws_secret_access_key: Optional[str] = None, |
| #42 | aws_region: Optional[str] = None, |
| #43 | ): |
| #44 | """ |
| #45 | Initializes a configuration class instance for the Embeddings. |
| #46 | |
| #47 | :param model: Embedding model to use, defaults to None |
| #48 | :type model: Optional[str], optional |
| #49 | :param api_key: API key to be use, defaults to None |
| #50 | :type api_key: Optional[str], optional |
| #51 | :param embedding_dims: The number of dimensions in the embedding, defaults to None |
| #52 | :type embedding_dims: Optional[int], optional |
| #53 | :param ollama_base_url: Base URL for the Ollama API, defaults to None |
| #54 | :type ollama_base_url: Optional[str], optional |
| #55 | :param model_kwargs: key-value arguments for the huggingface embedding model, defaults a dict inside init |
| #56 | :type model_kwargs: Optional[Dict[str, Any]], defaults a dict inside init |
| #57 | :param huggingface_base_url: Huggingface base URL to be use, defaults to None |
| #58 | :type huggingface_base_url: Optional[str], optional |
| #59 | :param openai_base_url: Openai base URL to be use, defaults to "https://api.openai.com/v1" |
| #60 | :type openai_base_url: Optional[str], optional |
| #61 | :param azure_kwargs: key-value arguments for the AzureOpenAI embedding model, defaults a dict inside init |
| #62 | :type azure_kwargs: Optional[Dict[str, Any]], defaults a dict inside init |
| #63 | :param http_client_proxies: The proxy server settings used to create self.http_client, defaults to None |
| #64 | :type http_client_proxies: Optional[Dict | str], optional |
| #65 | :param vertex_credentials_json: The path to the Vertex AI credentials JSON file, defaults to None |
| #66 | :type vertex_credentials_json: Optional[str], optional |
| #67 | :param memory_add_embedding_type: The type of embedding to use for the add memory action, defaults to None |
| #68 | :type memory_add_embedding_type: Optional[str], optional |
| #69 | :param memory_update_embedding_type: The type of embedding to use for the update memory action, defaults to None |
| #70 | :type memory_update_embedding_type: Optional[str], optional |
| #71 | :param memory_search_embedding_type: The type of embedding to use for the search memory action, defaults to None |
| #72 | :type memory_search_embedding_type: Optional[str], optional |
| #73 | :param lmstudio_base_url: LM Studio base URL to be use, defaults to "http://localhost:1234/v1" |
| #74 | :type lmstudio_base_url: Optional[str], optional |
| #75 | """ |
| #76 | |
| #77 | self.model = model |
| #78 | self.api_key = api_key |
| #79 | self.openai_base_url = openai_base_url |
| #80 | self.embedding_dims = embedding_dims |
| #81 | |
| #82 | # AzureOpenAI specific |
| #83 | self.http_client = httpx.Client(proxies=http_client_proxies) if http_client_proxies else None |
| #84 | |
| #85 | # Ollama specific |
| #86 | self.ollama_base_url = ollama_base_url |
| #87 | |
| #88 | # Huggingface specific |
| #89 | self.model_kwargs = model_kwargs or {} |
| #90 | self.huggingface_base_url = huggingface_base_url |
| #91 | # AzureOpenAI specific |
| #92 | self.azure_kwargs = AzureConfig(**azure_kwargs) or {} |
| #93 | |
| #94 | # VertexAI specific |
| #95 | self.vertex_credentials_json = vertex_credentials_json |
| #96 | self.memory_add_embedding_type = memory_add_embedding_type |
| #97 | self.memory_update_embedding_type = memory_update_embedding_type |
| #98 | self.memory_search_embedding_type = memory_search_embedding_type |
| #99 | |
| #100 | # Gemini specific |
| #101 | self.output_dimensionality = output_dimensionality |
| #102 | |
| #103 | # LM Studio specific |
| #104 | self.lmstudio_base_url = lmstudio_base_url |
| #105 | |
| #106 | # AWS Bedrock specific |
| #107 | self.aws_access_key_id = aws_access_key_id |
| #108 | self.aws_secret_access_key = aws_secret_access_key |
| #109 | self.aws_region = aws_region or os.environ.get("AWS_REGION") or "us-west-2" |
| #110 | |
| #111 |