DrishtiSharma commited on
Commit
e32e6f3
Β·
verified Β·
1 Parent(s): ca9bb7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -52,8 +52,10 @@ elif model_choice == "GPT-4o":
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,17 +64,23 @@ if input_option == "Use Hugging Face 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
- if st.session_state.df is not None:
74
- st.subheader("πŸ“‚ Dataset Preview")
75
- st.dataframe(st.session_state.df.head())
 
 
 
 
 
 
76
 
77
  # SQL-RAG Analysis
78
  if st.session_state.df is not None:
 
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
  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 is not None:
73
+ try:
74
+ st.session_state.df = pd.read_csv(uploaded_file)
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
+ st.subheader("πŸ“‚ Dataset Preview")
82
+ st.dataframe(st.session_state.df.head())
83
+
84
 
85
  # SQL-RAG Analysis
86
  if st.session_state.df is not None: