deepagents-graph-memory 0.1.1__cp313-cp313-win_amd64.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.
Files changed (43) hide show
  1. deepagents_graph_memory/__init__.py +32 -0
  2. deepagents_graph_memory/_runtime.py +67 -0
  3. deepagents_graph_memory/_vendor/__init__.py +1 -0
  4. deepagents_graph_memory/_vendor/ladybug/__init__.py +106 -0
  5. deepagents_graph_memory/_vendor/ladybug/_backend.py +43 -0
  6. deepagents_graph_memory/_vendor/ladybug/_lbug.cp313-win_amd64.pyd +0 -0
  7. deepagents_graph_memory/_vendor/ladybug/_lbug.exp +0 -0
  8. deepagents_graph_memory/_vendor/ladybug/_lbug.lib +0 -0
  9. deepagents_graph_memory/_vendor/ladybug/_lbug_capi.py +2415 -0
  10. deepagents_graph_memory/_vendor/ladybug/async_connection.py +234 -0
  11. deepagents_graph_memory/_vendor/ladybug/connection.py +1276 -0
  12. deepagents_graph_memory/_vendor/ladybug/constants.py +7 -0
  13. deepagents_graph_memory/_vendor/ladybug/database.py +411 -0
  14. deepagents_graph_memory/_vendor/ladybug/prepared_statement.py +77 -0
  15. deepagents_graph_memory/_vendor/ladybug/py.typed +0 -0
  16. deepagents_graph_memory/_vendor/ladybug/query_result.py +585 -0
  17. deepagents_graph_memory/_vendor/ladybug/torch_geometric_feature_store.py +201 -0
  18. deepagents_graph_memory/_vendor/ladybug/torch_geometric_graph_store.py +131 -0
  19. deepagents_graph_memory/_vendor/ladybug/torch_geometric_result_converter.py +313 -0
  20. deepagents_graph_memory/_vendor/ladybug/types.py +46 -0
  21. deepagents_graph_memory/_vendor/ladybug.libs/msvcp140-20076bc0e3fcb1842cab77dfe8ef816b.dll +0 -0
  22. deepagents_graph_memory/_vendor/libfts.dll +0 -0
  23. deepagents_graph_memory/_vendor/licenses/LICENSE +22 -0
  24. deepagents_graph_memory/backend.py +838 -0
  25. deepagents_graph_memory/errors.py +21 -0
  26. deepagents_graph_memory/ladybug_store.py +848 -0
  27. deepagents_graph_memory/paths.py +253 -0
  28. deepagents_graph_memory/py.typed +1 -0
  29. deepagents_graph_memory/recall.py +936 -0
  30. deepagents_graph_memory/renderers.py +199 -0
  31. deepagents_graph_memory/stores.py +378 -0
  32. deepagents_graph_memory/tools.py +193 -0
  33. deepagents_graph_memory/vgs.py +210 -0
  34. deepagents_graph_memory-0.1.1.dist-info/DELVEWHEEL +2 -0
  35. deepagents_graph_memory-0.1.1.dist-info/METADATA +135 -0
  36. deepagents_graph_memory-0.1.1.dist-info/RECORD +43 -0
  37. deepagents_graph_memory-0.1.1.dist-info/WHEEL +5 -0
  38. deepagents_graph_memory-0.1.1.dist-info/licenses/LICENSE +21 -0
  39. deepagents_graph_memory-0.1.1.dist-info/licenses/licenses/OpenSSL.txt +177 -0
  40. deepagents_graph_memory-0.1.1.dist-info/top_level.txt +1 -0
  41. deepagents_graph_memory.libs/libcrypto-3-x64-a7f745cad9209c33db5de9d6a5efc80a.dll +0 -0
  42. deepagents_graph_memory.libs/libssl-3-x64-b505f4b93cb419c84f6d7666ed4c76c4.dll +0 -0
  43. deepagents_graph_memory.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
