MCPcopy Create free account
hub / github.com/NanGePlus/LightRAGTest / insert_file

Function insert_file

LightRAG/examples/lightrag_api_oracle_demo..py:229–247  ·  view source on GitHub ↗
(file: UploadFile = File(...))

Source from the content-addressed store, hash-verified

227
228@app.post("/insert_file", response_model=Response)
229async def insert_file(file: UploadFile = File(...)):
230 try:
231 file_content = await file.read()
232 # Read file content
233 try:
234 content = file_content.decode("utf-8")
235 except UnicodeDecodeError:
236 # If UTF-8 decoding fails, try other encodings
237 content = file_content.decode("gbk")
238 # Insert file content
239 loop = asyncio.get_event_loop()
240 await loop.run_in_executor(None, lambda: rag.insert(content))
241
242 return Response(
243 status="success",
244 message=f"File content from {file.filename} inserted successfully",
245 )
246 except Exception as e:
247 raise HTTPException(status_code=500, detail=str(e))
248
249
250@app.get("/health")

Callers

nothing calls this directly

Calls 2

insertMethod · 0.80
ResponseClass · 0.70

Tested by

no test coverage detected