Balams/NL2SQL
0
1import streamlit as st2import pandas as pd3 4from user_codes.chatbot import get_tablenames,sql_code_generator,run_sql_query #,load_dataset5 6 7def main():8 st.set_page_config(page_title="NL2SQL", page_icon=":bar_chart:")9 st.markdown("""10 <h1 style="text-align: center; color: #4CAF50;">NL2SQL</h1>11 <p style="text-align: center; font-size: 20px; color: #777;">Natural Language to SQL converter.</p> 12 """, unsafe_allow_html=True)13 14 github_repo_url="https://github.com/balamurugan-shanmuganathan/NL2SQL"15 kaggle_url = "https://www.kaggle.com/datasets/andrexibiza/grocery-sales-dataset"16 17 st.markdown(f"""18 <style>19 .github-icon {{20 position: absolute;21 top: 10px;22 right: 20px;23 }}24 </style>25 26 <a href="{github_repo_url}" class="github-icon" target="_blank">27 <img src="https://cdn-icons-png.flaticon.com/512/25/25231.png" alt="GitHub Logo" width="30"/>28 View on GitHub29 </a>30 <a href="{kaggle_url}" class="top-right" target="_blank">Dataset:31 <img src="https://nlposs.github.io/2018/img/kaggle.png" alt="Kaggle Logo" width="80"/>32 </a><br><br>33 """, unsafe_allow_html=True)34 35 36 37 with st.expander("DataBase Details",expanded=True):38 st.image("database_details.png", use_container_width =True)39 40 # Load dataset from Kaggle and store into store.db41 # load_dataset()42 43 tables_names = get_tablenames()44 45 if prompt := st.chat_input("Enter your query to filter the population"):46 with st.chat_message("user"):47 st.markdown(f"**You asked:** {prompt}")48 49 with st.chat_message("assistant"):50 sql_code = sql_code_generator(prompt,tables_names)51 st.code(sql_code, language="sql")52 result=run_sql_query(sql_code)53 st.dataframe(result) # Display dataframe54 55if __name__ == "__main__":56 main()57 