daodao97 / chatdoc

Chat with your doc by openai
456 stars 105 forks source link

Backend container error #41

Open a-mian-lateral opened 1 year ago

a-mian-lateral commented 1 year ago

Hi, I'm trying to run the application in a local environment, but when I run the command docker-compose up --build docker start to build the container but after a while it fails and returns this error

Traceback (most recent call last): File "/data/main.py", line 3, in <module> from doc_util import Doc File "/data/doc_util.py", line 19, in <module> CJKPDFReader = download_loader("CJKPDFReader") File "/usr/local/lib/python3.9/site-packages/llama_index/readers/download.py", line 125, in download_loader library = json.loads(library_raw_content) File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.9/json/decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 4 (char 3)

Can someone help with this issue? Am I doing something wrong?

kotnibf commented 1 year ago

The error message suggests that the JSON data being loaded is incorrect, containing extra data. You can fix this issue by identifying and correcting the JSON file.

Here's how you can do it:

  1. Identify the JSON file causing the error. In your case, it's likely in the method download_loader("CJKPDFReader") within /usr/local/lib/python3.9/site-packages/llama_index/readers/download.py. Inspect the file to find out which JSON it's trying to load.

  2. Once you have found the JSON file or string, validate its content using a JSON validator (such as JSONLint). If there are errors in the JSON content, correct them until the validator shows no issues.

To demonstrate, let's assume your JSON file contains the following:

{"key": "value"}{"key2": "value2"}

This JSON content is incorrect because it has two separate objects without any delimiter. To correct this, either separate them with a comma and wrap them in an array, like so:

[
  {"key": "value"},
  {"key2": "value2"}
]

Or merge them into a single object, like this:

{
  "key": "value",
  "key2": "value2"
}
  1. After fixing the JSON content, save the changes and re-run the docker-compose up --build command. This should resolve the error.

Hope to solve the problem with this advice. Good luck

a-mian-lateral commented 1 year ago

Looks that the json file is being downloaded from an url get_file_content(loader_hub_url, "/library.json") The complete url is https://raw.githubusercontent.com/emptycrown/loader-hub/main/loader_hub/library.json, and returns a 404.

kotnibf commented 1 year ago

I see. Maybe you need to reset the docker by yourself.

a-mian-lateral commented 1 year ago

I don't know, I already deleted and recreated the containers (also with different versions of python) multiple times and also tried to run the application with python without docker. I tried also to create the container in different os, Windows, Ubuntu and in WSL. Anyway I don't see a reason why I should edit a library, that url is not generated on my data but is hard coded so I think the problem is the library or the way its used.

kotnibf commented 1 year ago

Then, I don't know too. I am really sorry