iqra785 commited on
Commit
496c793
·
verified ·
1 Parent(s): 84daf18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -25,9 +25,9 @@ st.markdown("""
25
  }
26
  .flashcard-container {
27
  display: flex;
28
- flex-wrap: wrap;
 
29
  gap: 1rem;
30
- overflow-x: auto; /* Allow horizontal scrolling if needed */
31
  }
32
  .flashcard {
33
  width: 250px;
@@ -42,6 +42,7 @@ st.markdown("""
42
  display: flex;
43
  align-items: center;
44
  justify-content: center;
 
45
  }
46
  .flashcard-inner {
47
  position: relative;
@@ -84,9 +85,9 @@ if 'flashcards' not in st.session_state:
84
  st.session_state.flashcards = ""
85
 
86
  # Display the title and introduction
87
- st.title("InsightStarfleet")
88
  st.write("""
89
- Welcome to the InsightStarfleet! This application helps you process text by summarizing content,
90
  extracting main points, and creating flashcards. Follow the instructions to enter your text and generate content.
91
  """)
92
 
@@ -110,7 +111,9 @@ if st.session_state.input_text:
110
  # Caching API call function
111
  @st.cache_data
112
  def generate_response(system_message, user_message):
113
- return _generate_response(system_message, user_message)
 
 
114
 
115
  # Buttons for processing
116
  if st.button("Generate Summary"):
@@ -124,6 +127,10 @@ if st.session_state.input_text:
124
  if st.button("Generate Flashcards"):
125
  flashcards_prompt = "Create flashcards with questions and answers based on the following text. Ensure each flashcard includes a question and its corresponding answer, formatted as 'Question: [question]\\nAnswer: [answer]':"
126
  st.session_state.flashcards = generate_response(flashcards_prompt, st.session_state.input_text)
 
 
 
 
127
 
128
  # Combined Results
129
  st.subheader("Results")
@@ -148,7 +155,8 @@ if st.session_state.summary:
148
  # Main Points
149
  if st.session_state.main_points:
150
  st.markdown("### Main Points")
151
- bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n")])
 
152
  st.markdown(f"### Main Points\n{bullet_points}", unsafe_allow_html=True)
153
  st.download_button(
154
  label="Download Main Points",
 
25
  }
26
  .flashcard-container {
27
  display: flex;
28
+ overflow-x: auto; /* Allow horizontal scrolling */
29
+ white-space: nowrap; /* Prevent wrapping */
30
  gap: 1rem;
 
31
  }
32
  .flashcard {
33
  width: 250px;
 
42
  display: flex;
43
  align-items: center;
44
  justify-content: center;
45
+ flex-shrink: 0; /* Prevent shrinking */
46
  }
47
  .flashcard-inner {
48
  position: relative;
 
85
  st.session_state.flashcards = ""
86
 
87
  # Display the title and introduction
88
+ st.title("AI71 Text Processing Tool")
89
  st.write("""
90
+ Welcome to the AI71 Text Processing Tool! This application helps you process text by summarizing content,
91
  extracting main points, and creating flashcards. Follow the instructions to enter your text and generate content.
92
  """)
93
 
 
111
  # Caching API call function
112
  @st.cache_data
113
  def generate_response(system_message, user_message):
114
+ response = _generate_response(system_message, user_message)
115
+ # Strip any unwanted labels or text
116
+ return response.strip()
117
 
118
  # Buttons for processing
119
  if st.button("Generate Summary"):
 
127
  if st.button("Generate Flashcards"):
128
  flashcards_prompt = "Create flashcards with questions and answers based on the following text. Ensure each flashcard includes a question and its corresponding answer, formatted as 'Question: [question]\\nAnswer: [answer]':"
129
  st.session_state.flashcards = generate_response(flashcards_prompt, st.session_state.input_text)
130
+ else:
131
+ # Only show generate buttons if text is present
132
+ if st.button("Generate Summary") or st.button("Extract Main Points") or st.button("Generate Flashcards"):
133
+ st.error("Please enter text before generating content.")
134
 
135
  # Combined Results
136
  st.subheader("Results")
 
155
  # Main Points
156
  if st.session_state.main_points:
157
  st.markdown("### Main Points")
158
+ # Remove any leading or trailing blank lines from main points
159
+ bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n") if point.strip()])
160
  st.markdown(f"### Main Points\n{bullet_points}", unsafe_allow_html=True)
161
  st.download_button(
162
  label="Download Main Points",