Team Ai
Apppublic

mlnsio/Text2SQLUI

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py42 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        st.write(response.status_code)24        st.write(response.__dict__)25        if response.status_code != 200:26            st.error("Error fetching data from the server.")27            st.stop()28 29        df = pd.DataFrame(response.json()["data"])30        st.write("Query:", response.json()["query"])31        # st.markdown(32        #     "<h1 style='text-align: center;'>Mutual Fund Data Analysis Tool</h1>",33        #     unsafe_allow_html=True,34        # )35 36        # Display the DataFrame without scrolling and use the full page width37        st.dataframe(df, width=10000, height=1000)38 39 40if __name__ == "__main__":41    main()42