jakob / Postico

Public issue tracking for Postico

Home Page:https://eggerapps.at/postico/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: schema-aware autocompletion with LLM

kyle-villeneuve opened this issue · comments

It seems like there are some very obvious autocompletions that can be inferred using a language model trained off of the schema of your database, let's say for instance you're writing a query such as
SELECT * FROM users JOIN .... an LLM would know the schema of your users table, see which foreign keys it has and which tables might be referencing it and populate a few autocompletions to join. Or, if you type JOIN table it would already know the foreign key relationship and write the clause for you. There seems to be a lot of low hanging fruit for improved autocompletion, not saying an LLM is the only way to achieve this but I've been very impressed by how good ChatGPT is at writing valid SQL with limited knowledge of your entire database schema. I think something running on the client would be a strict requirement for many, myself included, as I wouldn't want my database schema being sent out to 3rd parties.

I've wanted to add these kind of completions for a long time, because I think they are pretty straightforward to implement with basic if/else rules. A similar improvement would be eg. detecting comparisons and assignments to ENUM columns, and automatically suggesting values.

I don't think Postico needs LLM for basic completions like this. Postico already has a parser that should be able to do that with a few minor changes.

The reason why Postico doesn't have completions like this yet is that the auto-complete code is very complicated and I am a bit afraid to touch it, and there have always been more urgent things to work on.

I agree 100% an LLM model would be overkill for just autocompleting a join between two tables, my point is that it's just one of many different things an LLM could achieve to improve DX. And I think trying to hand-roll an autocompletion engine would ultimately be more difficult to achieve the same results as even a rudimentary implementation of an LLM.

To be honest, I have no idea what LLMs can do apart from playing a bit with ChatGPT. I'm sure they could be used for implementing autocomplete, but it's not something I am actively investigating.

All the examples I've seen so far (eg. https://sequal.dev, https://pgmagic.app) are based on the OpenAI API, which is not something that would work for Postico. A big differentiator of my app is that using it does not involve sending your data to cloud services, so adding a feature that sends your database schema, queries, and possibly data to a cloud service is not something I am eager to experiment with.

Local models would be a sweet option, but I lack the experience to use them. To my understanding they require lots of training data (that I don't have because I don't have access to my customers data), and the resulting models are typically gigabytes in size. Again, not something that is a good fit for Postico.

I'm not opposed to the idea of using LLMs in general, but right now my approach is to wait and see.