pracheeeeez commited on
Commit
e0d1ccb
Β·
verified Β·
1 Parent(s): 6523ce7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -19,7 +19,7 @@ def get_faiss_retriever(index_file="faiss_course_index.pkl"):
19
  def get_answer_from_t5(query, context):
20
  t5_pipeline = pipeline("text2text-generation", model="t5-small", device=0)
21
  input_text = f"Question: {query} Context: {context}"
22
- answer = t5_pipeline(input_text)
23
  return answer[0]['generated_text']
24
 
25
 
@@ -65,6 +65,7 @@ def main():
65
  query = st.text_input("πŸ” Enter your query:")
66
 
67
  if st.button("Search"):
 
68
  start_time = time.time()
69
  response, course_info, summary = search_and_answer(query, index_file="faiss_course_index.pkl")
70
 
@@ -76,12 +77,12 @@ def main():
76
 
77
  # Display related courses as cards
78
  st.subheader("πŸŽ“ Related Courses:")
79
- st.write("<div style='display: flex; flex-wrap: wrap; justify-content: center;'>", unsafe_allow_html=True)
80
  for course_title, course_lessons in course_info:
81
  card_html = f"""
82
- <div style='width: 200px; padding: 10px; margin: 10px; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);'>
83
- <h3 style='font-size: 16px; color: #333;'>{course_title}</h3>
84
- <p style='font-size: 14px; color: #666;'>Lessons: {course_lessons}</p>
85
  </div>
86
  """
87
  st.write(card_html, unsafe_allow_html=True)
@@ -89,10 +90,9 @@ def main():
89
 
90
  # Display summary with better layout
91
  st.subheader("πŸ“ Summary:")
92
- st.info(summary)
93
 
94
  st.markdown("<p style='text-align: center;'>Developed with ❀️ by Prachi</p>", unsafe_allow_html=True)
95
 
96
  if __name__ == "__main__":
97
- main()
98
-
 
19
  def get_answer_from_t5(query, context):
20
  t5_pipeline = pipeline("text2text-generation", model="t5-small", device=0)
21
  input_text = f"Question: {query} Context: {context}"
22
+ answer = t5_pipeline(input_text, max_length = 300,truncation = True)
23
  return answer[0]['generated_text']
24
 
25
 
 
65
  query = st.text_input("πŸ” Enter your query:")
66
 
67
  if st.button("Search"):
68
+ with st.spinner("Fetching results..."):
69
  start_time = time.time()
70
  response, course_info, summary = search_and_answer(query, index_file="faiss_course_index.pkl")
71
 
 
77
 
78
  # Display related courses as cards
79
  st.subheader("πŸŽ“ Related Courses:")
80
+ st.write("<div style='display: flex; flex-wrap: wrap; justify-content: space-between;'>", unsafe_allow_html=True)
81
  for course_title, course_lessons in course_info:
82
  card_html = f"""
83
+ <div style='width: 48%; padding: 10px; margin: 10px; border: 1px solid #f7f7f7; border-radius: 8px; box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);'>
84
+ <h3 style='font-size: 16px; color: #edebeb;'>{course_title}</h3>
85
+ <p style='font-size: 14px; color: #c9c9c9;'>Lessons: {course_lessons}</p>
86
  </div>
87
  """
88
  st.write(card_html, unsafe_allow_html=True)
 
90
 
91
  # Display summary with better layout
92
  st.subheader("πŸ“ Summary:")
93
+ st.info(summary[:300])
94
 
95
  st.markdown("<p style='text-align: center;'>Developed with ❀️ by Prachi</p>", unsafe_allow_html=True)
96
 
97
  if __name__ == "__main__":
98
+ main()