temporal-graphrag 1.0.0__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.
- temporal_graphrag-1.0.0/PKG-INFO +118 -0
- temporal_graphrag-1.0.0/api/__init__.py +1 -0
- temporal_graphrag-1.0.0/api/auth.py +109 -0
- temporal_graphrag-1.0.0/api/config.py +580 -0
- temporal_graphrag-1.0.0/api/gunicorn_config.py +162 -0
- temporal_graphrag-1.0.0/api/lightrag_server.py +1530 -0
- temporal_graphrag-1.0.0/api/routers/__init__.py +10 -0
- temporal_graphrag-1.0.0/api/routers/document_routes.py +3290 -0
- temporal_graphrag-1.0.0/api/routers/graph_routes.py +688 -0
- temporal_graphrag-1.0.0/api/routers/ollama_api.py +723 -0
- temporal_graphrag-1.0.0/api/routers/query_routes.py +1159 -0
- temporal_graphrag-1.0.0/api/run_with_gunicorn.py +282 -0
- temporal_graphrag-1.0.0/api/utils_api.py +438 -0
- temporal_graphrag-1.0.0/evaluation/__init__.py +25 -0
- temporal_graphrag-1.0.0/evaluation/eval_rag_quality.py +1016 -0
- temporal_graphrag-1.0.0/kg/__init__.py +143 -0
- temporal_graphrag-1.0.0/kg/deprecated/chroma_impl.py +343 -0
- temporal_graphrag-1.0.0/kg/faiss_impl.py +559 -0
- temporal_graphrag-1.0.0/kg/graphiti_impl.py +811 -0
- temporal_graphrag-1.0.0/kg/json_doc_status_impl.py +407 -0
- temporal_graphrag-1.0.0/kg/json_kv_impl.py +302 -0
- temporal_graphrag-1.0.0/kg/memgraph_impl.py +1146 -0
- temporal_graphrag-1.0.0/kg/milvus_impl.py +1371 -0
- temporal_graphrag-1.0.0/kg/mongo_impl.py +2505 -0
- temporal_graphrag-1.0.0/kg/nano_vector_db_impl.py +428 -0
- temporal_graphrag-1.0.0/kg/neo4j_impl.py +1877 -0
- temporal_graphrag-1.0.0/kg/networkx_impl.py +569 -0
- temporal_graphrag-1.0.0/kg/postgres_impl.py +5758 -0
- temporal_graphrag-1.0.0/kg/qdrant_impl.py +917 -0
- temporal_graphrag-1.0.0/kg/redis_impl.py +1119 -0
- temporal_graphrag-1.0.0/kg/shared_storage.py +1717 -0
- temporal_graphrag-1.0.0/llm/__init__.py +1 -0
- temporal_graphrag-1.0.0/llm/anthropic.py +335 -0
- temporal_graphrag-1.0.0/llm/azure_openai.py +22 -0
- temporal_graphrag-1.0.0/llm/bedrock.py +485 -0
- temporal_graphrag-1.0.0/llm/binding_options.py +740 -0
- temporal_graphrag-1.0.0/llm/deprecated/siliconcloud.py +69 -0
- temporal_graphrag-1.0.0/llm/gemini.py +632 -0
- temporal_graphrag-1.0.0/llm/hf.py +177 -0
- temporal_graphrag-1.0.0/llm/jina.py +157 -0
- temporal_graphrag-1.0.0/llm/llama_index_impl.py +208 -0
- temporal_graphrag-1.0.0/llm/lmdeploy.py +154 -0
- temporal_graphrag-1.0.0/llm/lollms.py +177 -0
- temporal_graphrag-1.0.0/llm/nvidia_openai.py +68 -0
- temporal_graphrag-1.0.0/llm/ollama.py +243 -0
- temporal_graphrag-1.0.0/llm/openai.py +1020 -0
- temporal_graphrag-1.0.0/llm/zhipu.py +219 -0
- temporal_graphrag-1.0.0/pyproject.toml +177 -0
- temporal_graphrag-1.0.0/setup.cfg +4 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/PKG-INFO +118 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/SOURCES.txt +61 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/dependency_links.txt +1 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/entry_points.txt +5 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/requires.txt +101 -0
- temporal_graphrag-1.0.0/temporal_graphrag.egg-info/top_level.txt +6 -0
- temporal_graphrag-1.0.0/tools/__init__.py +1 -0
- temporal_graphrag-1.0.0/tools/check_initialization.py +179 -0
- temporal_graphrag-1.0.0/tools/clean_llm_query_cache.py +1144 -0
- temporal_graphrag-1.0.0/tools/download_cache.py +200 -0
- temporal_graphrag-1.0.0/tools/lightrag_visualizer/__init__.py +1 -0
- temporal_graphrag-1.0.0/tools/lightrag_visualizer/graph_visualizer.py +1221 -0
- temporal_graphrag-1.0.0/tools/migrate_llm_cache.py +1472 -0
- temporal_graphrag-1.0.0/tools/prepare_qdrant_legacy_data.py +720 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: temporal-graphrag
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: HelixRAG: Retrieval-Augmented Generation with Graphiti-powered Knowledge Graphs
|
|
5
|
+
Author-email: Yash Nuhash <nuhashroxme@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/YashNuhash/Helix
|
|
8
|
+
Project-URL: Documentation, https://github.com/YashNuhash/Helix#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/YashNuhash/Helix
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/YashNuhash/Helix/issues
|
|
11
|
+
Keywords: rag,graphrag,knowledge-graph,graphiti,llm,ai,neo4j
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Intended Audience :: Science/Research
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: aiohttp
|
|
26
|
+
Requires-Dist: configparser
|
|
27
|
+
Requires-Dist: google-api-core<3.0.0,>=2.0.0
|
|
28
|
+
Requires-Dist: google-genai<2.0.0,>=1.0.0
|
|
29
|
+
Requires-Dist: json_repair
|
|
30
|
+
Requires-Dist: nano-vectordb
|
|
31
|
+
Requires-Dist: networkx
|
|
32
|
+
Requires-Dist: numpy<3.0.0,>=1.24.0
|
|
33
|
+
Requires-Dist: pandas<2.4.0,>=2.0.0
|
|
34
|
+
Requires-Dist: pipmaster
|
|
35
|
+
Requires-Dist: pydantic
|
|
36
|
+
Requires-Dist: pypinyin
|
|
37
|
+
Requires-Dist: python-dotenv
|
|
38
|
+
Requires-Dist: setuptools
|
|
39
|
+
Requires-Dist: tenacity
|
|
40
|
+
Requires-Dist: tiktoken
|
|
41
|
+
Requires-Dist: xlsxwriter>=3.1.0
|
|
42
|
+
Requires-Dist: graphiti-core>=0.27.1
|
|
43
|
+
Requires-Dist: neo4j>=5.28.0
|
|
44
|
+
Provides-Extra: pytest
|
|
45
|
+
Requires-Dist: pytest>=8.4.2; extra == "pytest"
|
|
46
|
+
Requires-Dist: pytest-asyncio>=1.2.0; extra == "pytest"
|
|
47
|
+
Requires-Dist: pre-commit; extra == "pytest"
|
|
48
|
+
Requires-Dist: ruff; extra == "pytest"
|
|
49
|
+
Provides-Extra: api
|
|
50
|
+
Requires-Dist: aiohttp; extra == "api"
|
|
51
|
+
Requires-Dist: configparser; extra == "api"
|
|
52
|
+
Requires-Dist: json_repair; extra == "api"
|
|
53
|
+
Requires-Dist: nano-vectordb; extra == "api"
|
|
54
|
+
Requires-Dist: networkx; extra == "api"
|
|
55
|
+
Requires-Dist: numpy<3.0.0,>=1.24.0; extra == "api"
|
|
56
|
+
Requires-Dist: openai<3.0.0,>=2.0.0; extra == "api"
|
|
57
|
+
Requires-Dist: pandas<2.4.0,>=2.0.0; extra == "api"
|
|
58
|
+
Requires-Dist: pipmaster; extra == "api"
|
|
59
|
+
Requires-Dist: pydantic; extra == "api"
|
|
60
|
+
Requires-Dist: pypinyin; extra == "api"
|
|
61
|
+
Requires-Dist: python-dotenv; extra == "api"
|
|
62
|
+
Requires-Dist: setuptools; extra == "api"
|
|
63
|
+
Requires-Dist: tenacity; extra == "api"
|
|
64
|
+
Requires-Dist: tiktoken; extra == "api"
|
|
65
|
+
Requires-Dist: xlsxwriter>=3.1.0; extra == "api"
|
|
66
|
+
Requires-Dist: google-api-core<3.0.0,>=2.0.0; extra == "api"
|
|
67
|
+
Requires-Dist: google-genai<2.0.0,>=1.0.0; extra == "api"
|
|
68
|
+
Requires-Dist: aiofiles; extra == "api"
|
|
69
|
+
Requires-Dist: ascii_colors; extra == "api"
|
|
70
|
+
Requires-Dist: distro; extra == "api"
|
|
71
|
+
Requires-Dist: fastapi; extra == "api"
|
|
72
|
+
Requires-Dist: httpcore; extra == "api"
|
|
73
|
+
Requires-Dist: httpx>=0.28.1; extra == "api"
|
|
74
|
+
Requires-Dist: jiter; extra == "api"
|
|
75
|
+
Requires-Dist: bcrypt>=4.0.0; extra == "api"
|
|
76
|
+
Requires-Dist: psutil; extra == "api"
|
|
77
|
+
Requires-Dist: PyJWT<3.0.0,>=2.8.0; extra == "api"
|
|
78
|
+
Requires-Dist: python-jose[cryptography]; extra == "api"
|
|
79
|
+
Requires-Dist: python-multipart; extra == "api"
|
|
80
|
+
Requires-Dist: pytz; extra == "api"
|
|
81
|
+
Requires-Dist: uvicorn; extra == "api"
|
|
82
|
+
Requires-Dist: gunicorn; extra == "api"
|
|
83
|
+
Requires-Dist: openpyxl<4.0.0,>=3.0.0; extra == "api"
|
|
84
|
+
Requires-Dist: pycryptodome<4.0.0,>=3.0.0; extra == "api"
|
|
85
|
+
Requires-Dist: pypdf>=6.1.0; extra == "api"
|
|
86
|
+
Requires-Dist: python-docx<2.0.0,>=0.8.11; extra == "api"
|
|
87
|
+
Requires-Dist: python-pptx<2.0.0,>=0.6.21; extra == "api"
|
|
88
|
+
Provides-Extra: offline-storage
|
|
89
|
+
Requires-Dist: redis<8.0.0,>=5.0.0; extra == "offline-storage"
|
|
90
|
+
Requires-Dist: neo4j<7.0.0,>=5.0.0; extra == "offline-storage"
|
|
91
|
+
Requires-Dist: pymilvus<3.0.0,>=2.6.2; extra == "offline-storage"
|
|
92
|
+
Requires-Dist: pymongo<5.0.0,>=4.0.0; extra == "offline-storage"
|
|
93
|
+
Requires-Dist: asyncpg<1.0.0,>=0.31.0; extra == "offline-storage"
|
|
94
|
+
Requires-Dist: pgvector<1.0.0,>=0.4.2; extra == "offline-storage"
|
|
95
|
+
Requires-Dist: qdrant-client<2.0.0,>=1.11.0; extra == "offline-storage"
|
|
96
|
+
Provides-Extra: offline-llm
|
|
97
|
+
Requires-Dist: openai<3.0.0,>=2.0.0; extra == "offline-llm"
|
|
98
|
+
Requires-Dist: anthropic<1.0.0,>=0.18.0; extra == "offline-llm"
|
|
99
|
+
Requires-Dist: ollama<1.0.0,>=0.1.0; extra == "offline-llm"
|
|
100
|
+
Requires-Dist: zhipuai<3.0.0,>=2.0.0; extra == "offline-llm"
|
|
101
|
+
Requires-Dist: aioboto3<16.0.0,>=12.0.0; extra == "offline-llm"
|
|
102
|
+
Requires-Dist: voyageai<1.0.0,>=0.2.0; extra == "offline-llm"
|
|
103
|
+
Requires-Dist: llama-index<1.0.0,>=0.14.0; extra == "offline-llm"
|
|
104
|
+
Requires-Dist: llama-index-llms-openai>=0.6.12; extra == "offline-llm"
|
|
105
|
+
Requires-Dist: google-api-core<3.0.0,>=2.0.0; extra == "offline-llm"
|
|
106
|
+
Requires-Dist: google-genai<2.0.0,>=1.0.0; extra == "offline-llm"
|
|
107
|
+
Provides-Extra: offline
|
|
108
|
+
Requires-Dist: helixrag[api,offline-llm,offline-storage]; extra == "offline"
|
|
109
|
+
Provides-Extra: test
|
|
110
|
+
Requires-Dist: helixrag[api]; extra == "test"
|
|
111
|
+
Requires-Dist: pytest>=8.4.2; extra == "test"
|
|
112
|
+
Requires-Dist: pytest-asyncio>=1.2.0; extra == "test"
|
|
113
|
+
Requires-Dist: pre-commit; extra == "test"
|
|
114
|
+
Requires-Dist: ruff; extra == "test"
|
|
115
|
+
Provides-Extra: evaluation
|
|
116
|
+
Requires-Dist: helixrag[api]; extra == "evaluation"
|
|
117
|
+
Requires-Dist: ragas>=0.3.7; extra == "evaluation"
|
|
118
|
+
Requires-Dist: datasets>=4.3.0; extra == "evaluation"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__api_version__ = "0271"
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
|
+
|
|
3
|
+
import jwt
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from fastapi import HTTPException, status
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
|
|
8
|
+
from .config import global_args
|
|
9
|
+
|
|
10
|
+
# use the .env that is inside the current folder
|
|
11
|
+
# allows to use different .env file for each lightrag instance
|
|
12
|
+
# the OS environment variables take precedence over the .env file
|
|
13
|
+
load_dotenv(dotenv_path=".env", override=False)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TokenPayload(BaseModel):
|
|
17
|
+
sub: str # Username
|
|
18
|
+
exp: datetime # Expiration time
|
|
19
|
+
role: str = "user" # User role, default is regular user
|
|
20
|
+
metadata: dict = {} # Additional metadata
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AuthHandler:
|
|
24
|
+
def __init__(self):
|
|
25
|
+
self.secret = global_args.token_secret
|
|
26
|
+
self.algorithm = global_args.jwt_algorithm
|
|
27
|
+
self.expire_hours = global_args.token_expire_hours
|
|
28
|
+
self.guest_expire_hours = global_args.guest_token_expire_hours
|
|
29
|
+
self.accounts = {}
|
|
30
|
+
auth_accounts = global_args.auth_accounts
|
|
31
|
+
if auth_accounts:
|
|
32
|
+
for account in auth_accounts.split(","):
|
|
33
|
+
username, password = account.split(":", 1)
|
|
34
|
+
self.accounts[username] = password
|
|
35
|
+
|
|
36
|
+
def create_token(
|
|
37
|
+
self,
|
|
38
|
+
username: str,
|
|
39
|
+
role: str = "user",
|
|
40
|
+
custom_expire_hours: int = None,
|
|
41
|
+
metadata: dict = None,
|
|
42
|
+
) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Create JWT token
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
username: Username
|
|
48
|
+
role: User role, default is "user", guest is "guest"
|
|
49
|
+
custom_expire_hours: Custom expiration time (hours), if None use default value
|
|
50
|
+
metadata: Additional metadata
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
str: Encoded JWT token
|
|
54
|
+
"""
|
|
55
|
+
# Choose default expiration time based on role
|
|
56
|
+
if custom_expire_hours is None:
|
|
57
|
+
if role == "guest":
|
|
58
|
+
expire_hours = self.guest_expire_hours
|
|
59
|
+
else:
|
|
60
|
+
expire_hours = self.expire_hours
|
|
61
|
+
else:
|
|
62
|
+
expire_hours = custom_expire_hours
|
|
63
|
+
|
|
64
|
+
expire = datetime.utcnow() + timedelta(hours=expire_hours)
|
|
65
|
+
|
|
66
|
+
# Create payload
|
|
67
|
+
payload = TokenPayload(
|
|
68
|
+
sub=username, exp=expire, role=role, metadata=metadata or {}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return jwt.encode(payload.dict(), self.secret, algorithm=self.algorithm)
|
|
72
|
+
|
|
73
|
+
def validate_token(self, token: str) -> dict:
|
|
74
|
+
"""
|
|
75
|
+
Validate JWT token
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
token: JWT token
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
dict: Dictionary containing user information
|
|
82
|
+
|
|
83
|
+
Raises:
|
|
84
|
+
HTTPException: If token is invalid or expired
|
|
85
|
+
"""
|
|
86
|
+
try:
|
|
87
|
+
payload = jwt.decode(token, self.secret, algorithms=[self.algorithm])
|
|
88
|
+
expire_timestamp = payload["exp"]
|
|
89
|
+
expire_time = datetime.utcfromtimestamp(expire_timestamp)
|
|
90
|
+
|
|
91
|
+
if datetime.utcnow() > expire_time:
|
|
92
|
+
raise HTTPException(
|
|
93
|
+
status_code=status.HTTP_401_UNAUTHORIZED, detail="Token expired"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Return complete payload instead of just username
|
|
97
|
+
return {
|
|
98
|
+
"username": payload["sub"],
|
|
99
|
+
"role": payload.get("role", "user"),
|
|
100
|
+
"metadata": payload.get("metadata", {}),
|
|
101
|
+
"exp": expire_time,
|
|
102
|
+
}
|
|
103
|
+
except jwt.PyJWTError:
|
|
104
|
+
raise HTTPException(
|
|
105
|
+
status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
auth_handler = AuthHandler()
|