opinder2906 commited on
Commit
8ef5231
·
verified ·
1 Parent(s): 65acf1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -6,7 +6,6 @@ import pandas as pd
6
  import requests
7
  from io import StringIO
8
  import speech_recognition as sr
9
- import json
10
  import random
11
 
12
  # --- Your Dummy Model and Helpers (same as before) ---
@@ -45,7 +44,21 @@ file_id = "1yVJh_NVL4Y4qEXGym47UCK5ZNZgVZYv"
45
  url = f"https://drive.google.com/uc?export=download&id={file_id}"
46
  response = requests.get(url)
47
  csv_text = response.text
 
 
48
  solutions_df = pd.read_csv(StringIO(csv_text), header=0, on_bad_lines='skip')
 
 
 
 
 
 
 
 
 
 
 
 
49
  used_solutions = {emotion: set() for emotion in solutions_df['emotion'].unique()}
50
 
51
  negative_words = [
@@ -186,8 +199,7 @@ if st.button("Send"):
186
  "feedback": ""
187
  })
188
 
189
- # Show conversation history
190
  for chat in st.session_state.history[-5:]:
191
  st.markdown(f"**You:** {chat['user']}")
192
  st.markdown(f"**EmotiBot:** {chat['bot']}")
193
-
 
6
  import requests
7
  from io import StringIO
8
  import speech_recognition as sr
 
9
  import random
10
 
11
  # --- Your Dummy Model and Helpers (same as before) ---
 
44
  url = f"https://drive.google.com/uc?export=download&id={file_id}"
45
  response = requests.get(url)
46
  csv_text = response.text
47
+
48
+ # Read CSV and clean column names
49
  solutions_df = pd.read_csv(StringIO(csv_text), header=0, on_bad_lines='skip')
50
+ solutions_df.columns = solutions_df.columns.str.strip().str.lower() # clean columns
51
+
52
+ # Show debug info in Streamlit UI (remove later if you want)
53
+ st.write("Columns found in CSV:", list(solutions_df.columns))
54
+ st.write("First few rows of CSV:")
55
+ st.write(solutions_df.head())
56
+
57
+ # Stop if 'emotion' column missing
58
+ if 'emotion' not in solutions_df.columns:
59
+ st.error("CSV is missing the 'emotion' column. Please check your file or rename the column.")
60
+ st.stop()
61
+
62
  used_solutions = {emotion: set() for emotion in solutions_df['emotion'].unique()}
63
 
64
  negative_words = [
 
199
  "feedback": ""
200
  })
201
 
202
+ # Show conversation history (last 5)
203
  for chat in st.session_state.history[-5:]:
204
  st.markdown(f"**You:** {chat['user']}")
205
  st.markdown(f"**EmotiBot:** {chat['bot']}")