mem0ai-azure-mysql 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl

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.
mem0/client/utils.py DELETED
@@ -1,29 +0,0 @@
1
- import logging
2
-
3
- import httpx
4
-
5
- logger = logging.getLogger(__name__)
6
-
7
-
8
- class APIError(Exception):
9
- """Exception raised for errors in the API."""
10
-
11
- pass
12
-
13
-
14
- def api_error_handler(func):
15
- """Decorator to handle API errors consistently."""
16
- from functools import wraps
17
-
18
- @wraps(func)
19
- def wrapper(*args, **kwargs):
20
- try:
21
- return func(*args, **kwargs)
22
- except httpx.HTTPStatusError as e:
23
- logger.error(f"HTTP error occurred: {e}")
24
- raise APIError(f"API request failed: {e.response.text}")
25
- except httpx.RequestError as e:
26
- logger.error(f"Request error occurred: {e}")
27
- raise APIError(f"Request failed: {str(e)}")
28
-
29
- return wrapper
@@ -1,221 +0,0 @@
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.