mem0ai-azure-mysql 0.1.116.4__tar.gz → 0.1.116.6__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.
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/PKG-INFO +1 -1
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/azure_openai.py +15 -3
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/graph_memory.py +50 -37
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/main.py +3 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/utils.py +21 -9
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/pyproject.toml +1 -1
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/.gitignore +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/README.md +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/client/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/client/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/client/project.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/client/utils.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/dbs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/dbs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/dbs/mysql.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/embeddings/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/embeddings/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/enums.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/anthropic.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/azure.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/deepseek.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/vllm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/prompts.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/azure_ai_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/baidu.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/chroma.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/databricks.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/elasticsearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/faiss.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/milvus.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/mongodb.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/opensearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/pgvector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/pinecone.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/qdrant.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/redis.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/supabase.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/upstash_vector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/vertex_ai_vector_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/weaviate.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/dbs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/dbs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/dbs/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/dbs/mysql.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/gemini.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/huggingface.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/mock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/together.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/vertexai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/neptune/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/neptune/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/neptune/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/tools.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/utils.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/anthropic.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/azure_openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/azure_openai_structured.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/deepseek.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/gemini.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/groq.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/litellm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/openai_structured.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/sarvam.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/together.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/vllm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/xai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/kuzu_memory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/memgraph_memory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/setup.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/storage.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/telemetry.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/proxy/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/proxy/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/utils/factory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/azure_ai_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/baidu.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/chroma.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/databricks.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/elasticsearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/faiss.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/milvus.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/mongodb.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/opensearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/pgvector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/pinecone.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/qdrant.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/redis.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/supabase.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/upstash_vector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/vertex_ai_vector_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/weaviate.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mem0ai-azure-mysql
|
|
3
|
-
Version: 0.1.116.
|
|
3
|
+
Version: 0.1.116.6
|
|
4
4
|
Summary: Long-term memory for AI Agents with Azure DefaultAzureCredential authentication and MySQL history database support
|
|
5
5
|
Requires-Python: <4.0,>=3.9
|
|
6
6
|
Requires-Dist: azure-identity>=1.23.1
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/azure_openai.py
RENAMED
|
@@ -10,6 +10,9 @@ from mem0.memory.utils import time_perf
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class AzureOpenAIEmbedding(EmbeddingBase):
|
|
13
|
+
|
|
14
|
+
cached_embeddings = {}
|
|
15
|
+
|
|
13
16
|
def __init__(self, config: Optional[BaseEmbedderConfig] = None):
|
|
14
17
|
super().__init__(config)
|
|
15
18
|
|
|
@@ -54,7 +57,9 @@ class AzureOpenAIEmbedding(EmbeddingBase):
|
|
|
54
57
|
list: The embedding vector.
|
|
55
58
|
"""
|
|
56
59
|
text = text.replace("\n", " ")
|
|
57
|
-
|
|
60
|
+
if text not in self.cached_embeddings:
|
|
61
|
+
self.cached_embeddings[text] = self.client.embeddings.create(input=[text], model=self.config.model).data[0].embedding
|
|
62
|
+
return self.cached_embeddings[text]
|
|
58
63
|
|
|
59
64
|
@time_perf
|
|
60
65
|
def embed_in_batch(self, texts, memory_action: Optional[Literal["add", "search", "update"]] = None):
|
|
@@ -68,5 +73,12 @@ class AzureOpenAIEmbedding(EmbeddingBase):
|
|
|
68
73
|
list: List of the embedding vector.
|
|
69
74
|
"""
|
|
70
75
|
texts = [text.replace("\n", " ") for text in texts]
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
|
|
77
|
+
# Use cached embeddings if available
|
|
78
|
+
uncached_texts = [text for text in texts if text not in self.cached_embeddings]
|
|
79
|
+
if uncached_texts:
|
|
80
|
+
uncached_embeddings = self.client.embeddings.create(input=uncached_texts, model=self.config.model)
|
|
81
|
+
for text, item in zip(uncached_texts, uncached_embeddings.data):
|
|
82
|
+
self.cached_embeddings[text] = item.embedding
|
|
83
|
+
|
|
84
|
+
return [self.cached_embeddings[text] for text in texts]
|
|
@@ -96,6 +96,7 @@ class MemoryGraph:
|
|
|
96
96
|
|
|
97
97
|
return {"deleted_entities": deleted_entities, "added_entities": added_entities}
|
|
98
98
|
|
|
99
|
+
@time_perf
|
|
99
100
|
def search(self, query, filters, limit=100):
|
|
100
101
|
"""
|
|
101
102
|
Search for memories and related graph data.
|
|
@@ -139,6 +140,7 @@ class MemoryGraph:
|
|
|
139
140
|
|
|
140
141
|
return search_results
|
|
141
142
|
|
|
143
|
+
@time_perf
|
|
142
144
|
def rerank(self, search_output, query):
|
|
143
145
|
if not self.config.graph_store.config.rerank:
|
|
144
146
|
search_outputs_sequence = [
|
|
@@ -318,52 +320,51 @@ class MemoryGraph:
|
|
|
318
320
|
@time_perf
|
|
319
321
|
def _search_graph_db(self, node_list, filters, limit=100):
|
|
320
322
|
"""Search similar nodes among and their respective incoming and outgoing relations."""
|
|
321
|
-
result_relations = []
|
|
322
|
-
|
|
323
323
|
# Build node properties for filtering
|
|
324
|
-
node_props = ["user_id:
|
|
324
|
+
node_props = ["user_id: row.user_id"]
|
|
325
325
|
if filters.get("agent_id"):
|
|
326
|
-
node_props.append("agent_id:
|
|
326
|
+
node_props.append("agent_id: row.agent_id")
|
|
327
327
|
if filters.get("run_id"):
|
|
328
|
-
node_props.append("run_id:
|
|
328
|
+
node_props.append("run_id: row.run_id")
|
|
329
329
|
node_props_str = ", ".join(node_props)
|
|
330
330
|
n_embeddings = self.embedding_model.embed_in_batch(node_list)
|
|
331
331
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
"""
|
|
332
|
+
cypher_query = f"""
|
|
333
|
+
UNWIND $rows AS row
|
|
334
|
+
MATCH (n {self.node_label} {{{node_props_str}}})
|
|
335
|
+
WHERE n.embedding IS NOT NULL
|
|
336
|
+
WITH n, row, round(2 * vector.similarity.cosine(n.embedding, row.n_embedding) - 1, 4) AS similarity // denormalize for backward compatibility
|
|
337
|
+
WHERE similarity >= row.threshold
|
|
338
|
+
CALL {{
|
|
339
|
+
WITH n, row
|
|
340
|
+
MATCH (n)-[r]->(m {self.node_label} {{{node_props_str}}})
|
|
341
|
+
RETURN n.name AS source, elementId(n) AS source_id, type(r) AS relationship, elementId(r) AS relation_id, m.name AS destination, elementId(m) AS destination_id
|
|
342
|
+
UNION
|
|
343
|
+
WITH n, row
|
|
344
|
+
MATCH (n)<-[r]-(m {self.node_label} {{{node_props_str}}})
|
|
345
|
+
RETURN m.name AS source, elementId(m) AS source_id, type(r) AS relationship, elementId(r) AS relation_id, n.name AS destination, elementId(n) AS destination_id
|
|
346
|
+
}}
|
|
347
|
+
WITH distinct source, source_id, relationship, relation_id, destination, destination_id, similarity
|
|
348
|
+
RETURN source, source_id, relationship, relation_id, destination, destination_id, similarity
|
|
349
|
+
ORDER BY similarity DESC
|
|
350
|
+
LIMIT {limit}
|
|
351
|
+
"""
|
|
353
352
|
|
|
354
|
-
|
|
353
|
+
rows = []
|
|
354
|
+
for n_embedding in n_embeddings:
|
|
355
|
+
row = {
|
|
355
356
|
"n_embedding": n_embedding,
|
|
356
357
|
"threshold": self.threshold,
|
|
357
358
|
"user_id": filters["user_id"],
|
|
358
|
-
"limit": limit,
|
|
359
359
|
}
|
|
360
360
|
if filters.get("agent_id"):
|
|
361
|
-
|
|
361
|
+
row["agent_id"] = filters["agent_id"]
|
|
362
362
|
if filters.get("run_id"):
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
363
|
+
row["run_id"] = filters["run_id"]
|
|
364
|
+
|
|
365
|
+
rows.append(row)
|
|
366
|
+
|
|
367
|
+
result_relations = self.graph.query(cypher_query, params={"rows": rows})
|
|
367
368
|
|
|
368
369
|
# Remove duplicates, key is (source, relationship, destination)
|
|
369
370
|
seen = set()
|
|
@@ -476,6 +477,16 @@ class MemoryGraph:
|
|
|
476
477
|
agent_id = filters.get("agent_id", None)
|
|
477
478
|
run_id = filters.get("run_id", None)
|
|
478
479
|
results = []
|
|
480
|
+
|
|
481
|
+
# Collect all entities which needs to be embedded
|
|
482
|
+
entities_to_embed = set()
|
|
483
|
+
for item in to_be_added:
|
|
484
|
+
entities_to_embed.add(item["source"])
|
|
485
|
+
entities_to_embed.add(item["destination"])
|
|
486
|
+
entities_to_embed = list(entities_to_embed)
|
|
487
|
+
embeddings = self.embedding_model.embed_in_batch(entities_to_embed)
|
|
488
|
+
embedding_map = {entity: embedding for entity, embedding in zip(entities_to_embed, embeddings)}
|
|
489
|
+
|
|
479
490
|
for item in to_be_added:
|
|
480
491
|
# entities
|
|
481
492
|
source = item["source"]
|
|
@@ -491,12 +502,12 @@ class MemoryGraph:
|
|
|
491
502
|
destination_extra_set = f", destination:`{destination_type}`" if self.node_label else ""
|
|
492
503
|
|
|
493
504
|
# embeddings
|
|
494
|
-
source_embedding =
|
|
495
|
-
dest_embedding =
|
|
505
|
+
source_embedding = embedding_map[source]
|
|
506
|
+
dest_embedding = embedding_map[destination]
|
|
496
507
|
|
|
497
508
|
# search for the nodes with the closest embeddings
|
|
498
|
-
source_node_search_result = self._search_source_node(source_embedding, filters, threshold=
|
|
499
|
-
destination_node_search_result = self._search_destination_node(dest_embedding, filters, threshold=
|
|
509
|
+
source_node_search_result = self._search_source_node(source_embedding, filters, threshold=self.threshold)
|
|
510
|
+
destination_node_search_result = self._search_destination_node(dest_embedding, filters, threshold=self.threshold)
|
|
500
511
|
|
|
501
512
|
# TODO: Create a cypher query and common params for all the cases
|
|
502
513
|
if not destination_node_search_result and source_node_search_result:
|
|
@@ -674,6 +685,7 @@ class MemoryGraph:
|
|
|
674
685
|
item["destination"] = item["destination"].lower().replace(" ", "_")
|
|
675
686
|
return entity_list
|
|
676
687
|
|
|
688
|
+
@time_perf
|
|
677
689
|
def _search_source_node(self, source_embedding, filters, threshold=0.9):
|
|
678
690
|
# Build WHERE conditions
|
|
679
691
|
where_conditions = ["source_candidate.embedding IS NOT NULL", "source_candidate.user_id = $user_id"]
|
|
@@ -711,6 +723,7 @@ class MemoryGraph:
|
|
|
711
723
|
result = self.graph.query(cypher, params=params)
|
|
712
724
|
return result
|
|
713
725
|
|
|
726
|
+
@time_perf
|
|
714
727
|
def _search_destination_node(self, destination_embedding, filters, threshold=0.9):
|
|
715
728
|
# Build WHERE conditions
|
|
716
729
|
where_conditions = ["destination_candidate.embedding IS NOT NULL", "destination_candidate.user_id = $user_id"]
|
|
@@ -1122,6 +1122,7 @@ class AsyncMemory(MemoryBase):
|
|
|
1122
1122
|
|
|
1123
1123
|
return {"results": vector_store_result}
|
|
1124
1124
|
|
|
1125
|
+
@time_perf
|
|
1125
1126
|
async def _add_to_vector_store(
|
|
1126
1127
|
self,
|
|
1127
1128
|
messages: list,
|
|
@@ -1306,6 +1307,7 @@ class AsyncMemory(MemoryBase):
|
|
|
1306
1307
|
)
|
|
1307
1308
|
return returned_memories
|
|
1308
1309
|
|
|
1310
|
+
@time_perf
|
|
1309
1311
|
async def _add_to_graph(self, messages, filters):
|
|
1310
1312
|
added_entities = []
|
|
1311
1313
|
if self.enable_graph:
|
|
@@ -1551,6 +1553,7 @@ class AsyncMemory(MemoryBase):
|
|
|
1551
1553
|
else:
|
|
1552
1554
|
return {"results": original_memories}
|
|
1553
1555
|
|
|
1556
|
+
@time_perf
|
|
1554
1557
|
async def _search_vector_store(self, query, filters, limit, threshold: Optional[float] = None):
|
|
1555
1558
|
embeddings = await asyncio.to_thread(self.embedding_model.embed, query, "search")
|
|
1556
1559
|
memories = await asyncio.to_thread(
|
|
@@ -2,6 +2,7 @@ import re
|
|
|
2
2
|
import time
|
|
3
3
|
import hashlib
|
|
4
4
|
import logging
|
|
5
|
+
import asyncio
|
|
5
6
|
from functools import wraps
|
|
6
7
|
|
|
7
8
|
from mem0.configs.prompts import FACT_RETRIEVAL_PROMPT
|
|
@@ -189,12 +190,23 @@ def sanitize_relationship_for_cypher(relationship) -> str:
|
|
|
189
190
|
|
|
190
191
|
|
|
191
192
|
def time_perf(func):
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
if asyncio.iscoroutinefunction(func):
|
|
194
|
+
@wraps(func)
|
|
195
|
+
async def async_wrapper(*args, **kwargs):
|
|
196
|
+
start = time.perf_counter()
|
|
197
|
+
result = await func(*args, **kwargs)
|
|
198
|
+
end = time.perf_counter()
|
|
199
|
+
elapsed = end - start
|
|
200
|
+
logger.debug(f"[Mem0 time perf][{func.__name__}] executed in {elapsed:.6f} seconds")
|
|
201
|
+
return result
|
|
202
|
+
return async_wrapper
|
|
203
|
+
else:
|
|
204
|
+
@wraps(func)
|
|
205
|
+
def sync_wrapper(*args, **kwargs):
|
|
206
|
+
start = time.perf_counter()
|
|
207
|
+
result = func(*args, **kwargs)
|
|
208
|
+
end = time.perf_counter()
|
|
209
|
+
elapsed = end - start
|
|
210
|
+
logger.debug(f"[Mem0 time perf][{func.__name__}] executed in {elapsed:.6f} seconds")
|
|
211
|
+
return result
|
|
212
|
+
return sync_wrapper
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mem0ai-azure-mysql"
|
|
7
|
-
version = "0.1.116.
|
|
7
|
+
version = "0.1.116.6"
|
|
8
8
|
description = "Long-term memory for AI Agents with Azure DefaultAzureCredential authentication and MySQL history database support"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9,<4.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/embeddings/__init__.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/embeddings/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/anthropic.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/llms/aws_bedrock.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/baidu.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/chroma.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/faiss.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/milvus.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/mongodb.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/pgvector.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/pinecone.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/qdrant.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/redis.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/supabase.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/configs/vector_stores/weaviate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/aws_bedrock.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/embeddings/huggingface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/graphs/neptune/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/azure_openai_structured.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/llms/openai_structured.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/memory/memgraph_memory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/__init__.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/azure_ai_search.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/databricks.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/elasticsearch.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/langchain.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/opensearch.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/pgvector.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/pinecone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/supabase.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/upstash_vector.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.4 → mem0ai_azure_mysql-0.1.116.6}/mem0/vector_stores/weaviate.py
RENAMED
|
File without changes
|