rahul@0interestratesNatural Language to SQL is really powerful.
Built censusGPT.com to let anyone query the census database with just natural language.
"cities with a population over 100,000 and lowest crime"
"highest income areas in california"
code is open-source and linked below00:46 AM - 10 Mar 2023
Thanks to AI we are all one chat prompt from being a Data Scientist.
header image was generated using midjourney
Several projects in the USA provide tools, like Civin, for civic planners to organize and orchestrate the collection of civic data. This tool allows the data scientist to ask any question based on USA Census data. Adding ChatGPT interaction to get answers is a chef's kiss.
With the addition of OpenAI tools, you can start seeing the potential of where this can go for understanding large amounts of City data. Excited to see what other ideas come out of this.
This open-source project from caesarHQ leverages the new ChatGPT API to ingest data and present answers on the cities with publicly viewable data.
code snippet from api/app/api/utils.py
# api/app/api/utils.py def get_assistant_message( temperature: int = 0, model: str = "gpt-3.5-turbo", # ChatGPT API messages: List[Dict[str, str]] = DEFAULT_MESSAGES, ) -> str: res = openai.ChatCompletion.create( model=model, temperature=temperature, messages=messages ) # completion = res['choices']['message']['content'] assistant_message = res['choices'] return assistant_message
Interesting is that they present the SQL queries in the browser. This allows the user, probably a data engineer, to leave the answers and continue work. My SQL injection days make me cringe at this, but their queries are read-only.
As mentioned in previous posts, I am not as familiar with Python in this series, but it looks like the project is using SQLAlchemy to access the hosted database and run queries there. Files reference the models and tables in the models folder.
OpenAI, especially the ChatGPT API does well with a data source. The little I know about Machine Learning is that you need a lot of data to get good results, and cities have been sourcing public data for years, making this problem approachable through AI. I look forward to sharing more examples like this in future posts.
Also, if you have a project leveraging OpenAI or similar, leave a link in the comments. I'd love to take a look and include it in my 30 days of OpenAI series.
Find more AI projects using OpenSauced