HKUDS / LightRAG

"LightRAG: Simple and Fast Retrieval-Augmented Generation"
https://arxiv.org/abs/2410.05779
MIT License
9.26k stars 1.14k forks source link

[Bug] Incorrect documentation for file upload in /insert_file endpoint #236

Open DHengW opened 1 week ago

DHengW commented 1 week ago

Description:

When following the provided documentation for uploading a file to the /insert_file endpoint, I encountered an error. The documentation suggests using a JSON body with a file_path field, but this results in a 422 Unprocessable Entity error. After some investigation, I found that the correct way to upload a file is by using the -F option in curl to specify the file directly.

Steps to Reproduce:

  1. Follow the provided documentation to upload a file:

    curl -X POST "http://127.0.0.1:8020/insert_file" \
        -H "Content-Type: application/json" \
        -d '{"file_path": "./book.txt"}'
  2. Observe the following errors:

    • Server Error:
      127.0.0.1:57274 - "POST /insert_file HTTP/1.1" 422 Unprocessable Entity
    • Client Error:
      {
      "detail": [
       {
         "type": "missing",
         "loc": ["body", "file"],
         "msg": "Field required",
         "input": null
       }
      ]
      }

Correct Usage:

To correctly upload a file to the /insert_file endpoint, use the following curl command:

curl -X POST "http://127.0.0.1:8020/insert_file" -F "file=@path/to/your/example.txt"

Expected Behavior:

The server should accept the file and return a success response, such as:

{
  "status": "success",
  "message": "File content from example.txt inserted successfully"
}

Additional Information:

Suggested Fix:

Update the documentation to reflect the correct usage of the /insert_file endpoint. Specifically, change the example curl command to use the -F option for file upload.

Thank you for your attention to this issue.


suercxx commented 1 week ago

这个怎么上传其他类型的文件啊