Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
| 52 |
-
|
| 53 |
if st.button("Search"):
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 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 |
-
#
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
| 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 |
+
|