mommi84 / rdf-qa

Explainable complex question answering over RDF files via Llama Index.
MIT License
31 stars 4 forks source link

Error while running the example #1

Open javiersorucol opened 1 year ago

javiersorucol commented 1 year ago

Hi! I'm trying to test this using the exmple.nt file, when I try to do so in the Webapp I get the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback:

File "/usr/local/lib/python3.10/dist-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
File "/home/javi/Desktop/rdf-qa/app.py", line 35, in <module>
    render_gui()
File "/home/javi/Desktop/rdf-qa/app.py", line 24, in render_gui
    data = requests.post("http://localhost:5050/index", files={'file': uploaded_file}).json()
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

After some review, I've found that this is due the Webapp is receiving response 500, therefore, I've checked only the server with the following code:

import requests

files = {'file': open('./rdf-qa/example.nt','rb')}
r = requests.post('http://localhost:5050/index', files=files)

The received answer is:

<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

And the server shows the following error:

ERROR:server:Exception on /index [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/javi/Desktop/rdf-qa/server.py", line 28, in upload_and_index
    index = GPTSimpleVectorIndex(document)
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/vector_store/vector_indices.py", line 94, in __init__
    super().__init__(
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/vector_store/base.py", line 58, in __init__
    super().__init__(
  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/base.py", line 56, in __init__
    raise ValueError(
ValueError: The constructor now takes in a list of Node objects. Since you are passing in a list of Document objects, please use `from_documents` instead.
INFO:werkzeug:127.0.0.1 - - [03/Apr/2023 12:04:38] "POST /index HTTP/1.1" 500 -

Am I doing something wrong? or maybe missing the version of some package? The received file is properly being stored in the uploads folder, but the error seems to be triggered on the following line:

        index = GPTSimpleVectorIndex(document)
mommi84 commented 1 year ago

Hi, I believe the Llama Index library introduced breaking changes. Try installing llama-index==0.4.20.

javiersorucol commented 1 year ago

I've modfied the llama-index version:

Name: llama-index

Version: 0.4.20

Summary: Interface between LLMs and your data.

Home-page: https://github.com/jerryjliu/gpt_index

Author: 

Author-email: 

License: MIT

Location: /home/javi/.local/lib/python3.10/site-packages

Requires: dataclasses-json, langchain, nltk, numpy, openai, pandas, tenacity, tiktoken, transformers

Required-by: 

But I still get the same issue:

ERROR:server:Exception on /index [POST]

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2528, in wsgi_app

    response = self.full_dispatch_request()

  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1825, in full_dispatch_request

    rv = self.handle_user_exception(e)

  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1823, in full_dispatch_request

    rv = self.dispatch_request()

  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1799, in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)

  File "/home/javi/Desktop/work/rdf-qa/./server.py", line 28, in upload_and_index

    index = GPTSimpleVectorIndex(document)

  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/vector_store/vector_indices.py", line 94, in __init__

    super().__init__(

  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/vector_store/base.py", line 58, in __init__

    super().__init__(

  File "/usr/local/lib/python3.10/dist-packages/llama_index/indices/base.py", line 56, in __init__

    raise ValueError(

ValueError: The constructor now takes in a list of Node objects. Since you are passing in a list of Document objects, please use `from_documents` instead.

INFO:werkzeug:127.0.0.1 - - [04/Apr/2023 16:59:25] "POST /index HTTP/1.1" 500 -