From 697401fdc31d47209c1b92e67f44f63129967dbd Mon Sep 17 00:00:00 2001 From: yangdx Date: Sun, 20 Apr 2025 21:39:51 +0800 Subject: [PATCH] Change OpenAI demo to asyc --- examples/lightrag_openai_demo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/lightrag_openai_demo.py b/examples/lightrag_openai_demo.py index 138b31a2..39068a1d 100644 --- a/examples/lightrag_openai_demo.py +++ b/examples/lightrag_openai_demo.py @@ -24,41 +24,41 @@ async def initialize_rag(): return rag -def main(): +async def main(): # Initialize RAG instance - rag = asyncio.run(initialize_rag()) + rag = await initialize_rag() with open("./book.txt", "r", encoding="utf-8") as f: - rag.insert(f.read()) + await rag.ainsert(f.read()) # Perform naive search print( - rag.query( + await rag.aquery( "What are the top themes in this story?", param=QueryParam(mode="naive") ) ) # Perform local search print( - rag.query( + await rag.aquery( "What are the top themes in this story?", param=QueryParam(mode="local") ) ) # Perform global search print( - rag.query( + await rag.aquery( "What are the top themes in this story?", param=QueryParam(mode="global") ) ) # Perform hybrid search print( - rag.query( + await rag.aquery( "What are the top themes in this story?", param=QueryParam(mode="hybrid") ) ) if __name__ == "__main__": - main() + asyncio.run(main())