Chunakorn/Text2SQL_Demo
0
1import torch2from transformers import AutoTokenizer, AutoModelForSeq2SeqLM3import streamlit as st4 5# Set up the Streamlit app with a title and caption6st.title("Text To SQL Queries")7st.caption("Use your SQL code to create the table and ask the question you want to know.", unsafe_allow_html=False)8 9# Initialize an empty list to store the conversation history10if 'conversation' not in st.session_state:11 st.session_state.conversation = []12 13# Capture the SQL table creation code input14SQL_Table = st.text_input("SQL Create Table")15 16# Capture user input as a chat message17prompt = st.chat_input("Enter Your Question")18 19# If the user sends a message, append it to the conversation20if prompt:21 st.session_state.conversation.append({"user": prompt})22 23# Display the conversation history in a chat format24for message in st.session_state.conversation:25 st.write(f"**User:** {message['user']}")26 27model_name = "Chunakorn/Fine-tuned_SQL_QA_Test" # Replace with your actual model repo28 29# Load the model and tokenizer30tokenizer = AutoTokenizer.from_pretrained(model_name)31model = AutoModelForSeq2SeqLM.from_pretrained(model_name)32 