Update app.py
Browse files
app.py
CHANGED
|
@@ -53,6 +53,7 @@ if "df" not in st.session_state:
|
|
| 53 |
|
| 54 |
# Dataset Input
|
| 55 |
input_option = st.radio("Select Dataset Input:", ["Use Hugging Face Dataset", "Upload CSV File"])
|
|
|
|
| 56 |
if input_option == "Use Hugging Face Dataset":
|
| 57 |
dataset_name = st.text_input("Enter Hugging Face Dataset Name:", value="Einstellung/demo-salaries")
|
| 58 |
if st.button("Load Dataset"):
|
|
@@ -61,15 +62,23 @@ if input_option == "Use Hugging Face Dataset":
|
|
| 61 |
dataset = load_dataset(dataset_name, split="train")
|
| 62 |
st.session_state.df = pd.DataFrame(dataset)
|
| 63 |
st.success(f"Dataset '{dataset_name}' loaded successfully!")
|
| 64 |
-
st.dataframe(st.session_state.df.head())
|
| 65 |
except Exception as e:
|
| 66 |
st.error(f"Error: {e}")
|
|
|
|
| 67 |
elif input_option == "Upload CSV File":
|
| 68 |
uploaded_file = st.file_uploader("Upload CSV File:", type=["csv"])
|
| 69 |
if uploaded_file:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# SQL-RAG Analysis
|
| 75 |
if st.session_state.df is not None:
|
|
|
|
| 53 |
|
| 54 |
# Dataset Input
|
| 55 |
input_option = st.radio("Select Dataset Input:", ["Use Hugging Face Dataset", "Upload CSV File"])
|
| 56 |
+
|
| 57 |
if input_option == "Use Hugging Face Dataset":
|
| 58 |
dataset_name = st.text_input("Enter Hugging Face Dataset Name:", value="Einstellung/demo-salaries")
|
| 59 |
if st.button("Load Dataset"):
|
|
|
|
| 62 |
dataset = load_dataset(dataset_name, split="train")
|
| 63 |
st.session_state.df = pd.DataFrame(dataset)
|
| 64 |
st.success(f"Dataset '{dataset_name}' loaded successfully!")
|
|
|
|
| 65 |
except Exception as e:
|
| 66 |
st.error(f"Error: {e}")
|
| 67 |
+
|
| 68 |
elif input_option == "Upload CSV File":
|
| 69 |
uploaded_file = st.file_uploader("Upload CSV File:", type=["csv"])
|
| 70 |
if uploaded_file:
|
| 71 |
+
try:
|
| 72 |
+
st.session_state.df = pd.read_csv(uploaded_file)
|
| 73 |
+
st.success("File uploaded successfully!")
|
| 74 |
+
except Exception as e:
|
| 75 |
+
st.error(f"Error loading file: {e}")
|
| 76 |
+
|
| 77 |
+
# Display Dataset Preview
|
| 78 |
+
if st.session_state.df is not None:
|
| 79 |
+
st.subheader("π Dataset Preview")
|
| 80 |
+
st.dataframe(st.session_state.df.head())
|
| 81 |
+
|
| 82 |
|
| 83 |
# SQL-RAG Analysis
|
| 84 |
if st.session_state.df is not None:
|