RamiAwar / dataline

Chat with your data - AI data analysis and visualization on CSV, Postgres, MySQL, Snowflake, SQLite...
https://dataline.app
GNU General Public License v3.0
129 stars 6 forks source link

Streaming response error support #216

Closed RamiAwar closed 1 week ago

RamiAwar commented 2 weeks ago

We want to be able to throw errors in the query route, but since it's a streaming response, the response status is already sent before the request begins. Then when I raise an error it becomes a Runtime error cause this isn't automatically handled.

I think we need to adjust the streaming response class to something that can try/capture errors and forward them to the frontend as events and then close the stream. Then also modify the frontend to handle those events as 'error events' and show the error snackbar with their details.

It's annoying cause now any error that's happening can't really propagate. We only see "error querying assistant". In snowflake at least, there are some errors that'll only show up when you're actually performing queries.

Idk if there's another way of dealing with this. This is just the first solution that popped to mind. Quick search of issues didn't show a better one.

https://github.com/tiangolo/fastapi/discussions/10138