Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +10 -4
src/streamlit_app.py
CHANGED
|
@@ -85,11 +85,17 @@ if 'chat_history' not in st.session_state:
|
|
| 85 |
# Load FAQ Data
|
| 86 |
@st.cache_data
|
| 87 |
def load_faq_data():
|
| 88 |
-
"""Load FAQ data from
|
| 89 |
-
sheet_url = "https://docs.google.com/spreadsheets/d/1ZJ8zCGq6iLTQv6Qzw1dsHvEj1Zo3qeTf/export?format=csv"
|
| 90 |
|
| 91 |
try:
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Set proper column names
|
| 95 |
df.columns = ['No', 'Category', 'Rarety', 'Questions', 'Additional Questions Data (image)',
|
|
@@ -99,10 +105,10 @@ def load_faq_data():
|
|
| 99 |
df.columns = df.columns.str.strip()
|
| 100 |
df = df[df['Questions'].notna() & (df['Questions'] != '') & (df['Questions'].str.len() > 5)]
|
| 101 |
|
|
|
|
| 102 |
return df
|
| 103 |
except Exception as e:
|
| 104 |
st.error(f"Error loading FAQ data: {e}")
|
| 105 |
-
st.error(f"Please check if the Google Sheet is publicly accessible")
|
| 106 |
return None
|
| 107 |
|
| 108 |
# Load embedding model
|
|
|
|
| 85 |
# Load FAQ Data
|
| 86 |
@st.cache_data
|
| 87 |
def load_faq_data():
|
| 88 |
+
"""Load FAQ data from local CSV file"""
|
|
|
|
| 89 |
|
| 90 |
try:
|
| 91 |
+
# Try to read from local file first
|
| 92 |
+
if os.path.exists('faq_data.csv'):
|
| 93 |
+
df = pd.read_csv('faq_data.csv', skiprows=1)
|
| 94 |
+
elif os.path.exists('src/faq_data.csv'):
|
| 95 |
+
df = pd.read_csv('src/faq_data.csv', skiprows=1)
|
| 96 |
+
else:
|
| 97 |
+
st.error("❌ faq_data.csv not found. Please upload the CSV file.")
|
| 98 |
+
return None
|
| 99 |
|
| 100 |
# Set proper column names
|
| 101 |
df.columns = ['No', 'Category', 'Rarety', 'Questions', 'Additional Questions Data (image)',
|
|
|
|
| 105 |
df.columns = df.columns.str.strip()
|
| 106 |
df = df[df['Questions'].notna() & (df['Questions'] != '') & (df['Questions'].str.len() > 5)]
|
| 107 |
|
| 108 |
+
st.success(f"✅ تم تحميل {len(df)} سؤال بنجاح!")
|
| 109 |
return df
|
| 110 |
except Exception as e:
|
| 111 |
st.error(f"Error loading FAQ data: {e}")
|
|
|
|
| 112 |
return None
|
| 113 |
|
| 114 |
# Load embedding model
|