mem0ai-azure-mysql 0.1.116.11__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. mem0ai_azure_mysql-0.2.0/PKG-INFO +221 -0
  2. mem0ai_azure_mysql-0.2.0/README.md +181 -0
  3. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/__init__.py +1 -1
  4. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/llms/base.py +1 -1
  5. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/embeddings/configs.py +3 -14
  6. mem0ai_azure_mysql-0.2.0/mem0/graphs/configs.py +64 -0
  7. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/llms/azure_openai.py +1 -1
  8. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/llms/configs.py +2 -20
  9. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/main.py +0 -861
  10. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/utils/factory.py +3 -55
  11. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/vector_stores/configs.py +2 -23
  12. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/pyproject.toml +20 -41
  13. mem0ai_azure_mysql-0.1.116.11/PKG-INFO +0 -88
  14. mem0ai_azure_mysql-0.1.116.11/README.md +0 -24
  15. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/anthropic.py +0 -56
  16. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/aws_bedrock.py +0 -191
  17. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/deepseek.py +0 -56
  18. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/lmstudio.py +0 -59
  19. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/ollama.py +0 -56
  20. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/openai.py +0 -76
  21. mem0ai_azure_mysql-0.1.116.11/mem0/configs/llms/vllm.py +0 -56
  22. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/baidu.py +0 -29
  23. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/chroma.py +0 -40
  24. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/databricks.py +0 -63
  25. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/elasticsearch.py +0 -65
  26. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/faiss.py +0 -39
  27. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/langchain.py +0 -32
  28. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/milvus.py +0 -44
  29. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/mongodb.py +0 -25
  30. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/opensearch.py +0 -41
  31. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/pgvector.py +0 -50
  32. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/pinecone.py +0 -57
  33. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/qdrant.py +0 -49
  34. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/redis.py +0 -26
  35. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/supabase.py +0 -44
  36. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/upstash_vector.py +0 -36
  37. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/vertex_ai_vector_search.py +0 -27
  38. mem0ai_azure_mysql-0.1.116.11/mem0/configs/vector_stores/weaviate.py +0 -43
  39. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/aws_bedrock.py +0 -100
  40. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/gemini.py +0 -39
  41. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/huggingface.py +0 -41
  42. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/langchain.py +0 -35
  43. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/lmstudio.py +0 -29
  44. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/mock.py +0 -11
  45. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/ollama.py +0 -53
  46. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/openai.py +0 -49
  47. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/together.py +0 -31
  48. mem0ai_azure_mysql-0.1.116.11/mem0/embeddings/vertexai.py +0 -54
  49. mem0ai_azure_mysql-0.1.116.11/mem0/graphs/configs.py +0 -120
  50. mem0ai_azure_mysql-0.1.116.11/mem0/graphs/neptune/base.py +0 -410
  51. mem0ai_azure_mysql-0.1.116.11/mem0/graphs/neptune/main.py +0 -373
  52. mem0ai_azure_mysql-0.1.116.11/mem0/llms/anthropic.py +0 -87
  53. mem0ai_azure_mysql-0.1.116.11/mem0/llms/aws_bedrock.py +0 -600
  54. mem0ai_azure_mysql-0.1.116.11/mem0/llms/azure_openai_structured.py +0 -91
  55. mem0ai_azure_mysql-0.1.116.11/mem0/llms/deepseek.py +0 -107
  56. mem0ai_azure_mysql-0.1.116.11/mem0/llms/gemini.py +0 -201
  57. mem0ai_azure_mysql-0.1.116.11/mem0/llms/groq.py +0 -88
  58. mem0ai_azure_mysql-0.1.116.11/mem0/llms/langchain.py +0 -65
  59. mem0ai_azure_mysql-0.1.116.11/mem0/llms/litellm.py +0 -87
  60. mem0ai_azure_mysql-0.1.116.11/mem0/llms/lmstudio.py +0 -114
  61. mem0ai_azure_mysql-0.1.116.11/mem0/llms/ollama.py +0 -106
  62. mem0ai_azure_mysql-0.1.116.11/mem0/llms/openai.py +0 -141
  63. mem0ai_azure_mysql-0.1.116.11/mem0/llms/openai_structured.py +0 -52
  64. mem0ai_azure_mysql-0.1.116.11/mem0/llms/sarvam.py +0 -89
  65. mem0ai_azure_mysql-0.1.116.11/mem0/llms/together.py +0 -88
  66. mem0ai_azure_mysql-0.1.116.11/mem0/llms/vllm.py +0 -107
  67. mem0ai_azure_mysql-0.1.116.11/mem0/llms/xai.py +0 -52
  68. mem0ai_azure_mysql-0.1.116.11/mem0/memory/kuzu_memory.py +0 -710
  69. mem0ai_azure_mysql-0.1.116.11/mem0/memory/memgraph_memory.py +0 -638
  70. mem0ai_azure_mysql-0.1.116.11/mem0/proxy/__init__.py +0 -0
  71. mem0ai_azure_mysql-0.1.116.11/mem0/proxy/main.py +0 -189
  72. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/__init__.py +0 -0
  73. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/baidu.py +0 -368
  74. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/chroma.py +0 -254
  75. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/databricks.py +0 -759
  76. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/elasticsearch.py +0 -237
  77. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/faiss.py +0 -473
  78. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/langchain.py +0 -180
  79. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/milvus.py +0 -247
  80. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/mongodb.py +0 -312
  81. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/opensearch.py +0 -281
  82. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/pgvector.py +0 -368
  83. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/pinecone.py +0 -382
  84. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/qdrant.py +0 -270
  85. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/redis.py +0 -295
  86. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/supabase.py +0 -237
  87. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/upstash_vector.py +0 -293
  88. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/vertex_ai_vector_search.py +0 -629
  89. mem0ai_azure_mysql-0.1.116.11/mem0/vector_stores/weaviate.py +0 -316
  90. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/.gitignore +0 -0
  91. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/client/__init__.py +0 -0
  92. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/client/main.py +0 -0
  93. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/client/project.py +0 -0
  94. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/client/utils.py +0 -0
  95. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/__init__.py +0 -0
  96. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/base.py +0 -0
  97. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/dbs/__init__.py +0 -0
  98. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/dbs/base.py +0 -0
  99. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/dbs/mysql.py +0 -0
  100. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/embeddings/__init__.py +0 -0
  101. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/embeddings/base.py +0 -0
  102. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/enums.py +0 -0
  103. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/llms/__init__.py +0 -0
  104. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/llms/azure.py +0 -0
  105. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/prompts.py +0 -0
  106. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/vector_stores/__init__.py +0 -0
  107. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/configs/vector_stores/azure_ai_search.py +0 -0
  108. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/dbs/__init__.py +0 -0
  109. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/dbs/base.py +0 -0
  110. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/dbs/configs.py +0 -0
  111. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/dbs/mysql.py +0 -0
  112. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/embeddings/__init__.py +0 -0
  113. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/embeddings/azure_openai.py +0 -0
  114. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/embeddings/base.py +0 -0
  115. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/graphs/__init__.py +0 -0
  116. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/graphs/tools.py +0 -0
  117. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/graphs/utils.py +0 -0
  118. {mem0ai_azure_mysql-0.1.116.11/mem0/graphs/neptune → mem0ai_azure_mysql-0.2.0/mem0/llms}/__init__.py +0 -0
  119. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/llms/base.py +0 -0
  120. {mem0ai_azure_mysql-0.1.116.11/mem0/llms → mem0ai_azure_mysql-0.2.0/mem0/memory}/__init__.py +0 -0
  121. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/base.py +0 -0
  122. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/graph_memory.py +0 -0
  123. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/setup.py +0 -0
  124. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/storage.py +0 -0
  125. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/telemetry.py +0 -0
  126. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/memory/utils.py +0 -0
  127. {mem0ai_azure_mysql-0.1.116.11/mem0/memory → mem0ai_azure_mysql-0.2.0/mem0/vector_stores}/__init__.py +0 -0
  128. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/vector_stores/azure_ai_search.py +0 -0
  129. {mem0ai_azure_mysql-0.1.116.11 → mem0ai_azure_mysql-0.2.0}/mem0/vector_stores/base.py +0 -0
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: mem0ai-azure-mysql
3
+ Version: 0.2.0
4
+ Summary: Long-term memory for AI Agents with Azure DefaultAzureCredential authentication and MySQL history database support. Async-only API.
5
+ Requires-Python: <4.0,>=3.10
6
+ Requires-Dist: azure-identity>=1.23.1
7
+ Requires-Dist: azure-search-documents>=11.5.3
8
+ Requires-Dist: cohere>=5.17.0
9
+ Requires-Dist: langchain-neo4j==0.6.0
10
+ Requires-Dist: openai<1.100.0,>=1.90.0
11
+ Requires-Dist: posthog>=3.5.0
12
+ Requires-Dist: protobuf>=5.29.0
13
+ Requires-Dist: pydantic>=2.7.3
14
+ Requires-Dist: pymysql
15
+ Requires-Dist: pytz>=2024.1
16
+ Requires-Dist: rank-bm25>=0.2.2
17
+ Requires-Dist: sqlalchemy>=2.0.31
18
+ Provides-Extra: dev
19
+ Requires-Dist: azure-keyvault-secrets; extra == 'dev'
20
+ Requires-Dist: isort>=5.13.2; extra == 'dev'
21
+ Requires-Dist: pytest-asyncio>=0.23.7; extra == 'dev'
22
+ Requires-Dist: pytest>=8.2.2; extra == 'dev'
23
+ Requires-Dist: ruff>=0.6.5; extra == 'dev'
24
+ Provides-Extra: extras
25
+ Requires-Dist: boto3>=1.34.0; extra == 'extras'
26
+ Provides-Extra: graph
27
+ Requires-Dist: langchain-neo4j==0.6.0; extra == 'graph'
28
+ Requires-Dist: neo4j>=5.23.1; extra == 'graph'
29
+ Requires-Dist: rank-bm25>=0.2.2; extra == 'graph'
30
+ Provides-Extra: llms
31
+ Requires-Dist: openai<1.100.0,>=1.90.0; extra == 'llms'
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest-asyncio>=0.23.7; extra == 'test'
34
+ Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
35
+ Requires-Dist: pytest>=8.2.2; extra == 'test'
36
+ Provides-Extra: vector-stores
37
+ Requires-Dist: azure-identity>=1.24.0; extra == 'vector-stores'
38
+ Requires-Dist: azure-search-documents>=11.4.0b8; extra == 'vector-stores'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Mem0 - Azure Enhanced Fork
42
+
43
+ This repository is an enhanced fork of [mem0ai/mem0](https://github.com/mem0ai/mem0.git) that provides enterprise-grade improvements for Azure environments and production deployments.
44
+
45
+ ## Key Enhancements
46
+
47
+ ### 1. Async-Only API
48
+ - **AsyncMemory**: This fork provides only the async `AsyncMemory` class for better performance and scalability
49
+ - **Simplified Codebase**: Removed synchronous `Memory` class to reduce code complexity and maintenance burden
50
+ - **Modern Python**: Built for async/await patterns with full asyncio support
51
+
52
+ ### 2. Azure Entra ID Authentication
53
+ - **Azure AI Search**: Support for Azure Entra ID (Azure AD) authentication using `DefaultAzureCredential`
54
+ - **Azure OpenAI**: Seamless Entra ID integration for both LLM and embedding services
55
+ - **Simplified Authentication**: No need to manage API keys when using managed identities or service principals
56
+
57
+ ### 3. MySQL Database Support
58
+ - **Production-Ready**: Replace SQLite3 with enterprise-grade MySQL for scalable memory history storage
59
+ - **Connection Pooling**: Built-in connection pooling and SSL support for secure connections
60
+ - **Thread-Safe**: Thread-safe operations with proper connection management
61
+
62
+ ## Installation
63
+
64
+ Install the enhanced package with Azure and MySQL dependencies:
65
+
66
+ ```bash
67
+ pip install mem0ai-azure-mysql
68
+ ```
69
+
70
+ Or with uv:
71
+
72
+ ```bash
73
+ uv add mem0ai-azure-mysql
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ ```python
79
+ import asyncio
80
+ from mem0 import AsyncMemory
81
+
82
+ config = {
83
+ "vector_store": {
84
+ "provider": "azure_ai_search",
85
+ "config": {
86
+ "collection_name": "mem0",
87
+ "service_name": "your-search-service",
88
+ "embedding_model_dims": 1536,
89
+ "azure_ad_token": "<your-token>" # Or use DefaultAzureCredential
90
+ },
91
+ },
92
+ "llm": {
93
+ "provider": "azure_openai",
94
+ "config": {
95
+ "model": "gpt-4",
96
+ "azure_kwargs": {
97
+ "api_version": "2024-12-01-preview",
98
+ "azure_deployment": "gpt-4",
99
+ "azure_endpoint": "https://your-endpoint.openai.azure.com/",
100
+ "azure_ad_token": "<your-token>",
101
+ },
102
+ },
103
+ },
104
+ "embedder": {
105
+ "provider": "azure_openai",
106
+ "config": {
107
+ "model": "text-embedding-3-small",
108
+ "embedding_dims": 1536,
109
+ "azure_kwargs": {
110
+ "api_version": "2024-12-01-preview",
111
+ "azure_deployment": "text-embedding-3-small",
112
+ "azure_endpoint": "https://your-endpoint.openai.azure.com/",
113
+ "azure_ad_token": "<your-token>",
114
+ },
115
+ },
116
+ },
117
+ "db": {
118
+ "provider": "mysql",
119
+ "config": {
120
+ "host": "your-mysql-server.mysql.database.azure.com",
121
+ "port": 3306,
122
+ "user": "mem0",
123
+ "password": "<your-password>",
124
+ "database": "mem0",
125
+ "ssl_enabled": True,
126
+ },
127
+ },
128
+ }
129
+
130
+ async def main():
131
+ memory = await AsyncMemory.from_config(config)
132
+
133
+ # Add memories
134
+ result = await memory.add(
135
+ "I love playing tennis on weekends",
136
+ user_id="user123"
137
+ )
138
+ print(result)
139
+
140
+ # Search memories
141
+ results = await memory.search("What sports do I like?", user_id="user123")
142
+ print(results)
143
+
144
+ asyncio.run(main())
145
+ ```
146
+
147
+ ## Development
148
+
149
+ ### Setup with uv (Recommended)
150
+
151
+ ```bash
152
+ # Install dependencies with dev extras
153
+ uv sync --extra dev
154
+
155
+ # Run example
156
+ uv run python example.py
157
+
158
+ # Run tests
159
+ uv run pytest tests/
160
+ ```
161
+
162
+ ### Setup with hatch
163
+
164
+ ```bash
165
+ # Create environment
166
+ make install
167
+
168
+ # Run tests
169
+ make test
170
+ ```
171
+
172
+ ### Available Commands
173
+
174
+ ```bash
175
+ make format # Format code with ruff
176
+ make lint # Lint code with ruff
177
+ make test # Run tests
178
+ make build # Build package
179
+ make clean # Clean build artifacts
180
+ ```
181
+
182
+ ## API Reference
183
+
184
+ ### AsyncMemory
185
+
186
+ The main class for interacting with the memory system.
187
+
188
+ ```python
189
+ from mem0 import AsyncMemory
190
+
191
+ # Create from config
192
+ memory = await AsyncMemory.from_config(config)
193
+
194
+ # Add memories
195
+ await memory.add(messages, user_id="user123")
196
+
197
+ # Search memories
198
+ await memory.search(query, user_id="user123")
199
+
200
+ # Get all memories
201
+ await memory.get_all(user_id="user123")
202
+
203
+ # Delete memories
204
+ await memory.delete_all(user_id="user123")
205
+
206
+ # Get memory by ID
207
+ await memory.get(memory_id)
208
+
209
+ # Update memory
210
+ await memory.update(memory_id, new_data)
211
+
212
+ # Get history
213
+ await memory.history(memory_id)
214
+
215
+ # Reset all
216
+ await memory.reset()
217
+ ```
218
+
219
+ ## License
220
+
221
+ This project is licensed under the Apache License 2.0 - see the original [mem0](https://github.com/mem0ai/mem0) repository for details.
@@ -0,0 +1,181 @@
1
+ # Mem0 - Azure Enhanced Fork
2
+
3
+ This repository is an enhanced fork of [mem0ai/mem0](https://github.com/mem0ai/mem0.git) that provides enterprise-grade improvements for Azure environments and production deployments.
4
+
5
+ ## Key Enhancements
6
+
7
+ ### 1. Async-Only API
8
+ - **AsyncMemory**: This fork provides only the async `AsyncMemory` class for better performance and scalability
9
+ - **Simplified Codebase**: Removed synchronous `Memory` class to reduce code complexity and maintenance burden
10
+ - **Modern Python**: Built for async/await patterns with full asyncio support
11
+
12
+ ### 2. Azure Entra ID Authentication
13
+ - **Azure AI Search**: Support for Azure Entra ID (Azure AD) authentication using `DefaultAzureCredential`
14
+ - **Azure OpenAI**: Seamless Entra ID integration for both LLM and embedding services
15
+ - **Simplified Authentication**: No need to manage API keys when using managed identities or service principals
16
+
17
+ ### 3. MySQL Database Support
18
+ - **Production-Ready**: Replace SQLite3 with enterprise-grade MySQL for scalable memory history storage
19
+ - **Connection Pooling**: Built-in connection pooling and SSL support for secure connections
20
+ - **Thread-Safe**: Thread-safe operations with proper connection management
21
+
22
+ ## Installation
23
+
24
+ Install the enhanced package with Azure and MySQL dependencies:
25
+
26
+ ```bash
27
+ pip install mem0ai-azure-mysql
28
+ ```
29
+
30
+ Or with uv:
31
+
32
+ ```bash
33
+ uv add mem0ai-azure-mysql
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ import asyncio
40
+ from mem0 import AsyncMemory
41
+
42
+ config = {
43
+ "vector_store": {
44
+ "provider": "azure_ai_search",
45
+ "config": {
46
+ "collection_name": "mem0",
47
+ "service_name": "your-search-service",
48
+ "embedding_model_dims": 1536,
49
+ "azure_ad_token": "<your-token>" # Or use DefaultAzureCredential
50
+ },
51
+ },
52
+ "llm": {
53
+ "provider": "azure_openai",
54
+ "config": {
55
+ "model": "gpt-4",
56
+ "azure_kwargs": {
57
+ "api_version": "2024-12-01-preview",
58
+ "azure_deployment": "gpt-4",
59
+ "azure_endpoint": "https://your-endpoint.openai.azure.com/",
60
+ "azure_ad_token": "<your-token>",
61
+ },
62
+ },
63
+ },
64
+ "embedder": {
65
+ "provider": "azure_openai",
66
+ "config": {
67
+ "model": "text-embedding-3-small",
68
+ "embedding_dims": 1536,
69
+ "azure_kwargs": {
70
+ "api_version": "2024-12-01-preview",
71
+ "azure_deployment": "text-embedding-3-small",
72
+ "azure_endpoint": "https://your-endpoint.openai.azure.com/",
73
+ "azure_ad_token": "<your-token>",
74
+ },
75
+ },
76
+ },
77
+ "db": {
78
+ "provider": "mysql",
79
+ "config": {
80
+ "host": "your-mysql-server.mysql.database.azure.com",
81
+ "port": 3306,
82
+ "user": "mem0",
83
+ "password": "<your-password>",
84
+ "database": "mem0",
85
+ "ssl_enabled": True,
86
+ },
87
+ },
88
+ }
89
+
90
+ async def main():
91
+ memory = await AsyncMemory.from_config(config)
92
+
93
+ # Add memories
94
+ result = await memory.add(
95
+ "I love playing tennis on weekends",
96
+ user_id="user123"
97
+ )
98
+ print(result)
99
+
100
+ # Search memories
101
+ results = await memory.search("What sports do I like?", user_id="user123")
102
+ print(results)
103
+
104
+ asyncio.run(main())
105
+ ```
106
+
107
+ ## Development
108
+
109
+ ### Setup with uv (Recommended)
110
+
111
+ ```bash
112
+ # Install dependencies with dev extras
113
+ uv sync --extra dev
114
+
115
+ # Run example
116
+ uv run python example.py
117
+
118
+ # Run tests
119
+ uv run pytest tests/
120
+ ```
121
+
122
+ ### Setup with hatch
123
+
124
+ ```bash
125
+ # Create environment
126
+ make install
127
+
128
+ # Run tests
129
+ make test
130
+ ```
131
+
132
+ ### Available Commands
133
+
134
+ ```bash
135
+ make format # Format code with ruff
136
+ make lint # Lint code with ruff
137
+ make test # Run tests
138
+ make build # Build package
139
+ make clean # Clean build artifacts
140
+ ```
141
+
142
+ ## API Reference
143
+
144
+ ### AsyncMemory
145
+
146
+ The main class for interacting with the memory system.
147
+
148
+ ```python
149
+ from mem0 import AsyncMemory
150
+
151
+ # Create from config
152
+ memory = await AsyncMemory.from_config(config)
153
+
154
+ # Add memories
155
+ await memory.add(messages, user_id="user123")
156
+
157
+ # Search memories
158
+ await memory.search(query, user_id="user123")
159
+
160
+ # Get all memories
161
+ await memory.get_all(user_id="user123")
162
+
163
+ # Delete memories
164
+ await memory.delete_all(user_id="user123")
165
+
166
+ # Get memory by ID
167
+ await memory.get(memory_id)
168
+
169
+ # Update memory
170
+ await memory.update(memory_id, new_data)
171
+
172
+ # Get history
173
+ await memory.history(memory_id)
174
+
175
+ # Reset all
176
+ await memory.reset()
177
+ ```
178
+
179
+ ## License
180
+
181
+ This project is licensed under the Apache License 2.0 - see the original [mem0](https://github.com/mem0ai/mem0) repository for details.
@@ -3,4 +3,4 @@ import importlib.metadata
3
3
  __version__ = importlib.metadata.version("mem0ai-azure-mysql")
4
4
 
5
5
  from mem0.client.main import AsyncMemoryClient, MemoryClient # noqa
6
- from mem0.memory.main import AsyncMemory, Memory # noqa
6
+ from mem0.memory.main import AsyncMemory # noqa
@@ -29,7 +29,7 @@ class BaseLlmConfig(ABC):
29
29
  Initialize a base configuration class instance for the LLM.
30
30
 
31
31
  Args:
32
- model: The model identifier to use (e.g., "gpt-4o-mini", "claude-3-5-sonnet-20240620")
32
+ model: The model identifier to use (e.g., "gpt-5.1", "claude-3-5-sonnet-20240620")
33
33
  Defaults to None (will be set by provider-specific configs)
34
34
  temperature: Controls the randomness of the model's output.
35
35
  Higher values (closer to 1) make output more random, lower values make it more deterministic.
@@ -5,26 +5,15 @@ from pydantic import BaseModel, Field, field_validator
5
5
 
6
6
  class EmbedderConfig(BaseModel):
7
7
  provider: str = Field(
8
- description="Provider of the embedding model (e.g., 'ollama', 'openai')",
9
- default="openai",
8
+ description="Provider of the embedding model (e.g., 'azure_openai')",
9
+ default="azure_openai",
10
10
  )
11
11
  config: Optional[dict] = Field(description="Configuration for the specific embedding model", default={})
12
12
 
13
13
  @field_validator("config")
14
14
  def validate_config(cls, v, values):
15
15
  provider = values.data.get("provider")
16
- if provider in [
17
- "openai",
18
- "ollama",
19
- "huggingface",
20
- "azure_openai",
21
- "gemini",
22
- "vertexai",
23
- "together",
24
- "lmstudio",
25
- "langchain",
26
- "aws_bedrock",
27
- ]:
16
+ if provider in ["azure_openai"]:
28
17
  return v
29
18
  else:
30
19
  raise ValueError(f"Unsupported embedding provider: {provider}")
@@ -0,0 +1,64 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, Field, field_validator, model_validator
4
+
5
+ from mem0.llms.configs import LlmConfig
6
+
7
+
8
+ class RerankConfig(BaseModel):
9
+ provider: str = Field(
10
+ description="Provider of the rerank model (e.g., 'openai', 'azure', 'cohere')",
11
+ default="cohere",
12
+ )
13
+ config: Optional[dict] = Field(
14
+ description="Configuration for the specific rerank model", default={}
15
+ )
16
+
17
+ class Neo4jConfig(BaseModel):
18
+ url: Optional[str] = Field(None, description="Host address for the graph database")
19
+ username: Optional[str] = Field(None, description="Username for the graph database")
20
+ password: Optional[str] = Field(None, description="Password for the graph database")
21
+ database: Optional[str] = Field(None, description="Database for the graph database")
22
+ base_label: Optional[bool] = Field(None, description="Whether to use base node label __Entity__ for all entities")
23
+ similarity_threshold: float = Field(0.7, description="Threshold for the similarity of nodes")
24
+ top_k: int = Field(5, description="Number of top scored results to return")
25
+ rerank: Optional[RerankConfig] = Field(None, description="Rerank configuration")
26
+
27
+ @model_validator(mode="before")
28
+ def check_host_port_or_path(cls, values):
29
+ url, username, password = (
30
+ values.get("url"),
31
+ values.get("username"),
32
+ values.get("password"),
33
+ )
34
+ if not url or not username or not password:
35
+ raise ValueError("Please provide 'url', 'username' and 'password'.")
36
+
37
+ if values.get("rerank") is not None:
38
+ values["rerank"] = RerankConfig(**values.get("rerank"))
39
+ if values["rerank"].provider not in ("cohere"):
40
+ raise ValueError("Invalid rerank provider. Supported providers are: cohere")
41
+
42
+ return values
43
+
44
+
45
+ class GraphStoreConfig(BaseModel):
46
+ provider: str = Field(
47
+ description="Provider of the data store (e.g., 'neo4j')",
48
+ default="neo4j",
49
+ )
50
+ config: Optional[Neo4jConfig] = Field(
51
+ description="Configuration for the specific data store", default=None
52
+ )
53
+ llm: Optional[LlmConfig] = Field(description="LLM configuration for querying the graph store", default=None)
54
+ custom_prompt: Optional[str] = Field(
55
+ description="Custom prompt to fetch entities from the given text", default=None
56
+ )
57
+
58
+ @field_validator("config")
59
+ def validate_config(cls, v, values):
60
+ provider = values.data.get("provider")
61
+ if provider in ("neo4j", "default"):
62
+ return Neo4jConfig(**v.model_dump())
63
+ else:
64
+ raise ValueError(f"Unsupported graph store provider: {provider}")
@@ -36,7 +36,7 @@ class AzureOpenAILLM(LLMBase):
36
36
 
37
37
  # Model name should match the custom deployment name chosen for it.
38
38
  if not self.config.model:
39
- self.config.model = "gpt-4o"
39
+ self.config.model = "gpt-5.1"
40
40
 
41
41
  api_key = self.config.azure_kwargs.api_key or os.getenv("LLM_AZURE_API_KEY")
42
42
  azure_ad_token = self.config.azure_kwargs.azure_ad_token or os.getenv("LLM_AZURE_AD_TOKEN")
@@ -4,31 +4,13 @@ from pydantic import BaseModel, Field, field_validator
4
4
 
5
5
 
6
6
  class LlmConfig(BaseModel):
7
- provider: str = Field(description="Provider of the LLM (e.g., 'ollama', 'openai')", default="openai")
7
+ provider: str = Field(description="Provider of the LLM (e.g., 'azure_openai')", default="azure_openai")
8
8
  config: Optional[dict] = Field(description="Configuration for the specific LLM", default={})
9
9
 
10
10
  @field_validator("config")
11
11
  def validate_config(cls, v, values):
12
12
  provider = values.data.get("provider")
13
- if provider in (
14
- "openai",
15
- "ollama",
16
- "anthropic",
17
- "groq",
18
- "together",
19
- "aws_bedrock",
20
- "litellm",
21
- "azure_openai",
22
- "openai_structured",
23
- "azure_openai_structured",
24
- "gemini",
25
- "deepseek",
26
- "xai",
27
- "sarvam",
28
- "lmstudio",
29
- "vllm",
30
- "langchain",
31
- ):
13
+ if provider in ("azure_openai",):
32
14
  return v
33
15
  else:
34
16
  raise ValueError(f"Unsupported LLM provider: {provider}")