mem0ai-azure-mysql 0.1.116.1__tar.gz → 0.1.116.3__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.1 → mem0ai_azure_mysql-0.1.116.3}/PKG-INFO +2 -1
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/configs.py +18 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/graph_memory.py +70 -10
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/pyproject.toml +3 -2
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/.gitignore +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/README.md +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/client/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/client/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/client/project.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/client/utils.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/dbs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/dbs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/dbs/mysql.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/embeddings/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/embeddings/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/enums.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/anthropic.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/azure.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/deepseek.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/vllm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/prompts.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/azure_ai_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/baidu.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/chroma.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/databricks.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/elasticsearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/faiss.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/milvus.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/mongodb.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/opensearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/pgvector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/pinecone.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/qdrant.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/redis.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/supabase.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/upstash_vector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/vertex_ai_vector_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/weaviate.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/dbs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/dbs/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/dbs/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/dbs/mysql.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/azure_openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/gemini.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/huggingface.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/mock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/together.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/vertexai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/neptune/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/neptune/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/neptune/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/tools.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/graphs/utils.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/anthropic.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/aws_bedrock.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/azure_openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/azure_openai_structured.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/deepseek.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/gemini.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/groq.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/litellm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/lmstudio.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/ollama.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/openai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/openai_structured.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/sarvam.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/together.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/vllm.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/llms/xai.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/kuzu_memory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/memgraph_memory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/setup.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/storage.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/telemetry.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/memory/utils.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/proxy/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/proxy/main.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/utils/factory.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/__init__.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/azure_ai_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/baidu.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/base.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/chroma.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/configs.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/databricks.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/elasticsearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/faiss.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/langchain.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/milvus.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/mongodb.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/opensearch.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/pgvector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/pinecone.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/qdrant.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/redis.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/supabase.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/upstash_vector.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/vertex_ai_vector_search.py +0 -0
- {mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/weaviate.py +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mem0ai-azure-mysql
|
|
3
|
-
Version: 0.1.116.
|
|
3
|
+
Version: 0.1.116.3
|
|
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
|
|
7
7
|
Requires-Dist: azure-search-documents>=11.5.3
|
|
8
|
+
Requires-Dist: cohere>=5.17.0
|
|
8
9
|
Requires-Dist: langchain-neo4j>=0.4.0
|
|
9
10
|
Requires-Dist: openai<1.100.0,>=1.90.0
|
|
10
11
|
Requires-Dist: posthog>=3.5.0
|
|
@@ -5,12 +5,24 @@ from pydantic import BaseModel, Field, field_validator, model_validator
|
|
|
5
5
|
from mem0.llms.configs import LlmConfig
|
|
6
6
|
|
|
7
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
|
+
|
|
8
17
|
class Neo4jConfig(BaseModel):
|
|
9
18
|
url: Optional[str] = Field(None, description="Host address for the graph database")
|
|
10
19
|
username: Optional[str] = Field(None, description="Username for the graph database")
|
|
11
20
|
password: Optional[str] = Field(None, description="Password for the graph database")
|
|
12
21
|
database: Optional[str] = Field(None, description="Database for the graph database")
|
|
13
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")
|
|
14
26
|
|
|
15
27
|
@model_validator(mode="before")
|
|
16
28
|
def check_host_port_or_path(cls, values):
|
|
@@ -21,6 +33,12 @@ class Neo4jConfig(BaseModel):
|
|
|
21
33
|
)
|
|
22
34
|
if not url or not username or not password:
|
|
23
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
|
+
|
|
24
42
|
return values
|
|
25
43
|
|
|
26
44
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
import cohere
|
|
2
5
|
|
|
3
6
|
from mem0.memory.utils import format_entities, sanitize_relationship_for_cypher
|
|
4
7
|
|
|
@@ -70,7 +73,8 @@ class MemoryGraph:
|
|
|
70
73
|
llm_config = self.config.llm.config
|
|
71
74
|
self.llm = LlmFactory.create(self.llm_provider, llm_config)
|
|
72
75
|
self.user_id = None
|
|
73
|
-
self.threshold =
|
|
76
|
+
self.threshold = self.config.graph_store.config.similarity_threshold
|
|
77
|
+
self.top_k = self.config.graph_store.config.top_k
|
|
74
78
|
|
|
75
79
|
def add(self, data, filters):
|
|
76
80
|
"""
|
|
@@ -106,28 +110,75 @@ class MemoryGraph:
|
|
|
106
110
|
- "contexts": List of search results from the base data store.
|
|
107
111
|
- "entities": List of related graph data based on the query.
|
|
108
112
|
"""
|
|
113
|
+
start_time = time.perf_counter()
|
|
114
|
+
logger.info(f"Searching for query in neo4j: {query} with filters: {filters}")
|
|
109
115
|
entity_type_map = self._retrieve_nodes_from_data(query, filters)
|
|
110
116
|
search_output = self._search_graph_db(node_list=list(entity_type_map.keys()), filters=filters)
|
|
117
|
+
print(f'entity_type_map: {entity_type_map}')
|
|
118
|
+
print(f'search_output: {search_output}')
|
|
111
119
|
|
|
112
120
|
if not search_output:
|
|
113
121
|
return []
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
[item["source"], item["relationship"], item["destination"]] for item in search_output
|
|
117
|
-
]
|
|
118
|
-
bm25 = BM25Okapi(search_outputs_sequence)
|
|
119
|
-
|
|
120
|
-
tokenized_query = query.split(" ")
|
|
121
|
-
reranked_results = bm25.get_top_n(tokenized_query, search_outputs_sequence, n=5)
|
|
123
|
+
reranked_results = self.rerank(search_output, query)
|
|
122
124
|
|
|
123
125
|
search_results = []
|
|
124
126
|
for item in reranked_results:
|
|
125
|
-
search_results.append(
|
|
127
|
+
search_results.append(
|
|
128
|
+
{
|
|
129
|
+
"source": item[0],
|
|
130
|
+
"relationship": item[1],
|
|
131
|
+
"destination": item[2],
|
|
132
|
+
"score": item[3] if len(item) > 3 else 0.0,
|
|
133
|
+
}
|
|
134
|
+
)
|
|
126
135
|
|
|
127
136
|
logger.info(f"Returned {len(search_results)} search results")
|
|
128
137
|
|
|
138
|
+
end_time = time.perf_counter()
|
|
139
|
+
# print milliseconds
|
|
140
|
+
print(f"Search took {(end_time - start_time) * 1000:.2f} ms")
|
|
141
|
+
|
|
129
142
|
return search_results
|
|
130
143
|
|
|
144
|
+
def rerank(self, search_output, query):
|
|
145
|
+
if not self.config.graph_store.config.rerank:
|
|
146
|
+
search_outputs_sequence = [
|
|
147
|
+
[item["source"], item["relationship"], item["destination"]] for item in search_output
|
|
148
|
+
]
|
|
149
|
+
bm25 = BM25Okapi(search_outputs_sequence)
|
|
150
|
+
|
|
151
|
+
tokenized_query = query.split(" ")
|
|
152
|
+
return bm25.get_top_n(tokenized_query, search_outputs_sequence, n=5)
|
|
153
|
+
|
|
154
|
+
# Only cohere is supported for now
|
|
155
|
+
rerank_config = self.config.graph_store.config.rerank.config
|
|
156
|
+
co = cohere.ClientV2(
|
|
157
|
+
api_key=rerank_config.get("api_key"),
|
|
158
|
+
base_url=rerank_config.get("base_url"),
|
|
159
|
+
)
|
|
160
|
+
docs = [f'{item["source"]} {item["relationship"]} {item["destination"]}' for item in search_output]
|
|
161
|
+
print(f'docs: {docs}')
|
|
162
|
+
response = co.rerank(
|
|
163
|
+
model=rerank_config.get("model"),
|
|
164
|
+
query=query,
|
|
165
|
+
documents=docs,
|
|
166
|
+
top_n=self.top_k,
|
|
167
|
+
)
|
|
168
|
+
print(f'response.results: {response.results}')
|
|
169
|
+
|
|
170
|
+
reranked_results = []
|
|
171
|
+
for result in response.results:
|
|
172
|
+
original_output = search_output[result.index]
|
|
173
|
+
reranked_results.append([
|
|
174
|
+
original_output["source"],
|
|
175
|
+
original_output["relationship"],
|
|
176
|
+
original_output["destination"],
|
|
177
|
+
result.relevance_score
|
|
178
|
+
])
|
|
179
|
+
print(f'reranked_results: {reranked_results}')
|
|
180
|
+
return reranked_results
|
|
181
|
+
|
|
131
182
|
def delete_all(self, filters):
|
|
132
183
|
# Build node properties for filtering
|
|
133
184
|
node_props = ["user_id: $user_id"]
|
|
@@ -316,7 +367,16 @@ class MemoryGraph:
|
|
|
316
367
|
ans = self.graph.query(cypher_query, params=params)
|
|
317
368
|
result_relations.extend(ans)
|
|
318
369
|
|
|
319
|
-
|
|
370
|
+
# Remove duplicates, key is (source, relationship, destination)
|
|
371
|
+
seen = set()
|
|
372
|
+
unique_relations = []
|
|
373
|
+
for rel in result_relations:
|
|
374
|
+
key = (rel["source"], rel["relationship"], rel["destination"])
|
|
375
|
+
if key not in seen:
|
|
376
|
+
seen.add(key)
|
|
377
|
+
unique_relations.append(rel)
|
|
378
|
+
|
|
379
|
+
return unique_relations
|
|
320
380
|
|
|
321
381
|
def _get_delete_entities_from_search_output(self, search_output, data, filters):
|
|
322
382
|
"""Get the entities to be deleted from the search output."""
|
|
@@ -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.3"
|
|
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"
|
|
@@ -20,7 +20,8 @@ dependencies = [
|
|
|
20
20
|
"azure-search-documents>=11.5.3",
|
|
21
21
|
"pymysql",
|
|
22
22
|
"langchain-neo4j>=0.4.0",
|
|
23
|
-
"rank-bm25>=0.2.2"
|
|
23
|
+
"rank-bm25>=0.2.2",
|
|
24
|
+
"cohere>=5.17.0",
|
|
24
25
|
]
|
|
25
26
|
|
|
26
27
|
[project.optional-dependencies]
|
|
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.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/embeddings/__init__.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/embeddings/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/llms/anthropic.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/baidu.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/chroma.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/faiss.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/milvus.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/mongodb.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/pgvector.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/pinecone.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/qdrant.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/redis.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/configs/vector_stores/supabase.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/aws_bedrock.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/embeddings/azure_openai.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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.1 → mem0ai_azure_mysql-0.1.116.3}/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.1 → mem0ai_azure_mysql-0.1.116.3}/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
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/__init__.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/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.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/databricks.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/elasticsearch.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/langchain.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/opensearch.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/pgvector.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/pinecone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/supabase.py
RENAMED
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/upstash_vector.py
RENAMED
|
File without changes
|
|
File without changes
|
{mem0ai_azure_mysql-0.1.116.1 → mem0ai_azure_mysql-0.1.116.3}/mem0/vector_stores/weaviate.py
RENAMED
|
File without changes
|