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 | --- |
| #2 | title: Azure MySQL |
| #3 | --- |
| #4 | |
| #5 | [Azure Database for MySQL](https://azure.microsoft.com/products/mysql) is a fully managed relational database service that provides enterprise-grade reliability and security. It supports JSON-based vector storage for semantic search capabilities in AI applications. |
| #6 | |
| #7 | ### Usage |
| #8 | |
| #9 | ```python |
| #10 | import os |
| #11 | from mem0 import Memory |
| #12 | |
| #13 | os.environ["OPENAI_API_KEY"] = "sk-xx" |
| #14 | |
| #15 | config = { |
| #16 | "vector_store": { |
| #17 | "provider": "azure_mysql", |
| #18 | "config": { |
| #19 | "host": "your-server.mysql.database.azure.com", |
| #20 | "port": 3306, |
| #21 | "user": "your_username", |
| #22 | "password": "your_password", |
| #23 | "database": "mem0_db", |
| #24 | "collection_name": "memories", |
| #25 | } |
| #26 | } |
| #27 | } |
| #28 | |
| #29 | m = Memory.from_config(config) |
| #30 | messages = [ |
| #31 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #32 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #33 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #34 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #35 | ] |
| #36 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #37 | ``` |
| #38 | |
| #39 | #### Using Azure Managed Identity |
| #40 | |
| #41 | For production deployments, use Azure Managed Identity instead of passwords: |
| #42 | |
| #43 | ```python |
| #44 | config = { |
| #45 | "vector_store": { |
| #46 | "provider": "azure_mysql", |
| #47 | "config": { |
| #48 | "host": "your-server.mysql.database.azure.com", |
| #49 | "user": "your_username", |
| #50 | "database": "mem0_db", |
| #51 | "collection_name": "memories", |
| #52 | "use_azure_credential": True, # Uses DefaultAzureCredential |
| #53 | "ssl_disabled": False |
| #54 | } |
| #55 | } |
| #56 | } |
| #57 | ``` |
| #58 | |
| #59 | <Note> |
| #60 | When `use_azure_credential` is enabled, the password is obtained via Azure DefaultAzureCredential (supports Managed Identity, Azure CLI, etc.) |
| #61 | </Note> |
| #62 | |
| #63 | ### Config |
| #64 | |
| #65 | Here are the parameters available for configuring Azure MySQL: |
| #66 | |
| #67 | | Parameter | Description | Default Value | |
| #68 | | --- | --- | --- | |
| #69 | | `host` | MySQL server hostname | Required | |
| #70 | | `port` | MySQL server port | `3306` | |
| #71 | | `user` | Database user | Required | |
| #72 | | `password` | Database password (optional with Azure credential) | `None` | |
| #73 | | `database` | Database name | Required | |
| #74 | | `collection_name` | Table name for storing vectors | `"mem0"` | |
| #75 | | `embedding_model_dims` | Dimensions of embedding vectors | `1536` | |
| #76 | | `use_azure_credential` | Use Azure DefaultAzureCredential | `False` | |
| #77 | | `ssl_ca` | Path to SSL CA certificate | `None` | |
| #78 | | `ssl_disabled` | Disable SSL (not recommended) | `False` | |
| #79 | | `minconn` | Minimum connections in pool | `1` | |
| #80 | | `maxconn` | Maximum connections in pool | `5` | |
| #81 | |
| #82 | ### Setup |
| #83 | |
| #84 | #### Create MySQL Flexible Server using Azure CLI: |
| #85 | |
| #86 | ```bash |
| #87 | # Create resource group |
| #88 | az group create --name mem0-rg --location eastus |
| #89 | |
| #90 | # Create MySQL Flexible Server |
| #91 | az mysql flexible-server create \ |
| #92 | --resource-group mem0-rg \ |
| #93 | --name mem0-mysql-server \ |
| #94 | --location eastus \ |
| #95 | --admin-user myadmin \ |
| #96 | --admin-password <YourPassword> \ |
| #97 | --version 8.0.21 |
| #98 | |
| #99 | # Create database |
| #100 | az mysql flexible-server db create \ |
| #101 | --resource-group mem0-rg \ |
| #102 | --server-name mem0-mysql-server \ |
| #103 | --database-name mem0_db |
| #104 | |
| #105 | # Configure firewall |
| #106 | az mysql flexible-server firewall-rule create \ |
| #107 | --resource-group mem0-rg \ |
| #108 | --name mem0-mysql-server \ |
| #109 | --rule-name AllowMyIP \ |
| #110 | --start-ip-address <YourIP> \ |
| #111 | --end-ip-address <YourIP> |
| #112 | ``` |
| #113 | |
| #114 | #### Enable Azure AD Authentication: |
| #115 | |
| #116 | 1. In Azure Portal, navigate to your MySQL Flexible Server |
| #117 | 2. Go to **Security** > **Authentication** and enable Azure AD |
| #118 | 3. Add your application's managed identity as a MySQL user: |
| #119 | |
| #120 | ```sql |
| #121 | CREATE AADUSER 'your-app-identity' IDENTIFIED BY 'your-client-id'; |
| #122 | GRANT ALL PRIVILEGES ON mem0_db.* TO 'your-app-identity'@'%'; |
| #123 | FLUSH PRIVILEGES; |
| #124 | ``` |
| #125 | |
| #126 | <Tip> |
| #127 | For production, use [Managed Identity](https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/) to eliminate password management. |
| #128 | </Tip> |
| #129 |