File size: 910 Bytes
f62b4e3 1fea92e c45fea1 f62b4e3 1fea92e f62b4e3 89f6f6b f62b4e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import streamlit as st
import pandas as pd
from pymongo import MongoClient
from dependency import load_db
import os
client = load_db()
db = client["chat_support"]
faq_collection = db["faq"]
# Fetch FAQ data from MongoDB
faq_data = pd.DataFrame(list(faq_collection.find()))
st.title("Frequently Asked Questions")
# Search functionality
search_term = st.text_input("Search FAQs", "")
if search_term:
filtered_data = faq_data[faq_data['questions'].apply(lambda x: any(search_term.lower() in q.lower() for q in x))]
else:
filtered_data = faq_data
st.write(f'filtered {len(filtered_data)} out of {len(faq_data)}')
# Display the FAQ list
for _, row in filtered_data.iterrows():
with st.expander(row['title']):
# st.write("**Questions:**")
# for question in row['questions']:
# st.write(f"- {question}")
st.write(f"\n**Answer:**")
st.write(row['answer']) |