File size: 1,082 Bytes
041eb13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9b7749
c3022f4
041eb13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
UI for text2sql app
"""
import os
import pandas as pd
import requests
import streamlit as st

# Streamlit app
st.set_page_config(layout="wide")


def main():
    st.title("Mutual Fund Text2SQL App")

    # Get user prompt from Streamlit UI
    prompt = st.text_input("Enter your question here:")

    if st.button("Submit"):

        API_URL = f"{os.environ['SERVER_URL']}/api/get-mf-data/?query={prompt}"
        response = requests.get(API_URL)
        st.write(response.status_code)
        st.write(response.__dict__)
        if response.status_code != 200:
            st.error("Error fetching data from the server.")
            st.stop()

        df = pd.DataFrame(response.json()["data"])
        st.write("Query:", response.json()["query"])
        # st.markdown(
        #     "<h1 style='text-align: center;'>Mutual Fund Data Analysis Tool</h1>",
        #     unsafe_allow_html=True,
        # )

        # Display the DataFrame without scrolling and use the full page width
        st.dataframe(df, width=10000, height=1000)


if __name__ == "__main__":
    main()