Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -5
src/streamlit_app.py
CHANGED
|
@@ -5,8 +5,11 @@ import requests
|
|
| 5 |
import re
|
| 6 |
import io
|
| 7 |
|
| 8 |
-
# π
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# π§ Generate SQL using Together API
|
| 12 |
def generate_sql_from_prompt(prompt, df):
|
|
@@ -52,7 +55,7 @@ st.markdown("Upload your **Excel file**, ask a question in natural language, and
|
|
| 52 |
|
| 53 |
uploaded_file = st.file_uploader("π Upload Excel file", type=["xlsx"])
|
| 54 |
|
| 55 |
-
if
|
| 56 |
df = pd.read_excel(uploaded_file)
|
| 57 |
st.success(f"β
Loaded: {uploaded_file.name} with shape {df.shape}")
|
| 58 |
st.dataframe(df.head(), use_container_width=True)
|
|
@@ -75,5 +78,6 @@ if uploaded_file and TOGETHER_API_KEY:
|
|
| 75 |
|
| 76 |
except Exception as e:
|
| 77 |
st.error(f"β Error: {e}")
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
| 5 |
import re
|
| 6 |
import io
|
| 7 |
|
| 8 |
+
# π Handle Together API Key (from secrets or user input)
|
| 9 |
+
if "TOGETHER_API_KEY" in st.secrets:
|
| 10 |
+
TOGETHER_API_KEY = st.secrets["TOGETHER_API_KEY"]
|
| 11 |
+
else:
|
| 12 |
+
TOGETHER_API_KEY = st.text_input("π Enter Together API Key", type="password")
|
| 13 |
|
| 14 |
# π§ Generate SQL using Together API
|
| 15 |
def generate_sql_from_prompt(prompt, df):
|
|
|
|
| 55 |
|
| 56 |
uploaded_file = st.file_uploader("π Upload Excel file", type=["xlsx"])
|
| 57 |
|
| 58 |
+
if TOGETHER_API_KEY and uploaded_file:
|
| 59 |
df = pd.read_excel(uploaded_file)
|
| 60 |
st.success(f"β
Loaded: {uploaded_file.name} with shape {df.shape}")
|
| 61 |
st.dataframe(df.head(), use_container_width=True)
|
|
|
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
st.error(f"β Error: {e}")
|
| 81 |
+
|
| 82 |
+
elif not TOGETHER_API_KEY:
|
| 83 |
+
st.warning("π Please enter your Together API key to continue.")
|