import os import asyncio from lightrag.kg.postgres_impl import PGGraphStorage from lightrag.utils import EmbeddingFunc from Config.Config import EMBED_DIM, EMBED_MAX_TOKEN_SIZE from Util.LightRagUtil import embedding_func ######### # Uncomment the below two lines if running in a jupyter notebook to handle the async nature of rag.insert() # import nest_asyncio # nest_asyncio.apply() ######### WORKING_DIR = "./local_neo4jWorkDir" if not os.path.exists(WORKING_DIR): os.mkdir(WORKING_DIR) # AGE os.environ["AGE_GRAPH_NAME"] = "dickens" os.environ["POSTGRES_HOST"] = "10.10.14.208" os.environ["POSTGRES_PORT"] = "5432" os.environ["POSTGRES_USER"] = "postgres" os.environ["POSTGRES_PASSWORD"] = "postgres" os.environ["POSTGRES_DATABASE"] = "rag" async def main(): graph_db = PGGraphStorage( namespace="dickens", embedding_func=EmbeddingFunc( embedding_dim=EMBED_DIM, max_token_size=EMBED_MAX_TOKEN_SIZE, func=embedding_func ), global_config={}, ) await graph_db.initialize() labels = await graph_db.get_all_labels() print("all labels", labels) res = await graph_db.get_knowledge_graph("FEZZIWIG") print("knowledge graphs", res) await graph_db.finalize() if __name__ == "__main__": asyncio.run(main())