From 5c679384671d716efc24bcddd5bade5b384f6e9a Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 12 Jan 2025 12:46:23 +0100 Subject: [PATCH 1/2] Resolve 500 error caused by missing len() for LightRAG's API insert_text endpoint --- lightrag/api/lightrag_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 644e622d..d29b8b56 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -487,7 +487,7 @@ def create_app(args): return InsertResponse( status="success", message="Text successfully inserted", - document_count=len(rag), + document_count=1, ) except Exception as e: raise HTTPException(status_code=500, detail=str(e)) From 7aaab219eed17b2e8790fe502b58bb129a35606d Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 12 Jan 2025 12:56:08 +0100 Subject: [PATCH 2/2] Fixed awaiting insert --- lightrag/api/lightrag_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index d29b8b56..5bcb149c 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -483,7 +483,7 @@ def create_app(args): ) async def insert_text(request: InsertTextRequest): try: - rag.insert(request.text) + await rag.ainsert(request.text) return InsertResponse( status="success", message="Text successfully inserted",