@@ -0,0 +1,32 @@
1
+ # - Gives apps one place to import the main graph features.
2
+ # - Tests: test_vgs.py checks the public graph setup helpers;
3
+ # test_optional_vgs_dependency.py checks what happens without LadybugDB.
4
+
5
+ """Graph-backed memory backend for LangChain Deep Agents."""
6
+
7
+
8
+ # start delvewheel patch
9
+ def _delvewheel_patch_1_13_1():
10
+ import os
11
+ if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'deepagents_graph_memory.libs'))):
12
+ os.add_dll_directory(libs_dir)
13
+
14
+
15
+ _delvewheel_patch_1_13_1()
16
+ del _delvewheel_patch_1_13_1
17
+ # end delvewheel patch
18
+
19
+ from deepagents_graph_memory.backend import GraphMemoryBackend
20
+ from deepagents_graph_memory.paths import make_graph_subject
21
+ from deepagents_graph_memory.tools import graph_memory_tools
22
+ from deepagents_graph_memory.vgs import VFS_TOOL_NAMES, graph_context_middleware, register_vgs_harness_profile, vgs_harness_profile
23
+
24
+ __all__ = [
25
+ "GraphMemoryBackend",
26
+ "VFS_TOOL_NAMES",
27
+ "graph_context_middleware",
28
+ "graph_memory_tools",
29
+ "make_graph_subject",
30
+ "register_vgs_harness_profile",
31
+ "vgs_harness_profile",
32
+ ]
@@ -0,0 +1,67 @@
1
+ """Load the bundled runtime under Ladybug's canonical native module name."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import ctypes
6
+ import sys
7
+ from functools import cache
8
+ from importlib.abc import MetaPathFinder
9
+ from importlib.util import spec_from_file_location
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from deepagents_graph_memory.errors import GraphMemoryConfigurationError
14
+
15
+ _VENDOR = Path(__file__).resolve().parent / "_vendor"
16
+
17
+
18
+ class _BundledLadybug(MetaPathFinder):
19
+ def find_spec(self, fullname: str, path: Any = None, target: Any = None) -> Any:
20
+ if fullname == "ladybug":
21
+ return spec_from_file_location(fullname, _VENDOR / "ladybug" / "__init__.py")
22
+ return None
23
+
24
+
25
+ def load_ladybug() -> Any:
26
+ """Use one module identity, including when standalone Ladybug was imported first."""
27
+ if not (_VENDOR / "ladybug").is_dir():
28
+ # Source/editable development uses the explicitly installed test dependency.
29
+ import ladybug
30
+
31
+ return ladybug
32
+ finder = _BundledLadybug()
33
+ sys.meta_path.insert(0, finder)
34
+ try:
35
+ import ladybug as module
36
+ finally:
37
+ sys.meta_path.remove(finder)
38
+ if module.Database.get_version() != "0.20.3":
39
+ msg = "Graph memory bundles LadybugDB 0.20.3; another Ladybug version is already loaded. Use a separate process."
40
+ raise ImportError(msg)
41
+ return module
42
+
43
+
44
+ @cache
45
+ def _preload_windows_fts(path: Path) -> Any:
46
+ # Ladybug uses LoadLibraryW, which ignores Python's added DLL directories.
47
+ # ctypes uses LoadLibraryEx with secure search flags; retain its handle.
48
+ return ctypes.CDLL(str(path))
49
+
50
+
51
+ def fts_load_query() -> str:
52
+ """Load the wheel's FTS binary directly, without using a user extension cache."""
53
+ name = "libfts.dll" if sys.platform == "win32" else "libfts.so"
54
+ path = _VENDOR / name
55
+ if not (_VENDOR / "ladybug").is_dir():
56
+ return "LOAD fts;"
57
+ if not path.is_file():
58
+ msg = "Bundled LadybugDB search extension is missing; reinstall deepagents-graph-memory."
59
+ raise GraphMemoryConfigurationError(msg)
60
+ if sys.platform == "win32":
61
+ try:
62
+ _preload_windows_fts(path)
63
+ except OSError as exc:
64
+ msg = "Bundled LadybugDB search dependencies could not load; reinstall deepagents-graph-memory."
65
+ raise GraphMemoryConfigurationError(msg) from exc
66
+ escaped = path.as_posix().replace("\\", "\\\\").replace("'", "\\'")
67
+ return f"LOAD EXTENSION '{escaped}';"
@@ -0,0 +1 @@
1
+ """Unmodified, pinned LadybugDB runtime; populated during wheel builds."""
@@ -0,0 +1,106 @@
1
+ # ruff: noqa
2
+ """
3
+ # Lbug Python API bindings.
4
+
5
+ This package provides a Python API for Lbug graph database management system.
6
+
7
+ To install the package, run:
8
+ ```
9
+ python3 -m pip install ladybug
10
+ ```
11
+
12
+ Example usage:
13
+ ```python
14
+ import ladybug as lb
15
+
16
+ db = lb.Database("./test")
17
+ conn = lb.Connection(db)
18
+
19
+ # Define the schema
20
+ conn.execute("CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))")
21
+ conn.execute("CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))")
22
+ conn.execute("CREATE REL TABLE Follows(FROM User TO User, since INT64)")
23
+ conn.execute("CREATE REL TABLE LivesIn(FROM User TO City)")
24
+
25
+ # Load some data
26
+ conn.execute('COPY User FROM "user.csv"')
27
+ conn.execute('COPY City FROM "city.csv"')
28
+ conn.execute('COPY Follows FROM "follows.csv"')
29
+ conn.execute('COPY LivesIn FROM "lives-in.csv"')
30
+
31
+ # Query the data
32
+ results = conn.execute("MATCH (u:User) RETURN u.name, u.age;")
33
+ while results.has_next():
34
+ print(results.get_next())
35
+ ```
36
+
37
+ The dataset used in this example can be found [here](https://github.com/LadybugDB/ladybug/tree/master/dataset/demo-db/csv).
38
+
39
+ """
40
+
41
+ from __future__ import annotations
42
+
43
+
44
+ # start delvewheel patch
45
+ def _delvewheel_patch_1_13_1():
46
+ import os
47
+ if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'ladybug.libs'))):
48
+ os.add_dll_directory(libs_dir)
49
+
50
+
51
+ _delvewheel_patch_1_13_1()
52
+ del _delvewheel_patch_1_13_1
53
+ # end delvewheel patch
54
+
55
+ from pathlib import Path
56
+
57
+ # In local dev/test runs the optional pybind extension is built under build/ladybug
58
+ # while the package sources live in src_py. Extend the package path so
59
+ # `from . import _lbug` can discover the built extension without installation.
60
+ _pkg_dir = Path(__file__).resolve().parent
61
+ _repo_build_pkg_dir = _pkg_dir.parent / "build" / "ladybug"
62
+ if _repo_build_pkg_dir.is_dir():
63
+ __path__.append(str(_repo_build_pkg_dir))
64
+
65
+ from ._backend import get_capi_module, get_pybind_module # noqa: E402
66
+
67
+ from .async_connection import AsyncConnection # noqa: E402
68
+ from .connection import Connection # noqa: E402
69
+ from .database import Database # noqa: E402
70
+ from .prepared_statement import PreparedStatement # noqa: E402
71
+ from .query_result import ArrowQueryResult, CSRResult, QueryResult # noqa: E402
72
+ from .types import ArrowRelTableLayout, Type # noqa: E402
73
+
74
+ _VERSION_INFO: tuple[str, int] | None = None
75
+
76
+
77
+ def _get_version_info() -> tuple[str, int]:
78
+ global _VERSION_INFO
79
+ if _VERSION_INFO is None:
80
+ _VERSION_INFO = (Database.get_version(), Database.get_storage_version())
81
+ return _VERSION_INFO
82
+
83
+
84
+ def __getattr__(name: str) -> str | int:
85
+ if name == "version" or name == "__version__":
86
+ return _get_version_info()[0]
87
+ if name == "storage_version":
88
+ return _get_version_info()[1]
89
+ msg = f"module {__name__!r} has no attribute {name!r}"
90
+ raise AttributeError(msg)
91
+
92
+
93
+ __all__ = [
94
+ "AsyncConnection",
95
+ "ArrowQueryResult",
96
+ "ArrowRelTableLayout",
97
+ "Connection",
98
+ "CSRResult",
99
+ "Database",
100
+ "PreparedStatement",
101
+ "QueryResult",
102
+ "Type",
103
+ "__version__", # noqa: F822
104
+ "storage_version", # noqa: F822
105
+ "version", # noqa: F822
106
+ ]
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ from importlib import import_module
6
+ from typing import Any
7
+
8
+ _CAPI_MODULE: Any | None = None
9
+ _PYBIND_MODULE: Any | None = None
10
+ _PYBIND_IMPORT_ATTEMPTED = False
11
+
12
+
13
+ def _import_pybind_module() -> Any:
14
+ if sys.platform != "linux":
15
+ return import_module("._lbug", __package__)
16
+
17
+ original_dlopen_flags = sys.getdlopenflags()
18
+ try:
19
+ # Keep pybind's symbols visible to any transitive native extensions
20
+ # without affecting the process-wide import path for the C-API backend.
21
+ sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_LAZY)
22
+ return import_module("._lbug", __package__)
23
+ finally:
24
+ sys.setdlopenflags(original_dlopen_flags)
25
+
26
+
27
+ def get_capi_module() -> Any:
28
+ global _CAPI_MODULE
29
+ if _CAPI_MODULE is None:
30
+ _CAPI_MODULE = import_module("._lbug_capi", __package__)
31
+ return _CAPI_MODULE
32
+
33
+
34
+ def get_pybind_module() -> Any | None:
35
+ global _PYBIND_MODULE, _PYBIND_IMPORT_ATTEMPTED
36
+ if _PYBIND_IMPORT_ATTEMPTED:
37
+ return _PYBIND_MODULE
38
+ _PYBIND_IMPORT_ATTEMPTED = True
39
+ try:
40
+ _PYBIND_MODULE = _import_pybind_module()
41
+ except ImportError:
42
+ _PYBIND_MODULE = None
43
+ return _PYBIND_MODULE