meshrag 1.0.0__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.
- lightrag/__init__.py +7 -0
- lightrag/api/__init__.py +1 -0
- lightrag/api/auth.py +109 -0
- lightrag/api/config.py +589 -0
- lightrag/api/external_kb_client.py +268 -0
- lightrag/api/gunicorn_config.py +162 -0
- lightrag/api/lightrag_server.py +1691 -0
- lightrag/api/llm_factory.py +307 -0
- lightrag/api/rag_manager.py +2017 -0
- lightrag/api/registry.py +209 -0
- lightrag/api/routers/__init__.py +12 -0
- lightrag/api/routers/document_routes.py +4433 -0
- lightrag/api/routers/graph_routes.py +737 -0
- lightrag/api/routers/ollama_api.py +778 -0
- lightrag/api/routers/query_routes.py +1645 -0
- lightrag/api/routers/registry_routes.py +250 -0
- lightrag/api/run_with_gunicorn.py +282 -0
- lightrag/api/static/swagger-ui/favicon-32x32.png +0 -0
- lightrag/api/static/swagger-ui/swagger-ui-bundle.js +2 -0
- lightrag/api/static/swagger-ui/swagger-ui.css +3 -0
- lightrag/api/utils_api.py +438 -0
- lightrag/api/webui/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- lightrag/api/webui/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- lightrag/api/webui/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- lightrag/api/webui/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- lightrag/api/webui/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- lightrag/api/webui/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- lightrag/api/webui/assets/arc-DYhJXBOL.js +1 -0
- lightrag/api/webui/assets/architectureDiagram-VXUJARFQ-D9NMPF4e.js +36 -0
- lightrag/api/webui/assets/blockDiagram-VD42YOAC-CxEq2npg.js +122 -0
- lightrag/api/webui/assets/c4Diagram-YG6GDRKO-Lf93PvOJ.js +10 -0
- lightrag/api/webui/assets/channel-BXtDqxR_.js +1 -0
- lightrag/api/webui/assets/chunk-4BX2VUAB-CqSR1aut.js +1 -0
- lightrag/api/webui/assets/chunk-55IACEB6-BTQ9UTO6.js +1 -0
- lightrag/api/webui/assets/chunk-B4BG7PRW-Cn5DVGI2.js +165 -0
- lightrag/api/webui/assets/chunk-DI55MBZ5-DxhGfynN.js +220 -0
- lightrag/api/webui/assets/chunk-FMBD7UC4-Dn-ygM4b.js +15 -0
- lightrag/api/webui/assets/chunk-QN33PNHL-DTW-5i10.js +1 -0
- lightrag/api/webui/assets/chunk-QZHKN3VN-Du90MEcU.js +1 -0
- lightrag/api/webui/assets/chunk-TZMSLE5B-COJpgEFo.js +1 -0
- lightrag/api/webui/assets/classDiagram-2ON5EDUG-Bj029qmo.js +1 -0
- lightrag/api/webui/assets/classDiagram-v2-WZHVMYZB-Bj029qmo.js +1 -0
- lightrag/api/webui/assets/clone-hXTrbV6b.js +1 -0
- lightrag/api/webui/assets/cose-bilkent-S5V4N54A-ztzrGaGR.js +1 -0
- lightrag/api/webui/assets/cytoscape.esm-5J0xJHOV.js +321 -0
- lightrag/api/webui/assets/dagre-6UL2VRFP-BixxvexV.js +4 -0
- lightrag/api/webui/assets/defaultLocale-C4B-KCzX.js +1 -0
- lightrag/api/webui/assets/diagram-PSM6KHXK-DdMjU-2l.js +24 -0
- lightrag/api/webui/assets/diagram-QEK2KX5R--bW-kATO.js +43 -0
- lightrag/api/webui/assets/diagram-S2PKOQOG-Dp_demLf.js +24 -0
- lightrag/api/webui/assets/erDiagram-Q2GNP2WA-plX8IRia.js +60 -0
- lightrag/api/webui/assets/flowDiagram-NV44I4VS-DtISCBNJ.js +162 -0
- lightrag/api/webui/assets/ganttDiagram-JELNMOA3-DkI0SmS_.js +267 -0
- lightrag/api/webui/assets/gitGraphDiagram-V2S2FVAM-CO-hc35z.js +65 -0
- lightrag/api/webui/assets/graph-CPCuV3C_.js +1 -0
- lightrag/api/webui/assets/index-C0Ra6R2k.js +3 -0
- lightrag/api/webui/assets/index-YTWDz8XI.css +1 -0
- lightrag/api/webui/assets/index-eBABlMd0.js +1764 -0
- lightrag/api/webui/assets/infoDiagram-HS3SLOUP-xCmix8cZ.js +2 -0
- lightrag/api/webui/assets/init-Gi6I4Gst.js +1 -0
- lightrag/api/webui/assets/journeyDiagram-XKPGCS4Q-4ZzY1szP.js +139 -0
- lightrag/api/webui/assets/kanban-definition-3W4ZIXB7-Df4v75SF.js +89 -0
- lightrag/api/webui/assets/layout-DAeEobxq.js +1 -0
- lightrag/api/webui/assets/linear-DHPlqM1b.js +1 -0
- lightrag/api/webui/assets/mindmap-definition-VGOIOE7T-DfHrkp2z.js +68 -0
- lightrag/api/webui/assets/ordinal-BENe2yWM.js +1 -0
- lightrag/api/webui/assets/pieDiagram-ADFJNKIX-1k4st0T2.js +30 -0
- lightrag/api/webui/assets/quadrantDiagram-AYHSOK5B-DURAK8QM.js +7 -0
- lightrag/api/webui/assets/requirementDiagram-UZGBJVZJ-RZlInJog.js +64 -0
- lightrag/api/webui/assets/sankeyDiagram-TZEHDZUN-CNaxQjSF.js +10 -0
- lightrag/api/webui/assets/sequenceDiagram-WL72ISMW-CaFAQyUz.js +145 -0
- lightrag/api/webui/assets/stateDiagram-FKZM4ZOC-B4FRWTvg.js +1 -0
- lightrag/api/webui/assets/stateDiagram-v2-4FDKWEC3-C_f0XKLw.js +1 -0
- lightrag/api/webui/assets/timeline-definition-IT6M3QCI-CJZgOy-y.js +61 -0
- lightrag/api/webui/assets/treemap-GDKQZRPO-CsQaPTHq.js +160 -0
- lightrag/api/webui/assets/xychartDiagram-PRI3JC2R-CfA_lR1M.js +7 -0
- lightrag/api/webui/index.html +17 -0
- lightrag/api/webui/logo.png +0 -0
- lightrag/api/webui/meshrag-favicon.png +0 -0
- lightrag/base.py +920 -0
- lightrag/constants.py +113 -0
- lightrag/evaluation/__init__.py +25 -0
- lightrag/evaluation/eval_rag_quality.py +1016 -0
- lightrag/exceptions.py +155 -0
- lightrag/kg/__init__.py +140 -0
- lightrag/kg/deprecated/chroma_impl.py +343 -0
- lightrag/kg/faiss_impl.py +583 -0
- lightrag/kg/json_doc_status_impl.py +426 -0
- lightrag/kg/json_kv_impl.py +302 -0
- lightrag/kg/memgraph_impl.py +1146 -0
- lightrag/kg/milvus_impl.py +1934 -0
- lightrag/kg/mongo_impl.py +2519 -0
- lightrag/kg/nano_vector_db_impl.py +428 -0
- lightrag/kg/neo4j_impl.py +1898 -0
- lightrag/kg/networkx_impl.py +570 -0
- lightrag/kg/postgres_impl.py +6166 -0
- lightrag/kg/qdrant_impl.py +1049 -0
- lightrag/kg/redis_impl.py +1165 -0
- lightrag/kg/shared_storage.py +1721 -0
- lightrag/lightrag.py +4603 -0
- lightrag/llm/__init__.py +0 -0
- lightrag/llm/anthropic.py +335 -0
- lightrag/llm/azure_openai.py +22 -0
- lightrag/llm/bedrock.py +485 -0
- lightrag/llm/binding_options.py +745 -0
- lightrag/llm/deprecated/siliconcloud.py +69 -0
- lightrag/llm/gemini.py +610 -0
- lightrag/llm/hf.py +177 -0
- lightrag/llm/jina.py +157 -0
- lightrag/llm/llama_index_impl.py +208 -0
- lightrag/llm/lmdeploy.py +154 -0
- lightrag/llm/lollms.py +177 -0
- lightrag/llm/nvidia_openai.py +68 -0
- lightrag/llm/ollama.py +243 -0
- lightrag/llm/openai.py +1096 -0
- lightrag/llm/zhipu.py +219 -0
- lightrag/namespace.py +28 -0
- lightrag/operate.py +5226 -0
- lightrag/prompt.py +605 -0
- lightrag/rerank.py +587 -0
- lightrag/tools/__init__.py +0 -0
- lightrag/tools/check_initialization.py +179 -0
- lightrag/tools/clean_llm_query_cache.py +1144 -0
- lightrag/tools/download_cache.py +200 -0
- lightrag/tools/lightrag_visualizer/__init__.py +0 -0
- lightrag/tools/lightrag_visualizer/graph_visualizer.py +1221 -0
- lightrag/tools/migrate_llm_cache.py +1472 -0
- lightrag/tools/prepare_qdrant_legacy_data.py +720 -0
- lightrag/types.py +29 -0
- lightrag/utils.py +3460 -0
- lightrag/utils_graph.py +1760 -0
- lightrag_webui/node_modules/flatted/python/flatted.py +149 -0
- lightrag_webui/node_modules/katex/src/fonts/generate_fonts.py +58 -0
- lightrag_webui/node_modules/katex/src/metrics/extract_tfms.py +114 -0
- lightrag_webui/node_modules/katex/src/metrics/extract_ttfs.py +122 -0
- lightrag_webui/node_modules/katex/src/metrics/format_json.py +28 -0
- lightrag_webui/node_modules/katex/src/metrics/parse_tfm.py +211 -0
- lightrag_webui/node_modules/micromark-extension-math/node_modules/katex/src/fonts/generate_fonts.py +58 -0
- lightrag_webui/node_modules/micromark-extension-math/node_modules/katex/src/metrics/extract_tfms.py +114 -0
- lightrag_webui/node_modules/micromark-extension-math/node_modules/katex/src/metrics/extract_ttfs.py +122 -0
- lightrag_webui/node_modules/micromark-extension-math/node_modules/katex/src/metrics/format_json.py +28 -0
- lightrag_webui/node_modules/micromark-extension-math/node_modules/katex/src/metrics/parse_tfm.py +211 -0
- lightrag_webui/node_modules/rehype-katex/node_modules/katex/src/fonts/generate_fonts.py +58 -0
- lightrag_webui/node_modules/rehype-katex/node_modules/katex/src/metrics/extract_tfms.py +114 -0
- lightrag_webui/node_modules/rehype-katex/node_modules/katex/src/metrics/extract_ttfs.py +122 -0
- lightrag_webui/node_modules/rehype-katex/node_modules/katex/src/metrics/format_json.py +28 -0
- lightrag_webui/node_modules/rehype-katex/node_modules/katex/src/metrics/parse_tfm.py +211 -0
- meshrag-1.0.0.dist-info/METADATA +385 -0
- meshrag-1.0.0.dist-info/RECORD +207 -0
- meshrag-1.0.0.dist-info/WHEEL +5 -0
- meshrag-1.0.0.dist-info/entry_points.txt +5 -0
- meshrag-1.0.0.dist-info/licenses/LICENSE +21 -0
- meshrag-1.0.0.dist-info/licenses/NOTICE +12 -0
- meshrag-1.0.0.dist-info/top_level.txt +2 -0
lightrag/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from .lightrag import LightRAG as LightRAG, QueryParam as QueryParam
|
|
2
|
+
|
|
3
|
+
# MeshRAG's own version. The upstream lineage (forked from HKUDS/LightRAG
|
|
4
|
+
# v1.4.11) is recorded in CHANGELOG.md and the README files.
|
|
5
|
+
__version__ = "v1.0.0"
|
|
6
|
+
__author__ = "Zirui Guo"
|
|
7
|
+
__url__ = "https://github.com/tuxin-labs/meshrag"
|
lightrag/api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__api_version__ = "0274"
|
lightrag/api/auth.py
ADDED
|
@@ -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()
|