Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -80,9 +80,10 @@ if 'flashcards' not in st.session_state:
|
|
80 |
st.session_state.flashcards = ""
|
81 |
|
82 |
# Display the title and introduction
|
83 |
-
st.title("
|
84 |
st.write("""
|
85 |
-
Welcome to the
|
|
|
86 |
""")
|
87 |
|
88 |
# Input area for text
|
@@ -123,8 +124,19 @@ if st.session_state.input_text:
|
|
123 |
flashcards_prompt = "Create flashcards with questions and answers based on the following text:"
|
124 |
st.session_state.flashcards = generate_response(flashcards_prompt, st.session_state.input_text)
|
125 |
|
126 |
-
|
|
|
|
|
|
|
127 |
if st.session_state.summary:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
st.download_button(
|
129 |
label="Download Summary",
|
130 |
data=st.session_state.summary,
|
@@ -132,8 +144,11 @@ if st.session_state.input_text:
|
|
132 |
mime="text/plain"
|
133 |
)
|
134 |
|
|
|
135 |
if st.session_state.main_points:
|
|
|
136 |
bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n")])
|
|
|
137 |
st.download_button(
|
138 |
label="Download Main Points",
|
139 |
data=bullet_points,
|
@@ -141,7 +156,26 @@ if st.session_state.input_text:
|
|
141 |
mime="text/plain"
|
142 |
)
|
143 |
|
|
|
144 |
if st.session_state.flashcards:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
st.download_button(
|
146 |
label="Download Flashcards",
|
147 |
data=st.session_state.flashcards,
|
|
|
80 |
st.session_state.flashcards = ""
|
81 |
|
82 |
# Display the title and introduction
|
83 |
+
st.title("AI71 Text Processing Tool")
|
84 |
st.write("""
|
85 |
+
Welcome to the AI71 Text Processing Tool! This application helps you process text by summarizing content,
|
86 |
+
extracting main points, and creating flashcards. Follow the instructions to enter your text and generate content.
|
87 |
""")
|
88 |
|
89 |
# Input area for text
|
|
|
124 |
flashcards_prompt = "Create flashcards with questions and answers based on the following text:"
|
125 |
st.session_state.flashcards = generate_response(flashcards_prompt, st.session_state.input_text)
|
126 |
|
127 |
+
# Results Tabs
|
128 |
+
tabs = st.tabs(["Summary", "Main Points", "Flashcards"])
|
129 |
+
|
130 |
+
with tabs[0]:
|
131 |
if st.session_state.summary:
|
132 |
+
st.subheader("Summary")
|
133 |
+
st.text_area(
|
134 |
+
"Summary",
|
135 |
+
value=st.session_state.summary,
|
136 |
+
height=200,
|
137 |
+
key="summary_results",
|
138 |
+
help="Generated summary."
|
139 |
+
)
|
140 |
st.download_button(
|
141 |
label="Download Summary",
|
142 |
data=st.session_state.summary,
|
|
|
144 |
mime="text/plain"
|
145 |
)
|
146 |
|
147 |
+
with tabs[1]:
|
148 |
if st.session_state.main_points:
|
149 |
+
st.subheader("Main Points")
|
150 |
bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n")])
|
151 |
+
st.markdown(f"### Main Points\n{bullet_points}", unsafe_allow_html=True)
|
152 |
st.download_button(
|
153 |
label="Download Main Points",
|
154 |
data=bullet_points,
|
|
|
156 |
mime="text/plain"
|
157 |
)
|
158 |
|
159 |
+
with tabs[2]:
|
160 |
if st.session_state.flashcards:
|
161 |
+
st.subheader("Flashcards")
|
162 |
+
flashcards = st.session_state.flashcards.split("\n\n") # Assuming flashcards are separated by double newlines
|
163 |
+
st.markdown('<div class="flashcard-container">', unsafe_allow_html=True)
|
164 |
+
for card in flashcards:
|
165 |
+
question, answer = card.split('\n', 1) # Assuming each card is in "question\nanswer" format
|
166 |
+
st.markdown(f"""
|
167 |
+
<div class="flashcard">
|
168 |
+
<div class="flashcard-inner">
|
169 |
+
<div class="flashcard-front">
|
170 |
+
<p>{question.strip()}</p>
|
171 |
+
</div>
|
172 |
+
<div class="flashcard-back">
|
173 |
+
<p>{answer.strip()}</p>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
""", unsafe_allow_html=True)
|
178 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
179 |
st.download_button(
|
180 |
label="Download Flashcards",
|
181 |
data=st.session_state.flashcards,
|