kg-rag 0.1.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.
- kg_rag-0.1.0/.env +3 -0
- kg_rag-0.1.0/.gitignore +4 -0
- kg_rag-0.1.0/.vscode/mcp.json +4 -0
- kg_rag-0.1.0/.vscode/settings.json +8 -0
- kg_rag-0.1.0/PKG-INFO +154 -0
- kg_rag-0.1.0/README.md +113 -0
- kg_rag-0.1.0/Untitled-1.ipynb +617 -0
- kg_rag-0.1.0/app.py +383 -0
- kg_rag-0.1.0/data/BR01_Brazil_KOL.docx +0 -0
- kg_rag-0.1.0/data/CN01_China_KOL.docx +0 -0
- kg_rag-0.1.0/data/CN01_China_KOL.xlsx +0 -0
- kg_rag-0.1.0/data/Chaz Washington Interview Yong RAG.docx +0 -0
- kg_rag-0.1.0/data/Interview_1 1.docx +0 -0
- kg_rag-0.1.0/data/KG-RAG.xlsx +0 -0
- kg_rag-0.1.0/data/Libby Meskie Interview.docx +0 -0
- kg_rag-0.1.0/data/UC_CD_Australia.docx +0 -0
- kg_rag-0.1.0/data/UC_CD_Brazil.docx +0 -0
- kg_rag-0.1.0/dockerfile +43 -0
- kg_rag-0.1.0/environment.yml +22 -0
- kg_rag-0.1.0/kgrag/__init__.py +11 -0
- kg_rag-0.1.0/kgrag/chunking.py +52 -0
- kg_rag-0.1.0/kgrag/community.py +171 -0
- kg_rag-0.1.0/kgrag/config.py +28 -0
- kg_rag-0.1.0/kgrag/extract_entity.py +55 -0
- kg_rag-0.1.0/kgrag/helper.py +91 -0
- kg_rag-0.1.0/kgrag/loader.py +9 -0
- kg_rag-0.1.0/kgrag/logger.py +24 -0
- kg_rag-0.1.0/kgrag/operations.py +325 -0
- kg_rag-0.1.0/kgrag/prompts.yaml +136 -0
- kg_rag-0.1.0/kgrag/rag.py +185 -0
- kg_rag-0.1.0/kgrag/schema.py +156 -0
- kg_rag-0.1.0/kgrag/state.py +99 -0
- kg_rag-0.1.0/mcp_config.json +12 -0
- kg_rag-0.1.0/mcp_server.py +247 -0
- kg_rag-0.1.0/pyproject.toml +131 -0
- kg_rag-0.1.0/rag.db +0 -0
- kg_rag-0.1.0/simplerag/config.py +20 -0
- kg_rag-0.1.0/simplerag/helper.py +31 -0
- kg_rag-0.1.0/simplerag/logger.py +24 -0
- kg_rag-0.1.0/simplerag/operations.py +146 -0
- kg_rag-0.1.0/simplerag/rag.py +62 -0
- kg_rag-0.1.0/uv.lock +3641 -0
- kg_rag-0.1.0/vector_store.py +135 -0
kg_rag-0.1.0/.env
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
AWS_ACCESS_KEY_ID=ASIAVUPQWCEVZBUYND3S
|
|
2
|
+
AWS_SECRET_ACCESS_KEY=J9Fxd56STR9AhrQ8yxcYLPhoWOdKIgy6FcFGPuYC
|
|
3
|
+
AWS_SESSION_TOKEN=IQoJb3JpZ2luX2VjEE0aCXVzLWVhc3QtMSJGMEQCIHP/w89IFlVHlgTSCWDNorEOdZjzvftAozzUHz/UOxemAiBygtzuGwoZj5DDBkoiBGbwoRMfQxkbyjIaQR1IHwVDZCqUAwiG//////////8BEAIaDDM4NzU4ODY5MDIxOSIMl4XoU0X/e00/Iyi3KugC8djZGJbl/gN8emlKMH3+FKbMHn9TpZ851JIhEatjeXsyLszxhqaw5KqSc2hOZvVw7KN4BlG94w6HH99mTtCH8g62tSdvK2pcd0smau1L3kwFLgfsEZiFKlbCFG6+5uqJwasbwQxNsyf99fwOICYxEwjy4f2xr4+hs9uNZ8TwX0AxywxYf2XHeEsXmO87wRxx+sSwvPnqysoBzJc2CN7J/3dKpFS16tVDx+VVcAjcVtVYQJ+rbGBgHF233tRE4JRv6itbE9lWt7BhJluiebXQ6mdXr6t0d7f5DYz0pxwkhs+gZPdLCMLLdC/RhRzAff1VGx9RMm1ARJ3mMmum6F3Op5knq8oUxe6+YfG31tLejXy9gta8/5PopZnwLH0a0wsC3XDwtAKpVgurVogHZXYfbQVaKOa/HFtR01FQ41rxNr3Hnd698xpWsq926mtDvYuJv6o1K5PQ3fI/fv/XnzVdtfKpNr6R9TviMPbW0MQGOqcByy8ZHxkG+M/lsPpZu+KGQC6OWHpW4oAVytCbaMmSrM4DuIwZVoJc3fL5PZ/VUYbVg0/m9pcN7OaFycC/tLC+b8vtk1qaTMU7Z/NFXV+hGsrBG1SvMUu04Y9uyjJNeMDLP3H85RUz3UaenYUZYgKMP+4pxVkLY1VS6Nf9ay0EdHo/rX9NLmWiR39U9eJcMmw0zQaMW+1ZJTB93OWWWF1tqhsPTIYVETY=
|
kg_rag-0.1.0/.gitignore
ADDED
kg_rag-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kg-rag
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Knowledge Graph-based RAG system with MCP server integration
|
|
5
|
+
Project-URL: Homepage, https://github.com/prout/kg-rag
|
|
6
|
+
Project-URL: Repository, https://github.com/prout/kg-rag
|
|
7
|
+
Project-URL: Issues, https://github.com/prout/kg-rag/issues
|
|
8
|
+
Author-email: prout <thepuspak@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: azure-identity
|
|
20
|
+
Requires-Dist: fastmcp
|
|
21
|
+
Requires-Dist: graspologic
|
|
22
|
+
Requires-Dist: litellm
|
|
23
|
+
Requires-Dist: markitdown
|
|
24
|
+
Requires-Dist: nest-asyncio
|
|
25
|
+
Requires-Dist: networkx
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: pandas
|
|
28
|
+
Requires-Dist: pydantic
|
|
29
|
+
Requires-Dist: python-dotenv
|
|
30
|
+
Requires-Dist: sqlalchemy
|
|
31
|
+
Requires-Dist: sqlmodel
|
|
32
|
+
Requires-Dist: streamlit
|
|
33
|
+
Requires-Dist: tenacity
|
|
34
|
+
Requires-Dist: tiktoken
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
39
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# KnowledgeGraphRAG with MCP Server
|
|
43
|
+
|
|
44
|
+
A Knowledge Graph-based RAG system with a modern MCP server for seamless integration with MCP-compatible clients like Claude Desktop.
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### 1. Install Dependencies
|
|
49
|
+
```bash
|
|
50
|
+
pip install -r requirements.txt
|
|
51
|
+
pip install fastmcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Test the Setup
|
|
55
|
+
```bash
|
|
56
|
+
python test_mcp.py
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Start the MCP Server
|
|
60
|
+
```bash
|
|
61
|
+
# Direct execution
|
|
62
|
+
python mcp_server.py
|
|
63
|
+
|
|
64
|
+
# Using startup scripts
|
|
65
|
+
# Windows:
|
|
66
|
+
start_mcp_server.bat
|
|
67
|
+
|
|
68
|
+
# Unix/Linux/macOS:
|
|
69
|
+
./start_mcp_server.sh
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. Configure Claude Desktop
|
|
73
|
+
Add to your Claude Desktop configuration:
|
|
74
|
+
|
|
75
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
76
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"knowledgegraph-rag": {
|
|
82
|
+
"command": "python",
|
|
83
|
+
"args": ["C:/path/to/kg-rag/mcp_server.py"],
|
|
84
|
+
"cwd": "C:/path/to/kg-rag"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Core Files
|
|
91
|
+
|
|
92
|
+
### MCP Server
|
|
93
|
+
- **`mcp_server.py`** - Main MCP server implementation
|
|
94
|
+
- **`test_mcp.py`** - Test script for the MCP server
|
|
95
|
+
- **`setup_mcp.py`** - Automated dependency installation
|
|
96
|
+
|
|
97
|
+
### Configuration & Startup
|
|
98
|
+
- **`mcp_config.json`** - Claude Desktop configuration template
|
|
99
|
+
- **`start_mcp_server.bat`** - Windows startup script
|
|
100
|
+
- **`start_mcp_server.sh`** - Unix startup script
|
|
101
|
+
|
|
102
|
+
### Documentation
|
|
103
|
+
- **`FASTMCP_GUIDE.md`** - Comprehensive setup and usage guide
|
|
104
|
+
|
|
105
|
+
### KnowledgeGraphRAG Core
|
|
106
|
+
- **`kgrag/`** - Core RAG system implementation
|
|
107
|
+
- **`requirements.txt`** - Python dependencies
|
|
108
|
+
- **`rag.db`** - SQLite database for the knowledge graph
|
|
109
|
+
|
|
110
|
+
## Available Tools
|
|
111
|
+
|
|
112
|
+
- **index_document** - Index documents into the knowledge graph
|
|
113
|
+
- **query_documents** - Query and get AI-generated answers
|
|
114
|
+
- **list_documents** - List all indexed documents
|
|
115
|
+
- **remove_document** - Remove documents from the knowledge graph
|
|
116
|
+
- **get_document_stats** - Get document statistics
|
|
117
|
+
|
|
118
|
+
## Available Resources
|
|
119
|
+
|
|
120
|
+
- **knowledgegraph://document/{doc_name}** - Dynamic document resources
|
|
121
|
+
|
|
122
|
+
## Available Prompts
|
|
123
|
+
|
|
124
|
+
- **generate_query_prompt** - Generate prompts for querying topics
|
|
125
|
+
- **analyze_document_prompt** - Generate prompts for document analysis
|
|
126
|
+
|
|
127
|
+
## Example Usage
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
User: List the documents in the knowledge graph
|
|
131
|
+
Assistant: 📚 Documents in knowledge graph (2 total):
|
|
132
|
+
- Research Paper 2024
|
|
133
|
+
- Q1 Report
|
|
134
|
+
|
|
135
|
+
User: What are the key findings in the Research Paper 2024?
|
|
136
|
+
Assistant: 💬 Answer to 'What are the key findings in the Research Paper 2024?':
|
|
137
|
+
[AI-generated response based on the knowledge graph]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
1. **Import Errors**: Run `python test_mcp.py` to check setup
|
|
143
|
+
2. **Server Issues**: Check that `kgrag` module is accessible
|
|
144
|
+
3. **Claude Integration**: Verify paths in Claude Desktop config
|
|
145
|
+
|
|
146
|
+
For detailed information, see `FASTMCP_GUIDE.md`.
|
|
147
|
+
|
|
148
|
+
## Architecture
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
Claude Desktop → MCP Server → KnowledgeGraphRAG → SQLite Database
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The MCP server provides a clean, type-safe interface to the KnowledgeGraphRAG system with minimal boilerplate code.
|
kg_rag-0.1.0/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# KnowledgeGraphRAG with MCP Server
|
|
2
|
+
|
|
3
|
+
A Knowledge Graph-based RAG system with a modern MCP server for seamless integration with MCP-compatible clients like Claude Desktop.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Install Dependencies
|
|
8
|
+
```bash
|
|
9
|
+
pip install -r requirements.txt
|
|
10
|
+
pip install fastmcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 2. Test the Setup
|
|
14
|
+
```bash
|
|
15
|
+
python test_mcp.py
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 3. Start the MCP Server
|
|
19
|
+
```bash
|
|
20
|
+
# Direct execution
|
|
21
|
+
python mcp_server.py
|
|
22
|
+
|
|
23
|
+
# Using startup scripts
|
|
24
|
+
# Windows:
|
|
25
|
+
start_mcp_server.bat
|
|
26
|
+
|
|
27
|
+
# Unix/Linux/macOS:
|
|
28
|
+
./start_mcp_server.sh
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 4. Configure Claude Desktop
|
|
32
|
+
Add to your Claude Desktop configuration:
|
|
33
|
+
|
|
34
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
35
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"knowledgegraph-rag": {
|
|
41
|
+
"command": "python",
|
|
42
|
+
"args": ["C:/path/to/kg-rag/mcp_server.py"],
|
|
43
|
+
"cwd": "C:/path/to/kg-rag"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Core Files
|
|
50
|
+
|
|
51
|
+
### MCP Server
|
|
52
|
+
- **`mcp_server.py`** - Main MCP server implementation
|
|
53
|
+
- **`test_mcp.py`** - Test script for the MCP server
|
|
54
|
+
- **`setup_mcp.py`** - Automated dependency installation
|
|
55
|
+
|
|
56
|
+
### Configuration & Startup
|
|
57
|
+
- **`mcp_config.json`** - Claude Desktop configuration template
|
|
58
|
+
- **`start_mcp_server.bat`** - Windows startup script
|
|
59
|
+
- **`start_mcp_server.sh`** - Unix startup script
|
|
60
|
+
|
|
61
|
+
### Documentation
|
|
62
|
+
- **`FASTMCP_GUIDE.md`** - Comprehensive setup and usage guide
|
|
63
|
+
|
|
64
|
+
### KnowledgeGraphRAG Core
|
|
65
|
+
- **`kgrag/`** - Core RAG system implementation
|
|
66
|
+
- **`requirements.txt`** - Python dependencies
|
|
67
|
+
- **`rag.db`** - SQLite database for the knowledge graph
|
|
68
|
+
|
|
69
|
+
## Available Tools
|
|
70
|
+
|
|
71
|
+
- **index_document** - Index documents into the knowledge graph
|
|
72
|
+
- **query_documents** - Query and get AI-generated answers
|
|
73
|
+
- **list_documents** - List all indexed documents
|
|
74
|
+
- **remove_document** - Remove documents from the knowledge graph
|
|
75
|
+
- **get_document_stats** - Get document statistics
|
|
76
|
+
|
|
77
|
+
## Available Resources
|
|
78
|
+
|
|
79
|
+
- **knowledgegraph://document/{doc_name}** - Dynamic document resources
|
|
80
|
+
|
|
81
|
+
## Available Prompts
|
|
82
|
+
|
|
83
|
+
- **generate_query_prompt** - Generate prompts for querying topics
|
|
84
|
+
- **analyze_document_prompt** - Generate prompts for document analysis
|
|
85
|
+
|
|
86
|
+
## Example Usage
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
User: List the documents in the knowledge graph
|
|
90
|
+
Assistant: 📚 Documents in knowledge graph (2 total):
|
|
91
|
+
- Research Paper 2024
|
|
92
|
+
- Q1 Report
|
|
93
|
+
|
|
94
|
+
User: What are the key findings in the Research Paper 2024?
|
|
95
|
+
Assistant: 💬 Answer to 'What are the key findings in the Research Paper 2024?':
|
|
96
|
+
[AI-generated response based on the knowledge graph]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Troubleshooting
|
|
100
|
+
|
|
101
|
+
1. **Import Errors**: Run `python test_mcp.py` to check setup
|
|
102
|
+
2. **Server Issues**: Check that `kgrag` module is accessible
|
|
103
|
+
3. **Claude Integration**: Verify paths in Claude Desktop config
|
|
104
|
+
|
|
105
|
+
For detailed information, see `FASTMCP_GUIDE.md`.
|
|
106
|
+
|
|
107
|
+
## Architecture
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
Claude Desktop → MCP Server → KnowledgeGraphRAG → SQLite Database
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The MCP server provides a clean, type-safe interface to the KnowledgeGraphRAG system with minimal boilerplate code.
|