CoolFace
Apppublic

mlnsio/text2sql

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
0likes
text2sql_ui.py41 linesDownload Raw Back to root
1"""2UI for text2sql app3"""4import os5import pandas as pd6import requests7import streamlit as st8 9# Streamlit app10st.set_page_config(layout="wide")11 12 13def main():14    st.title("Mutual Fund Text2SQL App")15 16    # Get user prompt from Streamlit UI17    prompt = st.text_input("Enter your question here:")18 19    if st.button("Submit"):20 21        API_URL = f"{os.environ['SERVER_URL']}/api/get-mf-data/?query={prompt}"22        response = requests.get(API_URL)23 24        if response.status_code != 200:25            st.error("Error fetching data from the server.")26            st.stop()27 28        df = pd.DataFrame(response.json()["data"])29        st.write("Query:", response.json()["query"])30        # st.markdown(31        #     "<h1 style='text-align: center;'>Mutual Fund Data Analysis Tool</h1>",32        #     unsafe_allow_html=True,33        # )34 35        # Display the DataFrame without scrolling and use the full page width36        st.dataframe(df, width=10000, height=1000)37 38 39if __name__ == "__main__":40    main()41