calpoly-csai / api

Official API for the NIMBUS Voice Assistant accessible via HTTP REST protocol.
https://nimbus.api.calpolycsai.com/
GNU General Public License v3.0
9 stars 4 forks source link

When the NLP model doesn't find variables in the question, It throws error #169

Closed Waidhoferj closed 3 years ago

Waidhoferj commented 4 years ago
Traceback (most recent call last):
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/flask_api.py", line 129, in handle_question
    response = {"answer": nimbus.answer_question(question)}
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/nimbus.py", line 33, in answer_question
    ans_dict = self.predict_question(question)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/nimbus.py", line 65, in predict_question
    nlp_props = self.variable_extractor.extract_variables(question)
  File "/Users/johnwaidhofer/Desktop/Coding/Python/CSAI/api/nimbus_nlp/variable_extractor.py", line 75, in extract_variables
    entity = request.payload[0].text_extraction.text_segment.content
IndexError: list index (0) out of range
snekiam commented 4 years ago

Ideally, we shouldn't 500 when this happens, but handle the IndexError gracefully.