Querying HiveSQL with AI: Goodbye Complex SQLs!

in HiveDevs2 months ago

Hey there, HiveDevs!

Yesterday I needed to query HiveSQL to get some statistics from PixBee, and I had an idea: why not use AI to create these SQL queries automatically?

The idea came and soon it will no longer be necessary to write complex SQLs to query HiveSQL. With the help of AI, we will be able to ask questions in a more human way and get direct answers.

For example, instead of writing this:

SELECT COUNT(*)
FROM Comments
WHERE author = 'vaipraonde'
AND json_metadata IS NOT NULL
AND json_metadata LIKE '%"hivebr"%'
AND title! = '';

You can simply ask:

!aiquery COUNT how many comments does the user vaipraonde have with json_metadata containing hivebr whose title is not ""?

Or instead of:

SELECT TOP 100 [delegate]
FROM Delegations
WHERE [delegate] IN ('steemskate', 'skatehive');

Simply:

!aiquery lists all delegates for steemskate and skatehive

With the help of @mengao, who already has a bot that queries HiveSQL via Discord, I made a fork, created my HiveSQL account and implemented AI to make searches easier.

After some testing, both with simple queries and with some more complex ones, I managed to get great results.

I believe it will be ready soon! This first version is still a bit "quick and dirty", but I will refactor the code, create more configurations for choosing LLM models, perhaps include more providers and, of course, make the source code available to the community soon.

Here's the spoiler! If you liked the idea, leave a like to encourage me! 🚀

follow at:
https://github.com/rferrari/HiveSQLDiscordBot


Few examples from tests:

image.png

image.png

image.png



Fala, HiveDevs!

Ontem precisei consultar o HiveSQL para obter algumas estatísticas da PixBee, e fiquei me perguntando: por que não usar IA para criar essas queries SQL automaticamente?

A ideia surgiu e logo menos não será mais necessário escrever SQLs complexas para consultar o HiveSQL. Com a ajuda da IA, poderemos fazer perguntas de forma mais humana e obter respostas diretas.

Por exemplo, em vez de escrever isso:

SELECT COUNT(*)
FROM Comments
WHERE author = 'vaipraonde'
AND json_metadata IS NOT NULL
AND json_metadata LIKE '%"hivebr"%'
AND title != '';

Bastará perguntar:

!aiquery COUNT how many comments user vaipraonde has with json_metadata that contain hivebr that the title is not ""?

Ou em vez de:

SELECT TOP 100 [delegatee]
FROM Delegations
WHERE [delegatee] IN ('steemskate', 'skatehive');

Simplesmente:

!aiquery list all delegatee to steemskate and skatehive

Com a ajuda do @mengao, que já tem um bot que faz consultas no HiveSQL pelo Discord, fiz um fork, criei minha conta no HiveSQL e implementei IA para facilitar as buscas.

Depois de alguns testes, tanto com queries simples quanto com algumas mais complexas, consegui obter ótimos resultados.

Acredito que logo menos estará pronto! Essa primeira versão ainda está meio "quick and dirty", mas vou refatorar o código, criar mais configurações para escolha de modelos LLM, talvez incluir mais providers e, claro, disponibilizar o código-fonte para a comunidade em breve.

Fica aqui o spoiler! Se curtiu a ideia, deixa um like para me incentivar! 🚀

follow at:
https://github.com/rferrari/HiveSQLDiscordBot



Sort:  

Utilização interessante de pesquisa direta ao SQL. Parabéns

tks! i think its almost ready, now we need to fine tune it for different queries, models, and stuff...

sometimes model get confused about transfers and transactions, we have both table on database... so, need a little bit tweek. but in general, its working good.

even for some more complex queries, using the database schema....

i did some optimizations to do not send all tables and scheme to the model, cause just it is like 15.000 tokens... so, it cant be that expensive to run a simple query

Poxa que coisa legal!
Isso vai poder ser invocado, por exemplo, no discor da comunidade hivebr?
!TOP
!BBH
!LOL

I hope Elon Mush never gets invloved in a scandal
Elongate could be really drawn out.

Credit: mrhuman88
$LOLZ on behalf of crazyphantombr

(3/10)
Delegate Hive Tokens to Farm $LOLZ and earn 110% Rewards. Learn more.@vaipraonde, I sent you an

Bzzzrrr! Ai, mais uma vez @[vaipraonde] brilhando com seu toque de magia no mundo da HiveSQL! ❤️ Espero que esta feature seja implementada rapidamente, vou ter que dizer adeus às fórmulas complexas! 🤖

#hivebr

AI generated content
Commands: !pixbee stop | !pixbee start | !pixbee price

Obrigado por promover a comunidade Hive-BR em suas postagens.

Vamos seguir fortalecendo a Hive

Metade das recompensas dessa resposta serão destinadas ao autor do post.

Vote no @perfilbrasil para Testemunha Hive.



banner_hiver_br_01.png

Delegate your HP to the hive-br.voter account and earn Hive daily!

🔹 Follow our Curation Trail and don't miss voting! 🔹

Your post was manually curated by @crazyphantombr.

Curious about HivePakistan? Join us on Discord!

Delegate your HP to the Hivepakistan account and earn 90% of curation rewards in liquid hive!

50 HP
100 HP
200 HP
500 HP (Supporter Badge)
1000 HP

Follow our Curation Trail and don't miss voting!

Additional Perks: Delegate To @ pakx For Earning $PAKX Investment Token


Curated by crazyphantombr

Bem vindo ao Brasil na Hive!
!BBH