Spaces:
Sleeping
Sleeping
DrishtiSharma
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -52,10 +52,8 @@ elif model_choice == "GPT-4o":
|
|
52 |
if "df" not in st.session_state:
|
53 |
st.session_state.df = None
|
54 |
|
55 |
-
# Dataset Input
|
56 |
# Dataset Input
|
57 |
input_option = st.radio("Select Dataset Input:", ["Use Hugging Face Dataset", "Upload CSV File"])
|
58 |
-
|
59 |
if input_option == "Use Hugging Face Dataset":
|
60 |
dataset_name = st.text_input("Enter Hugging Face Dataset Name:", value="Einstellung/demo-salaries")
|
61 |
if st.button("Load Dataset"):
|
@@ -64,24 +62,16 @@ if input_option == "Use Hugging Face Dataset":
|
|
64 |
dataset = load_dataset(dataset_name, split="train")
|
65 |
st.session_state.df = pd.DataFrame(dataset)
|
66 |
st.success(f"Dataset '{dataset_name}' loaded successfully!")
|
|
|
67 |
except Exception as e:
|
68 |
st.error(f"Error: {e}")
|
69 |
-
|
70 |
elif input_option == "Upload CSV File":
|
71 |
uploaded_file = st.file_uploader("Upload CSV File:", type=["csv"])
|
72 |
-
if uploaded_file
|
73 |
-
|
74 |
-
|
75 |
-
st.success("File uploaded successfully!")
|
76 |
-
except Exception as e:
|
77 |
-
st.error(f"Error loading file: {e}")
|
78 |
-
|
79 |
-
# Show dataset preview only after loading (for both Hugging Face and CSV)
|
80 |
-
if st.session_state.df is not None:
|
81 |
-
with st.expander("π View Dataset Preview", expanded=True):
|
82 |
st.dataframe(st.session_state.df.head())
|
83 |
|
84 |
-
|
85 |
# SQL-RAG Analysis
|
86 |
if st.session_state.df is not None:
|
87 |
temp_dir = tempfile.TemporaryDirectory()
|
|
|
52 |
if "df" not in st.session_state:
|
53 |
st.session_state.df = None
|
54 |
|
|
|
55 |
# Dataset Input
|
56 |
input_option = st.radio("Select Dataset Input:", ["Use Hugging Face Dataset", "Upload CSV File"])
|
|
|
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 |
+
st.dataframe(st.session_state.df.head())
|
66 |
except Exception as e:
|
67 |
st.error(f"Error: {e}")
|
|
|
68 |
elif input_option == "Upload CSV File":
|
69 |
uploaded_file = st.file_uploader("Upload CSV File:", type=["csv"])
|
70 |
+
if uploaded_file:
|
71 |
+
st.session_state.df = pd.read_csv(uploaded_file)
|
72 |
+
st.success("File uploaded successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
st.dataframe(st.session_state.df.head())
|
74 |
|
|
|
75 |
# SQL-RAG Analysis
|
76 |
if st.session_state.df is not None:
|
77 |
temp_dir = tempfile.TemporaryDirectory()
|