import streamlit as st import sys import subprocess import importlib st.title("GraphRAG Module Explorer") # Function to install a package def install_package(package): subprocess.check_call([sys.executable, "-m", "pip", "install", package]) # Check and install required packages required_packages = ['graphrag', 'sentence_transformers'] for package in required_packages: try: importlib.import_module(package) except ImportError: st.write(f"Installing {package}...") install_package(package) st.write(f"{package} installed successfully.") # Now try to import graphrag try: import graphrag import inspect # Display all attributes and functions in the graphrag module st.header("GraphRAG Module Contents") graphrag_contents = dir(graphrag) for item in graphrag_contents: attr = getattr(graphrag, item) st.subheader(f"{item}") st.write(f"Type: {type(attr)}") if inspect.isclass(attr): st.write("Class Methods:") for name, method in inspect.getmembers(attr, predicate=inspect.isfunction): st.write(f"- {name}") st.write(f" Signature: {inspect.signature(method)}") st.write(f" Docstring: {method.__doc__}") elif inspect.isfunction(attr): st.write("Function:") st.write(f"Signature: {inspect.signature(attr)}") st.write(f"Docstring: {attr.__doc__}") elif isinstance(attr, (int, float, str, bool)): st.write(f"Value: {attr}") st.write("---") # Display the module's docstring if available if graphrag.__doc__: st.header("GraphRAG Module Documentation") st.write(graphrag.__doc__) st.header("Next Steps") st.write(""" Based on the information above, we need to determine: 1. How to create a graph representation of text using graphrag. 2. How to process this graph representation for analysis. 3. Whether graphrag provides any built-in analysis tools or if we need to integrate it with other libraries. Please review the module contents and let me know which components seem most relevant for our text analysis task. """) except Exception as e: st.error(f"An error occurred while exploring the graphrag module: {str(e)}") st.write("Please check the installation of graphrag and its dependencies, and try running the app again.")