qwerty45-uiop commited on
Commit
574a10f
·
verified ·
1 Parent(s): e4e41ee

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +44 -9
src/streamlit_app.py CHANGED
@@ -22,28 +22,63 @@ st.set_page_config(
22
  )
23
 
24
  # Enhanced data loading with error handling
 
 
 
 
 
25
  @st.cache_data
26
- def load_data():
 
27
  try:
28
- # Use actual file paths
29
- df1 = pd.read_excel("src/BITS_INTERNS.xlsx", sheet_name="Form Responses 1")
30
- df2 = pd.read_excel("/mnt/data/Summer of AI - ICFAI (Responses) (3).xlsx")
 
 
31
 
32
  df1.columns = df1.columns.str.strip()
33
  df2.columns = df2.columns.str.strip()
34
-
35
- # Find common columns and combine
36
  common_cols = list(set(df1.columns) & set(df2.columns))
37
  df1 = df1[common_cols]
38
  df2 = df2[common_cols]
39
 
40
  combined_df = pd.concat([df1, df2], ignore_index=True)
41
  return combined_df, None
42
- except FileNotFoundError as e:
43
- return None, f"File not found: {e}"
44
  except Exception as e:
45
- return None, f"Error loading data: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
 
47
 
48
  # Enhanced RAM extraction with better parsing
49
  def extract_numeric_ram(ram) -> Optional[int]:
 
22
  )
23
 
24
  # Enhanced data loading with error handling
25
+ # Upload section in sidebar
26
+ st.sidebar.header("📤 Upload Excel Files")
27
+ uploaded_file1 = st.sidebar.file_uploader("Upload File 1 (e.g. BITS_INTERNS)", type=["xlsx"])
28
+ uploaded_file2 = st.sidebar.file_uploader("Upload File 2 (e.g. ICFAI Responses)", type=["xlsx"])
29
+
30
  @st.cache_data
31
+
32
+ def load_uploaded_data(upload1, upload2):
33
  try:
34
+ if not upload1 or not upload2:
35
+ return None, "Please upload both Excel files."
36
+
37
+ df1 = pd.read_excel(upload1)
38
+ df2 = pd.read_excel(upload2)
39
 
40
  df1.columns = df1.columns.str.strip()
41
  df2.columns = df2.columns.str.strip()
42
+
43
+ # Use only common columns
44
  common_cols = list(set(df1.columns) & set(df2.columns))
45
  df1 = df1[common_cols]
46
  df2 = df2[common_cols]
47
 
48
  combined_df = pd.concat([df1, df2], ignore_index=True)
49
  return combined_df, None
 
 
50
  except Exception as e:
51
+ return None, str(e)
52
+
53
+ def extract_numeric_ram(ram) -> Optional[int]:
54
+ if pd.isna(ram):
55
+ return None
56
+ ram_str = str(ram).lower().replace(" ", "")
57
+ gb_match = re.search(r"(\d+(?:\.\d+)?)(?:gb|g)", ram_str)
58
+ if gb_match:
59
+ return int(float(gb_match.group(1)))
60
+ mb_match = re.search(r"(\d+)(?:mb|m)", ram_str)
61
+ if mb_match:
62
+ return max(1, int(int(mb_match.group(1)) / 1024))
63
+ plain_match = re.search(r"(\d+)", ram_str)
64
+ if plain_match:
65
+ return int(plain_match.group(1))
66
+ return None
67
+
68
+ st.title("🧠 LLM Compatibility Advisor")
69
+ st.markdown("Get personalized recommendations from **150+ popular open source AI models** with download sizes!")
70
+
71
+ df, error = load_uploaded_data(uploaded_file1, uploaded_file2)
72
+
73
+ if error:
74
+ st.error(error)
75
+ st.stop()
76
+
77
+ if df is None or df.empty:
78
+ st.warning("No data loaded. Please upload both files.")
79
+ st.stop()
80
 
81
+ st.success(f"✅ Loaded {len(df)} student entries from both files.")
82
 
83
  # Enhanced RAM extraction with better parsing
84
  def extract_numeric_ram(ram) -> Optional[int]: