gllm-datastore-binary 0.0.15__cp311-cp311-macosx_13_0_x86_64.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.

Potentially problematic release.


This version of gllm-datastore-binary might be problematic. Click here for more details.

Files changed (38) hide show
  1. gllm_datastore/__init__.pyi +0 -0
  2. gllm_datastore/cache_data_store/__init__.pyi +5 -0
  3. gllm_datastore/cache_data_store/cache_data_store.pyi +146 -0
  4. gllm_datastore/cache_data_store/cache_data_store_utils.pyi +1 -0
  5. gllm_datastore/cache_data_store/file_system_cache_data_store.pyi +62 -0
  6. gllm_datastore/cache_data_store/in_memory_cache_data_store.pyi +43 -0
  7. gllm_datastore/cache_data_store/redis_cache_data_store.pyi +48 -0
  8. gllm_datastore/cache_data_store/utils.pyi +36 -0
  9. gllm_datastore/constants.pyi +2 -0
  10. gllm_datastore/graph_data_store/__init__.pyi +0 -0
  11. gllm_datastore/graph_data_store/graph_data_store.pyi +80 -0
  12. gllm_datastore/graph_data_store/graph_rag_data_store.pyi +28 -0
  13. gllm_datastore/graph_data_store/llama_index_graph_rag_data_store.pyi +18 -0
  14. gllm_datastore/graph_data_store/llama_index_neo4j_graph_rag_data_store.pyi +26 -0
  15. gllm_datastore/graph_data_store/nebula_graph_data_store.pyi +112 -0
  16. gllm_datastore/graph_data_store/neo4j_graph_data_store.pyi +81 -0
  17. gllm_datastore/sql_data_store/__init__.pyi +5 -0
  18. gllm_datastore/sql_data_store/adapter/__init__.pyi +0 -0
  19. gllm_datastore/sql_data_store/adapter/sqlalchemy_adapter.pyi +30 -0
  20. gllm_datastore/sql_data_store/constants.pyi +6 -0
  21. gllm_datastore/sql_data_store/sql_data_store.pyi +87 -0
  22. gllm_datastore/sql_data_store/sqlalchemy_data_store.pyi +9 -0
  23. gllm_datastore/sql_data_store/sqlalchemy_sql_data_store.pyi +183 -0
  24. gllm_datastore/sql_data_store/types.pyi +30 -0
  25. gllm_datastore/utils/__init__.pyi +4 -0
  26. gllm_datastore/utils/converter.pyi +21 -0
  27. gllm_datastore/utils/ttl.pyi +25 -0
  28. gllm_datastore/vector_data_store/__init__.pyi +4 -0
  29. gllm_datastore/vector_data_store/chroma_vector_data_store.pyi +119 -0
  30. gllm_datastore/vector_data_store/elasticsearch_data_store.pyi +9 -0
  31. gllm_datastore/vector_data_store/elasticsearch_vector_data_store.pyi +140 -0
  32. gllm_datastore/vector_data_store/vector_data_store.pyi +73 -0
  33. gllm_datastore.build/.gitignore +1 -0
  34. gllm_datastore.cpython-311-darwin.so +0 -0
  35. gllm_datastore.pyi +63 -0
  36. gllm_datastore_binary-0.0.15.dist-info/METADATA +98 -0
  37. gllm_datastore_binary-0.0.15.dist-info/RECORD +38 -0
  38. gllm_datastore_binary-0.0.15.dist-info/WHEEL +4 -0
File without changes
@@ -0,0 +1,5 @@
1
+ from gllm_datastore.cache_data_store.file_system_cache_data_store import FileSystemCacheDataStore as FileSystemCacheDataStore
2
+ from gllm_datastore.cache_data_store.in_memory_cache_data_store import InMemoryCacheDataStore as InMemoryCacheDataStore
3
+ from gllm_datastore.cache_data_store.redis_cache_data_store import RedisCacheDataStore as RedisCacheDataStore
4
+
5
+ __all__ = ['FileSystemCacheDataStore', 'InMemoryCacheDataStore', 'RedisCacheDataStore']
@@ -0,0 +1,146 @@
1
+ import abc
2
+ from _typeshed import Incomplete
3
+ from abc import ABC, abstractmethod
4
+ from enum import StrEnum
5
+ from gllm_datastore.cache_data_store.utils import generate_key_from_func as generate_key_from_func
6
+ from gllm_datastore.utils import convert_ttl_to_seconds as convert_ttl_to_seconds
7
+ from typing import Any, Callable, ParamSpec, TypeVar
8
+
9
+ P = ParamSpec('P')
10
+ T = TypeVar('T')
11
+
12
+ class CacheMatchingStrategy(StrEnum):
13
+ """An enumeration of cache matching strategies.
14
+
15
+ Attributes:
16
+ EXACT (str): The cache key must match the query exactly.
17
+ FUZZY (str): The cache key must match the query with fuzzy matching.
18
+ """
19
+ EXACT = 'exact'
20
+ FUZZY = 'fuzzy'
21
+
22
+ class BaseCacheDataStore(ABC, metaclass=abc.ABCMeta):
23
+ """A base class for cache data store used in Gen AI applications.
24
+
25
+ The `BaseCacheDataStore` class provides a framework for storing and retrieving cache data.
26
+
27
+ Attributes:
28
+ retrieval_method (Callable[[str], Any]): The method to retrieve cache data based on the matching strategy.
29
+ fuzzy_distance_ratio (float): The ratio of key length to use as maximum Levenshtein distance
30
+ for fuzzy matching (e.g., 0.1 means 10% of key length). Must be between 0 and 1.
31
+
32
+ Supported matching strategies:
33
+ 1. EXACT
34
+ The cache matches when the key is an exact match.
35
+ 2. FUZZY
36
+ The cache matches when the key has a Levenshtein distance of less than or equal to the maximum allowed
37
+ distance. The maximum allowed distance is calculated by multiplying the `fuzzy_distance_ratio` with the key
38
+ length. Since the fuzzy matching heavily depends on the syntactic similarity between the key and the cached
39
+ key, it should only be used when the key is a plain string. Fuzzy matching SHOULD NOT be used when the key
40
+ is a hash / encryption of the input data.
41
+ """
42
+ retrieval_method: Incomplete
43
+ fuzzy_distance_ratio: Incomplete
44
+ def __init__(self, matching_strategy: CacheMatchingStrategy = ..., fuzzy_distance_ratio: float = 0.05) -> None:
45
+ """Initialize a new instance of the `BaseCacheDataStore` class.
46
+
47
+ Args:
48
+ matching_strategy (CacheMatchingStrategy, optional): The matching strategy to use.
49
+ Defaults to CacheMatchingStrategy.EXACT.
50
+ fuzzy_distance_ratio (float, optional): The ratio of key length to use as maximum Levenshtein distance
51
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1. Defaults to 0.05.
52
+
53
+ Raises:
54
+ ValueError: If the matching strategy is not supported or if fuzzy_distance_ratio is not between 0 and 1.
55
+ """
56
+ def store(self, key: str, value: Any, ttl: int | str | None = None) -> None:
57
+ '''Stores cache data in the storage.
58
+
59
+ This method preprocesses the TTL (time-to-live) value to seconds if provided, and then calls the `_store`
60
+ method to store the cache data in the storage.
61
+
62
+ Args:
63
+ key (str): The key to store the cache data.
64
+ value (Any): The cache data to store.
65
+ ttl (int | str | None): The time-to-live (TTL) for the cache data. Must either be an integer in seconds
66
+ or a string (e.g. "1h", "1d", "1w", "1y"). If None, the cache data will not expire.
67
+ '''
68
+ def retrieve(self, key: str) -> Any:
69
+ """Retrieves cache data from the storage.
70
+
71
+ Args:
72
+ key (str): The key to retrieve the cache data.
73
+
74
+ Returns:
75
+ Any: The retrieved cache data.
76
+ """
77
+ @abstractmethod
78
+ def retrieve_all_keys(self) -> list[str]:
79
+ """Retrieves all keys from the storage.
80
+
81
+ This method must be implemented by the subclasses to define the logic for retrieving all keys from the storage.
82
+
83
+ Returns:
84
+ list[str]: A list of all keys in the storage.
85
+
86
+ Raises:
87
+ NotImplementedError: If the method is not implemented.
88
+ """
89
+ @abstractmethod
90
+ def delete(self, key: str | list[str]) -> None:
91
+ """Deletes cache data from the storage.
92
+
93
+ This method must be implemented by the subclasses to define the logic for deleting cache data from the storage.
94
+
95
+ Args:
96
+ key (str | list[str] | None): The key(s) to delete the cache data.
97
+
98
+ Raises:
99
+ NotImplementedError: If the method is not implemented.
100
+ """
101
+ @abstractmethod
102
+ def clear(self) -> None:
103
+ """Clears all cache data from the storage.
104
+
105
+ This method must be implemented by the subclasses to define the logic for clearing all cache data from the
106
+ storage.
107
+
108
+ Args:
109
+ None
110
+
111
+ Raises:
112
+ NotImplementedError: If the method is not implemented.
113
+ """
114
+ def cache(self, key_func: Callable[P, str] | None = None, name: str = '', ttl: int | str | None = None) -> Callable[[Callable[P, T]], Callable[P, T]]:
115
+ '''Decorator for caching function results.
116
+
117
+ This decorator caches the results of the decorated function using this cache storage.
118
+ The cache key is generated using the provided key function or a default key generation
119
+ based on the function name and arguments.
120
+
121
+ Synchronous and asynchronous functions are supported.
122
+
123
+ Args:
124
+ key_func (Callable[P, str] | None, optional): Function to generate cache keys.
125
+ Must accept the same parameters as the decorated function.
126
+ name (str, optional): Name to use in the default key generation if key_func is None.
127
+ ttl (int | str | None, optional): The time-to-live for the cached data. Can be an integer
128
+ in seconds or a string (e.g. "1h", "1d", "1w", "1y"). If None, the cache data will not expire.
129
+ Defaults to None. In this case, the cache will not expire.
130
+
131
+ Example:
132
+ ```python
133
+ def get_user_cache_key(user_id: int) -> str:
134
+ return f"user:{user_id}"
135
+
136
+ @cache_store.cache(key_func=get_user_cache_key, ttl="1h")
137
+ async def get_user(user_id: int) -> User:
138
+ return await db.get_user(user_id)
139
+
140
+ # will use/store cache with key "user:1", expiring after 1 hour
141
+ user1 = await get_user(1)
142
+ ```
143
+
144
+ Returns:
145
+ Callable: A decorator function.
146
+ '''
@@ -0,0 +1 @@
1
+ from gllm_datastore.cache_data_store.utils import *
@@ -0,0 +1,62 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_datastore.cache_data_store.cache_data_store import BaseCacheDataStore as BaseCacheDataStore, CacheMatchingStrategy as CacheMatchingStrategy
3
+
4
+ class FileSystemCacheDataStore(BaseCacheDataStore):
5
+ '''A cache data store that stores data in the file system.
6
+
7
+ The `FileSystemCacheDataStore` class utilizes the file system to store cache data.
8
+
9
+ Attributes:
10
+ cache_dir (str): The directory to store the cache data.
11
+ cache_version (str): The version of the cache data.
12
+ current_version_dir (str): The directory to store the cache data for the current version.
13
+ serialization_format (str): The serialization format to use for storing the cache data.
14
+ The supported serialization formats are "json" and "pickle".
15
+ compression_extension (str): The extension to use for the compression of the cache data.
16
+ matching_strategy (CacheMatchingStrategy): The matching strategy to use.
17
+ logger (Logger): The logger to use for logging.
18
+ retrieval_method (Callable[[str], Any]): The method to retrieve cache data based on the matching strategy.
19
+ fuzzy_distance_ratio (float): The ratio of key length to use as maximum Levenshtein distance
20
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1.
21
+ '''
22
+ logger: Incomplete
23
+ cache_dir: Incomplete
24
+ cache_version: Incomplete
25
+ current_version_dir: Incomplete
26
+ serialization_format: Incomplete
27
+ compression_extension: Incomplete
28
+ def __init__(self, cache_dir: str, cache_version: str = '1.0.0', serialization_format: str = 'json', matching_strategy: CacheMatchingStrategy = ..., fuzzy_distance_ratio: float = 0.05) -> None:
29
+ '''Initializes a new instance of the FileSystemCacheDataStore class.
30
+
31
+ Args:
32
+ cache_dir (str): The directory to store the cache data.
33
+ cache_version (str, optional): The version of the cache data. Defaults to "1.0.0".
34
+ serialization_format (str, optional): The serialization format to use for storing the cache data.
35
+ The supported serialization formats are "json" and "pickle". Defaults to "json".
36
+ matching_strategy (CacheMatchingStrategy, optional): The matching strategy to use.
37
+ Defaults to CacheMatchingStrategy.EXACT.
38
+ fuzzy_distance_ratio (float, optional): The ratio of key length to use as maximum Levenshtein distance
39
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1. Defaults to 0.05.
40
+
41
+ Raises:
42
+ ValueError: If the serialization format is not supported.
43
+ '''
44
+ def retrieve_all_keys(self) -> list[str]:
45
+ """Retrieves all keys from the file system cache data store.
46
+
47
+ This method filters out and deletes any expired keys before returning the list.
48
+
49
+ Returns:
50
+ list[str]: A list of all keys in the file system cache data store.
51
+ """
52
+ def delete(self, key: str | list[str]) -> None:
53
+ """Deletes cache data from the file system cache data store.
54
+
55
+ Args:
56
+ key (str | list[str]): The key(s) to delete the cache data.
57
+
58
+ Raises:
59
+ Exception: If there's exist cache file that cannot be deleted.
60
+ """
61
+ def clear(self) -> None:
62
+ """Clears all cache data from the file system cache data store cahe directory."""
@@ -0,0 +1,43 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_datastore.cache_data_store.cache_data_store import BaseCacheDataStore as BaseCacheDataStore, CacheMatchingStrategy as CacheMatchingStrategy
3
+
4
+ class InMemoryCacheDataStore(BaseCacheDataStore):
5
+ """A cache data store that stores data in an in-memory dictionary.
6
+
7
+ The `InMemoryCacheDataStore` class utilizes an in-memory dictionary to store the cache data.
8
+
9
+ Attributes:
10
+ in_memory_cache (dict[str, Any]): An in-memory dictionary to store the cache data.
11
+ retrieval_method (Callable[[str], Any]): The method to retrieve cache data based on the matching strategy.
12
+ fuzzy_distance_ratio (float): The ratio of key length to use as maximum Levenshtein distance
13
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1.
14
+ """
15
+ in_memory_cache: Incomplete
16
+ def __init__(self, matching_strategy: CacheMatchingStrategy = ..., fuzzy_distance_ratio: float = 0.05) -> None:
17
+ """Initializes a new instance of the InMemoryCacheDataStore class.
18
+
19
+ Args:
20
+ matching_strategy (CacheMatchingStrategy, optional): The matching strategy to use.
21
+ Defaults to CacheMatchingStrategy.EXACT.
22
+ fuzzy_distance_ratio (float, optional): The ratio of key length to use as maximum Levenshtein distance
23
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1. Defaults to 0.05.
24
+
25
+ Raises:
26
+ ValueError: If the fuzzy distance ratio is not between 0 and 1.
27
+ """
28
+ def retrieve_all_keys(self) -> list[str]:
29
+ """Retrieves all keys from the storage.
30
+
31
+ This method filters out and deletes any expired keys before returning the list.
32
+
33
+ Returns:
34
+ list[str]: A list of all keys in the storage.
35
+ """
36
+ def delete(self, key: str | list[str]) -> None:
37
+ """Deletes cache data from the storage.
38
+
39
+ Args:
40
+ key (str | list[str]): The key(s) to delete the cache data.
41
+ """
42
+ def clear(self) -> None:
43
+ """Clears all cache data from the storage."""
@@ -0,0 +1,48 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_datastore.cache_data_store.cache_data_store import BaseCacheDataStore as BaseCacheDataStore, CacheMatchingStrategy as CacheMatchingStrategy
3
+
4
+ class RedisCacheDataStore(BaseCacheDataStore):
5
+ """A cache data store that stores data in Redis.
6
+
7
+ The `RedisCacheDataStore` class utilizes Redis to store the cache data.
8
+
9
+ Attributes:
10
+ client (StrictRedis): The Redis client.
11
+ retrieval_method (Callable[[str], Any]): The method to retrieve cache data based on the matching strategy.
12
+ fuzzy_distance_ratio (float): The ratio of key length to use as maximum Levenshtein distance
13
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1.
14
+ """
15
+ client: Incomplete
16
+ def __init__(self, host: str, port: int, password: str, db: int = 0, ssl: bool = False, matching_strategy: CacheMatchingStrategy = ..., fuzzy_distance_ratio: float = 0.05) -> None:
17
+ """Initializes a new instance of the RedisCacheDataStore class.
18
+
19
+ Args:
20
+ host (str): The host of the Redis server.
21
+ port (int): The port of the Redis server.
22
+ password (str): The password for the Redis server.
23
+ db (int, optional): The database number. Defaults to 0.
24
+ ssl (bool, optional): Whether to use SSL. Defaults to False.
25
+ matching_strategy (CacheMatchingStrategy, optional): The matching strategy to use.
26
+ Defaults to CacheMatchingStrategy.EXACT.
27
+ fuzzy_distance_ratio (float, optional): The ratio of key length to use as maximum Levenshtein distance
28
+ for fuzzy matching (e.g., 0.05 means 5% of key length). Must be between 0 and 1. Defaults to 0.05.
29
+
30
+ Raises:
31
+ ValueError: If the fuzzy distance ratio is not between 0 and 1.
32
+ """
33
+ def retrieve_all_keys(self) -> list[str]:
34
+ """Retrieves all keys from the storage.
35
+
36
+ This method filters out and deletes any expired keys before returning the list.
37
+
38
+ Returns:
39
+ list[str]: A list of all keys in the storage.
40
+ """
41
+ def delete(self, key: str | list[str]) -> None:
42
+ """Deletes cache data from the storage.
43
+
44
+ Args:
45
+ key (str | list[str]): The key(s) to delete the cache data.
46
+ """
47
+ def clear(self) -> None:
48
+ """Clears all cache data from the storage."""
@@ -0,0 +1,36 @@
1
+ from _typeshed import Incomplete
2
+ from typing import Any
3
+
4
+ logger: Incomplete
5
+
6
+ def generate_cache_key(input_: str, key_prefix: str = '') -> str:
7
+ '''Generate a cache key from the input string.
8
+
9
+ This function generates a cache key from the input string.
10
+ If the input is a valid file, the function will hash the file.
11
+ If the input is not a valid file, the function will hash the input string.
12
+
13
+ Args:
14
+ input_ (str): The input string to generate the cache key from.
15
+ key_prefix (str, optional): The prefix of the cache key. Defaults to "".
16
+
17
+ Returns:
18
+ str: The generated cache key.
19
+
20
+ Raises:
21
+ Exception: If the input file path exists but cannot be read.
22
+ '''
23
+ def generate_key_from_func(func_name: str, *args: Any, **kwargs: Any) -> str:
24
+ """Generate a cache key based on function name and arguments.
25
+
26
+ The key is created by hashing the function name, positional arguments, and keyword arguments.
27
+ If the function name, positional arguments, or keyword arguments are modified, the cache key will change.
28
+
29
+ Args:
30
+ func_name (str): Name of the function being cached
31
+ *args (Any): Positional arguments passed to the function
32
+ **kwargs (Any): Keyword arguments passed to the function
33
+
34
+ Returns:
35
+ str: SHA-256 hash digest to be used as cache key
36
+ """
@@ -0,0 +1,2 @@
1
+ DEFAULT_TOP_K: int
2
+ DEFAULT_REQUEST_TIMEOUT: int
File without changes
@@ -0,0 +1,80 @@
1
+ import abc
2
+ from abc import ABC, abstractmethod
3
+ from typing import Any
4
+
5
+ class BaseGraphDataStore(ABC, metaclass=abc.ABCMeta):
6
+ """Abstract base class for a graph data store interface."""
7
+ @abstractmethod
8
+ def upsert_node(self, label: str, identifier_key: str, identifier_value: str, properties: dict[str, Any] | None) -> Any:
9
+ """Upsert a node in the graph.
10
+
11
+ Args:
12
+ label (str): The label of the node.
13
+ identifier_key (str): The key of the identifier.
14
+ identifier_value (str): The value of the identifier.
15
+ properties (dict[str, Any] | None, optional): The properties of the node. Defaults to None.
16
+
17
+ Returns:
18
+ Any: The result of the operation.
19
+ """
20
+ @abstractmethod
21
+ def upsert_relationship(self, node_source_key: str, node_source_value: str, relation: str, node_target_key: str, node_target_value: str, properties: dict[str, Any] | None) -> Any:
22
+ """Upsert a relationship between two nodes in the graph.
23
+
24
+ Args:
25
+ node_source_key (str): The key of the source node.
26
+ node_source_value (str): The value of the source node.
27
+ relation (str): The type of the relationship.
28
+ node_target_key (str): The key of the target node.
29
+ node_target_value (str): The value of the target node.
30
+ properties (dict[str, Any] | None, optional): The properties of the relationship. Defaults to None.
31
+
32
+ Returns:
33
+ Any: The result of the operation.
34
+ """
35
+ @abstractmethod
36
+ def delete_node(self, label: str, identifier_key: str, identifier_value: str) -> Any:
37
+ """Delete a node from the graph.
38
+
39
+ Args:
40
+ label (str): The label of the node.
41
+ identifier_key (str): The key of the identifier.
42
+ identifier_value (str): The identifier of the node.
43
+
44
+ Returns:
45
+ Any: The result of the operation.
46
+ """
47
+ @abstractmethod
48
+ def delete_relationship(self, node_source_key: str, node_source_value: str, relation: str, node_target_key: str, node_target_value: str) -> Any:
49
+ """Delete a relationship between two nodes in the graph.
50
+
51
+ Args:
52
+ node_source_key (str): The key of the source node.
53
+ node_source_value (str): The identifier of the source node.
54
+ relation (str): The type of the relationship.
55
+ node_target_key (str): The key of the target node.
56
+ node_target_value (str): The identifier of the target node.
57
+
58
+ Returns:
59
+ Any: The result of the operation.
60
+ """
61
+ @abstractmethod
62
+ def query(self, query: str, parameters: dict[str, Any] | None = None) -> list[dict[str, Any]]:
63
+ """Query the graph store.
64
+
65
+ Args:
66
+ query (str): The query to be executed.
67
+ parameters (dict[str, Any] | None, optional): The parameters of the query. Defaults to None.
68
+
69
+ Returns:
70
+ list[dict[str, Any]]: The result of the query.
71
+ """
72
+ @abstractmethod
73
+ def close(self) -> None:
74
+ """Close the graph data store."""
75
+
76
+ class GraphDataStore(BaseGraphDataStore, metaclass=abc.ABCMeta):
77
+ """A graph data store interface.
78
+
79
+ This class is deprecated and will be removed in a future release. Use BaseGraphDataStore instead.
80
+ """
@@ -0,0 +1,28 @@
1
+ import abc
2
+ from abc import ABC, abstractmethod
3
+ from typing import Any
4
+
5
+ class BaseGraphRAGDataStore(ABC, metaclass=abc.ABCMeta):
6
+ """Abstract base class for graph RAG data stores in the retrieval system.
7
+
8
+ This class defines the interface for all graph data store implementations.
9
+ """
10
+ @abstractmethod
11
+ def query(self, query: str, **kwargs: Any) -> Any:
12
+ """Query the graph RAG data store.
13
+
14
+ Args:
15
+ query (str): The query to be executed.
16
+ **kwargs (Any): Additional keyword arguments.
17
+
18
+ Returns:
19
+ Any: The result of the query.
20
+ """
21
+ @abstractmethod
22
+ def delete_by_document_id(self, document_id: str, **kwargs: Any) -> None:
23
+ """Delete nodes and edges by document ID.
24
+
25
+ Args:
26
+ document_id (str): The document ID.
27
+ **kwargs (Any): Additional keyword arguments.
28
+ """
@@ -0,0 +1,18 @@
1
+ import abc
2
+ from abc import ABC
3
+ from gllm_datastore.graph_data_store.graph_rag_data_store import BaseGraphRAGDataStore as BaseGraphRAGDataStore
4
+ from llama_index.core.graph_stores.types import PropertyGraphStore
5
+ from typing import Any
6
+
7
+ class LlamaIndexGraphRAGDataStore(PropertyGraphStore, BaseGraphRAGDataStore, ABC, metaclass=abc.ABCMeta):
8
+ """Abstract base class for a LlamaIndex graph RAG data store."""
9
+ def query(self, query: str, **kwargs: Any) -> Any:
10
+ """Query the graph RAG data store.
11
+
12
+ Args:
13
+ query (str): The query to be executed.
14
+ **kwargs (Any): Additional keyword arguments.
15
+
16
+ Returns:
17
+ Any: The result of the query.
18
+ """
@@ -0,0 +1,26 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_datastore.graph_data_store.llama_index_graph_rag_data_store import LlamaIndexGraphRAGDataStore as LlamaIndexGraphRAGDataStore
3
+ from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore
4
+ from typing import Any
5
+
6
+ class LlamaIndexNeo4jGraphRAGDataStore(LlamaIndexGraphRAGDataStore, Neo4jPropertyGraphStore):
7
+ """Graph RAG data store for Neo4j. This class extends the Neo4jPropertyGraphStore class from LlamaIndex.
8
+
9
+ Attributes:
10
+ neo4j_version_tuple (tuple[int, ...]): The Neo4j version tuple.
11
+ """
12
+ neo4j_version_tuple: Incomplete
13
+ def __init__(self, *args, **kwargs) -> None:
14
+ """Initialize the LlamaIndexNeo4jGraphRAGDataStore.
15
+
16
+ Args:
17
+ *args: Variable length argument list.
18
+ **kwargs: Arbitrary keyword arguments.
19
+ """
20
+ def delete_by_document_id(self, document_id: str, **kwargs: Any) -> None:
21
+ """Delete nodes and edges by document ID.
22
+
23
+ Args:
24
+ document_id (str): The document ID.
25
+ **kwargs (Any): Additional keyword arguments.
26
+ """
@@ -0,0 +1,112 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_datastore.graph_data_store.graph_data_store import BaseGraphDataStore as BaseGraphDataStore
3
+ from nebula3.gclient.net import Session as Session
4
+ from typing import Any
5
+
6
+ class NebulaGraphDataStore(BaseGraphDataStore):
7
+ """Implementation of BaseGraphDataStore for Nebula Graph.
8
+
9
+ Attributes:
10
+ connection_pool (ConnectionPool): The connection pool for Nebula Graph.
11
+ space (str): The space name.
12
+ user (str): The username.
13
+ password (str): The password.
14
+ operation_wait_time (int): The timeout in seconds.
15
+ """
16
+ connection_pool: Incomplete
17
+ space: Incomplete
18
+ user: Incomplete
19
+ password: Incomplete
20
+ operation_wait_time: Incomplete
21
+ def __init__(self, url: str, port: int, user: str, password: str, space: str, operation_wait_time: int = 5) -> None:
22
+ """Initialize NebulaGraphDataStore.
23
+
24
+ Args:
25
+ url (str): The URL of the graph store.
26
+ port (int): The port of the graph store.
27
+ user (str): The user of the graph store.
28
+ password (str): The password of the graph store.
29
+ space (str): The space name.
30
+ operation_wait_time (int, optional): The operation wait time in seconds. Defaults to 5.
31
+ """
32
+ def upsert_node(self, label: str, identifier_key: str, identifier_value: str, properties: dict[str, Any] | None = None) -> Any:
33
+ """Upsert a node in the graph.
34
+
35
+ Args:
36
+ label (str): The label of the node.
37
+ identifier_key (str): The key of the identifier.
38
+ identifier_value (str): The value of the identifier.
39
+ properties (dict[str, Any] | None, optional): The properties of the node. Defaults to None.
40
+
41
+ Returns:
42
+ Any: The result of the operation.
43
+ """
44
+ def upsert_relationship(self, node_source_key: str, node_source_value: str, relation: str, node_target_key: str, node_target_value: str, properties: dict[str, Any] | None = None) -> Any:
45
+ """Upsert a relationship between two nodes in the graph.
46
+
47
+ Args:
48
+ node_source_key (str): The key of the source node.
49
+ node_source_value (str): The value of the source node.
50
+ relation (str): The type of the relationship.
51
+ node_target_key (str): The key of the target node.
52
+ node_target_value (str): The value of the target node.
53
+ properties (dict[str, Any] | None, optional): The properties of the relationship. Defaults to None.
54
+
55
+ Returns:
56
+ Any: The result of the operation.
57
+ """
58
+ def delete_node(self, label: str, identifier_key: str, identifier_value: str) -> Any:
59
+ """Delete a node from the graph.
60
+
61
+ Args:
62
+ label (str): The label of the node.
63
+ identifier_key (str): The key of the identifier.
64
+ identifier_value (str): The identifier of the node.
65
+
66
+ Returns:
67
+ Any: The result of the operation.
68
+ """
69
+ def delete_relationship(self, node_source_key: str, node_source_value: str, relation: str, node_target_key: str, node_target_value: str) -> Any:
70
+ """Delete a relationship between two nodes in the graph.
71
+
72
+ Args:
73
+ node_source_key (str): The key of the source node.
74
+ node_source_value (str): The identifier of the source node.
75
+ relation (str): The type of the relationship.
76
+ node_target_key (str): The key of the target node.
77
+ node_target_value (str): The identifier of the target node.
78
+
79
+ Returns:
80
+ Any: The result of the operation.
81
+ """
82
+ def query(self, query: str, parameters: dict[str, Any] | None = None) -> list[dict[str, Any]]:
83
+ """Query the graph store.
84
+
85
+ Args:
86
+ query (str): The query to be executed.
87
+ parameters (dict[str, Any] | None, optional): The parameters of the query. Defaults to None.
88
+
89
+ Returns:
90
+ list[dict[str, Any]]: The result of the query.
91
+ """
92
+ def close(self) -> None:
93
+ """Close the graph data store."""
94
+ def get_nodes(self, label: str | None = None) -> list[dict[str, Any]]:
95
+ """Get all nodes with optional label filter.
96
+
97
+ Args:
98
+ label (str | None, optional): The label of the nodes. Defaults to None.
99
+
100
+ Returns:
101
+ list[dict[str, Any]]: The result of the query.
102
+ """
103
+ def get_relationships(self, source_value: str | None = None, relation: str | None = None) -> list[dict[str, Any]]:
104
+ """Get relationships with optional filters.
105
+
106
+ Args:
107
+ source_value (str | None, optional): The source vertex identifier. Defaults to None.
108
+ relation (str | None, optional): The relationship type. Defaults to None.
109
+
110
+ Returns:
111
+ list[dict[str, Any]]: The result of the query.
112
+ """