Spaces:
Running
Running
eaglelandsonce
commited on
Commit
•
5794470
1
Parent(s):
97aae78
Update pages/21_GraphRag.py
Browse files- pages/21_GraphRag.py +70 -60
pages/21_GraphRag.py
CHANGED
@@ -1,60 +1,70 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import sys
|
3 |
+
import subprocess
|
4 |
+
import importlib
|
5 |
+
|
6 |
+
st.title("GraphRAG Module Explorer")
|
7 |
+
|
8 |
+
# Function to install a package
|
9 |
+
def install_package(package):
|
10 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
11 |
+
|
12 |
+
# Check and install required packages
|
13 |
+
required_packages = ['graphrag', 'sentence_transformers']
|
14 |
+
for package in required_packages:
|
15 |
+
try:
|
16 |
+
importlib.import_module(package)
|
17 |
+
except ImportError:
|
18 |
+
st.write(f"Installing {package}...")
|
19 |
+
install_package(package)
|
20 |
+
st.write(f"{package} installed successfully.")
|
21 |
+
|
22 |
+
# Now try to import graphrag
|
23 |
+
try:
|
24 |
+
import graphrag
|
25 |
+
import inspect
|
26 |
+
|
27 |
+
# Display all attributes and functions in the graphrag module
|
28 |
+
st.header("GraphRAG Module Contents")
|
29 |
+
graphrag_contents = dir(graphrag)
|
30 |
+
|
31 |
+
for item in graphrag_contents:
|
32 |
+
attr = getattr(graphrag, item)
|
33 |
+
st.subheader(f"{item}")
|
34 |
+
st.write(f"Type: {type(attr)}")
|
35 |
+
|
36 |
+
if inspect.isclass(attr):
|
37 |
+
st.write("Class Methods:")
|
38 |
+
for name, method in inspect.getmembers(attr, predicate=inspect.isfunction):
|
39 |
+
st.write(f"- {name}")
|
40 |
+
st.write(f" Signature: {inspect.signature(method)}")
|
41 |
+
st.write(f" Docstring: {method.__doc__}")
|
42 |
+
|
43 |
+
elif inspect.isfunction(attr):
|
44 |
+
st.write("Function:")
|
45 |
+
st.write(f"Signature: {inspect.signature(attr)}")
|
46 |
+
st.write(f"Docstring: {attr.__doc__}")
|
47 |
+
|
48 |
+
elif isinstance(attr, (int, float, str, bool)):
|
49 |
+
st.write(f"Value: {attr}")
|
50 |
+
|
51 |
+
st.write("---")
|
52 |
+
|
53 |
+
# Display the module's docstring if available
|
54 |
+
if graphrag.__doc__:
|
55 |
+
st.header("GraphRAG Module Documentation")
|
56 |
+
st.write(graphrag.__doc__)
|
57 |
+
|
58 |
+
st.header("Next Steps")
|
59 |
+
st.write("""
|
60 |
+
Based on the information above, we need to determine:
|
61 |
+
1. How to create a graph representation of text using graphrag.
|
62 |
+
2. How to process this graph representation for analysis.
|
63 |
+
3. Whether graphrag provides any built-in analysis tools or if we need to integrate it with other libraries.
|
64 |
+
|
65 |
+
Please review the module contents and let me know which components seem most relevant for our text analysis task.
|
66 |
+
""")
|
67 |
+
|
68 |
+
except Exception as e:
|
69 |
+
st.error(f"An error occurred while exploring the graphrag module: {str(e)}")
|
70 |
+
st.write("Please check the installation of graphrag and its dependencies, and try running the app again.")
|