Spaces:
Sleeping
Sleeping
ns-devel
commited on
Commit
·
041eb13
1
Parent(s):
b54b7d9
Added ui for text2sql
Browse files- app.py +40 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
UI for text2sql app
|
| 3 |
+
"""
|
| 4 |
+
import os
|
| 5 |
+
import pandas as pd
|
| 6 |
+
import requests
|
| 7 |
+
import streamlit as st
|
| 8 |
+
|
| 9 |
+
# Streamlit app
|
| 10 |
+
st.set_page_config(layout="wide")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def main():
|
| 14 |
+
st.title("Mutual Fund Text2SQL App")
|
| 15 |
+
|
| 16 |
+
# Get user prompt from Streamlit UI
|
| 17 |
+
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 width
|
| 36 |
+
st.dataframe(df, width=10000, height=1000)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.29.0
|