nvidia-nat-mem0ai 1.2.0a20250813__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.
nat/meta/pypi.md ADDED
@@ -0,0 +1,23 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+
18
+ ![NVIDIA NeMo Agent Toolkit](https://media.githubusercontent.com/media/NVIDIA/NeMo-Agent-Toolkit/refs/heads/main/docs/source/_static/aiqtoolkit_banner.png "NeMo Agent toolkit banner image")
19
+
20
+ # NVIDIA NeMo Agent Toolkit Subpackage
21
+ This is a subpackage for Mem0 memory integration in NeMo Agent toolkit.
22
+
23
+ For more information about the NVIDIA NeMo Agent toolkit, please visit the [NeMo Agent toolkit GitHub Repo](https://github.com/NVIDIA/NeMo-Agent-Toolkit).
File without changes
@@ -0,0 +1,112 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import asyncio
17
+
18
+ from mem0 import AsyncMemoryClient
19
+
20
+ from nat.memory.interfaces import MemoryEditor
21
+ from nat.memory.models import MemoryItem
22
+
23
+
24
+ class Mem0Editor(MemoryEditor):
25
+ """
26
+ Wrapper class that implements NAT interfaces for Mem0 Integrations Async.
27
+ """
28
+
29
+ def __init__(self, mem0_client: AsyncMemoryClient):
30
+ """
31
+ Initialize class with Predefined Mem0 Client.
32
+
33
+ Args:
34
+ mem0_client (AsyncMemoryClient): Preinstantiated
35
+ AsyncMemoryClient object for Mem0.
36
+ """
37
+ self._client = mem0_client
38
+
39
+ async def add_items(self, items: list[MemoryItem]) -> None:
40
+ """
41
+ Insert Multiple MemoryItems into the memory.
42
+ Each MemoryItem is translated and uploaded.
43
+ """
44
+
45
+ coroutines = []
46
+
47
+ # Iteratively insert memories into Mem0
48
+ for memory_item in items:
49
+ item_meta = memory_item.metadata
50
+ content = memory_item.conversation
51
+
52
+ user_id = memory_item.user_id # This must be specified
53
+ run_id = item_meta.pop("run_id", None)
54
+ tags = memory_item.tags
55
+
56
+ coroutines.append(
57
+ self._client.add(content,
58
+ user_id=user_id,
59
+ run_id=run_id,
60
+ tags=tags,
61
+ metadata=item_meta,
62
+ output_format="v1.1"))
63
+
64
+ await asyncio.gather(*coroutines)
65
+
66
+ async def search(self, query: str, top_k: int = 5, **kwargs) \
67
+ -> list[MemoryItem]:
68
+ """
69
+ Retrieve items relevant to the given query.
70
+
71
+ Args:
72
+ query (str): The query string to match.
73
+ top_k (int): Maximum number of items to return.
74
+ **kwargs: Other keyword arguments for search.
75
+
76
+ Returns:
77
+ list[MemoryItem]: The most relevant
78
+ MemoryItems for the given query.
79
+ """
80
+
81
+ user_id = kwargs.pop("user_id") # Ensure user ID is in keyword arguments
82
+
83
+ search_result = await self._client.search(query, user_id=user_id, top_k=top_k, output_format="v1.1", **kwargs)
84
+
85
+ # Construct MemoryItem instances
86
+ memories = []
87
+
88
+ for res in search_result["results"]:
89
+ item_meta = res.pop("metadata", {})
90
+
91
+ memories.append(
92
+ MemoryItem(conversation=res.pop("input", []),
93
+ user_id=user_id,
94
+ memory=res["memory"],
95
+ tags=res.pop("categories", []) or [],
96
+ metadata=item_meta))
97
+
98
+ return memories
99
+
100
+ async def remove_items(self, **kwargs):
101
+
102
+ if "memory_id" in kwargs:
103
+
104
+ memory_id = kwargs.pop("memory_id")
105
+ await self._client.delete(memory_id)
106
+
107
+ elif "user_id" in kwargs:
108
+
109
+ user_id = kwargs.pop("user_id")
110
+ await self._client.delete_all(user_id=user_id)
111
+
112
+ return
@@ -0,0 +1,57 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from nat.builder.builder import Builder
17
+ from nat.cli.register_workflow import register_memory
18
+ from nat.data_models.memory import MemoryBaseConfig
19
+ from nat.data_models.retry_mixin import RetryMixin
20
+ from nat.utils.exception_handlers.automatic_retries import patch_with_retry
21
+
22
+
23
+ class Mem0MemoryClientConfig(MemoryBaseConfig, RetryMixin, name="mem0_memory"):
24
+ host: str | None = None
25
+ organization: str | None = None
26
+ project: str | None = None
27
+ org_id: str | None = None
28
+ project_id: str | None = None
29
+
30
+
31
+ @register_memory(config_type=Mem0MemoryClientConfig)
32
+ async def mem0_memory_client(config: Mem0MemoryClientConfig, builder: Builder):
33
+ import os
34
+
35
+ from mem0 import AsyncMemoryClient
36
+
37
+ from nat.plugins.mem0ai.mem0_editor import Mem0Editor
38
+
39
+ mem0_api_key = os.environ.get("MEM0_API_KEY")
40
+
41
+ if mem0_api_key is None:
42
+ raise RuntimeError("Mem0 API key is not set. Please specify it in the environment variable 'MEM0_API_KEY'.")
43
+
44
+ mem0_client = AsyncMemoryClient(api_key=mem0_api_key,
45
+ host=config.host,
46
+ org_id=config.org_id,
47
+ project_id=config.project_id)
48
+
49
+ memory_editor = Mem0Editor(mem0_client=mem0_client)
50
+
51
+ if isinstance(config, RetryMixin):
52
+ memory_editor = patch_with_retry(memory_editor,
53
+ retries=config.num_retries,
54
+ retry_codes=config.retry_on_status_codes,
55
+ retry_on_messages=config.retry_on_errors)
56
+
57
+ yield memory_editor
@@ -0,0 +1,22 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # pylint: disable=unused-import
17
+ # flake8: noqa
18
+ # isort:skip_file
19
+
20
+ # Import any providers which need to be automatically registered here
21
+
22
+ from . import memory
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: nvidia-nat-mem0ai
3
+ Version: 1.2.0a20250813
4
+ Summary: Subpackage for Mem0 integration in NeMo Agent toolkit
5
+ Keywords: ai,agents,memory
6
+ Classifier: Programming Language :: Python
7
+ Requires-Python: <3.13,>=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: nvidia-nat==v1.2.0a20250813
10
+ Requires-Dist: mem0ai~=0.1.30
11
+
12
+ <!--
13
+ SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
14
+ SPDX-License-Identifier: Apache-2.0
15
+
16
+ Licensed under the Apache License, Version 2.0 (the "License");
17
+ you may not use this file except in compliance with the License.
18
+ You may obtain a copy of the License at
19
+
20
+ http://www.apache.org/licenses/LICENSE-2.0
21
+
22
+ Unless required by applicable law or agreed to in writing, software
23
+ distributed under the License is distributed on an "AS IS" BASIS,
24
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ See the License for the specific language governing permissions and
26
+ limitations under the License.
27
+ -->
28
+
29
+ ![NVIDIA NeMo Agent Toolkit](https://media.githubusercontent.com/media/NVIDIA/NeMo-Agent-Toolkit/refs/heads/main/docs/source/_static/aiqtoolkit_banner.png "NeMo Agent toolkit banner image")
30
+
31
+ # NVIDIA NeMo Agent Toolkit Subpackage
32
+ This is a subpackage for Mem0 memory integration in NeMo Agent toolkit.
33
+
34
+ For more information about the NVIDIA NeMo Agent toolkit, please visit the [NeMo Agent toolkit GitHub Repo](https://github.com/NVIDIA/NeMo-Agent-Toolkit).
@@ -0,0 +1,10 @@
1
+ nat/meta/pypi.md,sha256=M3fUU11Pxni0woH-GJUeaKcy2lQE3OLNhjDqU-lO244,1123
2
+ nat/plugins/mem0ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nat/plugins/mem0ai/mem0_editor.py,sha256=8BKaUia8VLW_NRYHQgFKyqX5EAoDTwmlBxck0JhIv7I,3647
4
+ nat/plugins/mem0ai/memory.py,sha256=-uO0kcuCpAXrRZnzU2dfM5yHm87go4nOhBUZ03i9Qtk,2291
5
+ nat/plugins/mem0ai/register.py,sha256=_ffKNKnMfkB2HzX4Nk_9EW0pwebg3GuzAE-iB-CoC3E,839
6
+ nvidia_nat_mem0ai-1.2.0a20250813.dist-info/METADATA,sha256=qF1RtPdEI8HNR2gp1F73HXptQZcI5xRrbDw7pnpjVGY,1470
7
+ nvidia_nat_mem0ai-1.2.0a20250813.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ nvidia_nat_mem0ai-1.2.0a20250813.dist-info/entry_points.txt,sha256=3eEklM2ToRyptUsWn00bINNml1FWTMaEZlNq29G4SjQ,58
9
+ nvidia_nat_mem0ai-1.2.0a20250813.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
10
+ nvidia_nat_mem0ai-1.2.0a20250813.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [nat.components]
2
+ nat_mem0ai = nat.plugins.mem0ai.register