[Day 112] db2chat - Talk with your (sqlite3) database
Hello :)
Today is Day 112!
A quick summary of today:
This morning I saw this langchain post on creating a chat agent with a database, and it hit me - I need to make one myself!
The short but concise tutorial uses GPT, but I am just a poor student that prefers to use open source, and from a random X post I learned about Groq. It is crazy that we can use Groq models off-the-shelf (like mistral-8x7b, gemma-7b-it, and even llama3-8b).
A quick summary of the code
1st: create a query chain for the sql code
2nd: query the model for a natural response3rd: I used streamlit because it is so easy to develop, and deploy a webapp with itWebapp summary
1. Input your Groq/OpenAI API key and select a model (mistral-8x7b, gpt-4, llama3-8b, gemma-7b-it)
2. Load your sqlite3 db file (optional)3. Select a database to chat with (default is chinook) + click 'Connect'You can view your db's schema:4. Enter a query, run and get your chartYou can see the executed SQL query by hovering the (?)A potential upgrade would be to give a natural language input that asks for specific data (i.e. albums sold in 2015) and the model returns that and shows it to the user + allows to download it
That is all for today!
See you tomorrow :)