pracheeeeez commited on
Commit
69d5ad5
Β·
verified Β·
1 Parent(s): b27a6fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -26
app.py CHANGED
@@ -48,36 +48,31 @@ def search_and_answer(query, index_file="faiss_course_index.pkl"):
48
 
49
  def main():
50
  st.title("πŸ“š Course Search WebApp")
51
- st.markdown("Find the best courses tailored to your needs.")
52
- query = st.text_input("πŸ” Enter your query:")
53
  if st.button("Search"):
54
- with st.spinner("Fetching results..."):
55
- start_time = time.time()
56
- response = search_and_answer(query, index_file="faiss_course_index.pkl")
57
- if response == "No relevant courses found.":
58
- st.warning(response)
59
- else:
60
- st.success("Results fetched successfully!")
61
-
62
- # Display the formatted response
63
- sections = response.split("\n\n")
64
- st.markdown("### **Related Courses:**")
65
- for section in sections[:-1]: # Exclude summary section
66
- if section.strip():
67
- st.markdown(section)
68
- st.write("---")
69
-
70
- # Display summary
71
- summary = sections[-1].replace("Summary:", "").strip()
72
- st.subheader("πŸ“ Summary:")
73
- st.info(summary)
74
 
75
- # Log time taken
76
- end_time = time.time()
77
- st.markdown(f"⏱ **Time Taken:** {end_time - start_time:.2f} seconds")
 
 
 
78
 
79
- st.markdown("---")
 
 
80
  st.markdown("Developed with ❀️ by [Your Name](https://your-link.com)")
81
 
 
82
  if __name__ == "__main__":
83
  main()
 
 
48
 
49
  def main():
50
  st.title("πŸ“š Course Search WebApp")
51
+ query = st.text_input("πŸ” Enter your query:")
52
+
53
  if st.button("Search"):
54
+ start_time = time.time()
55
+ response, course_info, summary = search_and_answer(query, index_file="faiss_course_index.pkl")
56
+
57
+ if response == "No relevant courses found.":
58
+ st.error(response)
59
+ else:
60
+ st.success("βœ… Results fetched successfully!")
61
+ st.write(f"⏱ **Time Taken:** {time.time() - start_time:.2f} seconds")
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+ # Display related courses in a scrollable section
64
+ with st.container():
65
+ st.subheader("πŸŽ“ Related Courses:")
66
+ for course_title, course_lessons in course_info:
67
+ with st.expander(course_title, expanded=False):
68
+ st.write(f"**Lessons:** {course_lessons}")
69
 
70
+ # Display summary with better layout
71
+ st.write("πŸ“ **Summary:**")
72
+ st.info(summary)
73
  st.markdown("Developed with ❀️ by [Your Name](https://your-link.com)")
74
 
75
+
76
  if __name__ == "__main__":
77
  main()
78
+