vanna-ai / vanna

🤖 Chat with your SQL database 📊. Accurate Text-to-SQL Generation via LLMs using RAG 🔄.
https://vanna.ai/docs/
MIT License
9.12k stars 673 forks source link

AttributeError: 'NoneType' object has no attribute 'questions' #465

Open anechii opened 1 month ago

anechii commented 1 month ago

I am getting an exception when running vn.ask on a linux server.

~ $ python
>>> import vanna
>>> from vanna.remote import VannaDefault
>>> vn = VannaDefault(model='chinook', api_key=vanna.get_api_key('my-email@example.com'))
>>> vn.connect_to_sqlite('https://vanna.ai/Chinook.sqlite')
>>> vn.ask('What are the top 10 artists by sales?')
'NoneType' object has no attribute 'questions'
(None, None, None)
>>> 

Is there a reason this code here returns a None value, inevitably causing this NoneType error ? What does it mean and how to prevent this from happening ? https://github.com/vanna-ai/vanna/blob/a72b842d420cf1fa061e5f97d45ea08051651ebb/src/vanna/vannadb/vannadb_vector.py#L190

anechii commented 1 month ago

update: When checking why the mentioned code was returning none, I was able to get this error out:

>>> vn_rpc_call(method="get_related_training_data", params=params)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'vn_rpc_call' is not defined
>>> vn._rpc_call(method="get_related_training_data", params=params)
**{'error': {'code': -32600, 'message': 'Invalid Request: No email'}, 'jsonrpc': '2.0'}**

A better exception + error message would be useful instead of returning None. What email though ?

anechii commented 1 month ago

Fixed: I made a typo in the API Key. I suggest improving the error handling here.

anechii commented 1 month ago

is it possible to contribute ? if so i would like to suggest a code snippet to better address the exception handling resulting in this issue.