Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -155,16 +155,18 @@ def provide_learning_resources(topic):
|
|
| 155 |
response = client.chat.completions.create(messages=messages, model="llama-3.3-70b-versatile", stream=False)
|
| 156 |
return response.choices[0].message.content
|
| 157 |
|
| 158 |
-
# Function to
|
| 159 |
-
def
|
| 160 |
doc = docx.Document()
|
| 161 |
doc.add_paragraph(text)
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
| 164 |
|
| 165 |
# Streamlit app layout
|
| 166 |
st.title("EduAI Assistant for Teachers")
|
| 167 |
-
st.markdown("""
|
| 168 |
Welcome to the AI-powered teaching assistant!
|
| 169 |
- Upload your lesson files or input text.
|
| 170 |
- Ask questions, summarize topics, create quizzes, assignments, and access learning resources.
|
|
@@ -208,13 +210,12 @@ if manual_input or uploaded_files:
|
|
| 208 |
if st.button("Summarize"):
|
| 209 |
summaries = [summarize_topic(chunk, topic) for chunk in text_chunks]
|
| 210 |
st.write("### Summary")
|
| 211 |
-
|
| 212 |
-
st.write(
|
| 213 |
|
| 214 |
-
#
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
st.success(f"Summary has been exported as {filename}")
|
| 218 |
|
| 219 |
elif task == "Ask Questions":
|
| 220 |
question = st.text_input("Enter your question:")
|
|
@@ -248,14 +249,13 @@ if manual_input or uploaded_files:
|
|
| 248 |
topic = st.text_input("Enter the topic for assignment generation:")
|
| 249 |
if st.button("Generate Assignment"):
|
| 250 |
assignments = [generate_assignment(chunk, topic) for chunk in text_chunks]
|
|
|
|
| 251 |
st.write("### Conceptual Assignment")
|
| 252 |
-
|
| 253 |
-
st.write(full_assignment)
|
| 254 |
|
| 255 |
-
#
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
st.success(f"Assignment has been exported as {filename}")
|
| 259 |
|
| 260 |
elif task == "Provide Learning Resources":
|
| 261 |
topic = st.text_input("Enter the topic for learning resources:")
|
|
|
|
| 155 |
response = client.chat.completions.create(messages=messages, model="llama-3.3-70b-versatile", stream=False)
|
| 156 |
return response.choices[0].message.content
|
| 157 |
|
| 158 |
+
# Function to save text to a docx file
|
| 159 |
+
def save_to_docx(text, filename="download.docx"):
|
| 160 |
doc = docx.Document()
|
| 161 |
doc.add_paragraph(text)
|
| 162 |
+
byte_io = BytesIO()
|
| 163 |
+
doc.save(byte_io)
|
| 164 |
+
byte_io.seek(0)
|
| 165 |
+
return byte_io
|
| 166 |
|
| 167 |
# Streamlit app layout
|
| 168 |
st.title("EduAI Assistant for Teachers")
|
| 169 |
+
st.markdown("""
|
| 170 |
Welcome to the AI-powered teaching assistant!
|
| 171 |
- Upload your lesson files or input text.
|
| 172 |
- Ask questions, summarize topics, create quizzes, assignments, and access learning resources.
|
|
|
|
| 210 |
if st.button("Summarize"):
|
| 211 |
summaries = [summarize_topic(chunk, topic) for chunk in text_chunks]
|
| 212 |
st.write("### Summary")
|
| 213 |
+
summary_text = "\n\n".join(summaries)
|
| 214 |
+
st.write(summary_text)
|
| 215 |
|
| 216 |
+
# Export to docx
|
| 217 |
+
docx_file = save_to_docx(summary_text)
|
| 218 |
+
st.download_button("Download Summary as DOCX", docx_file, file_name="summary.docx", mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
|
|
|
| 219 |
|
| 220 |
elif task == "Ask Questions":
|
| 221 |
question = st.text_input("Enter your question:")
|
|
|
|
| 249 |
topic = st.text_input("Enter the topic for assignment generation:")
|
| 250 |
if st.button("Generate Assignment"):
|
| 251 |
assignments = [generate_assignment(chunk, topic) for chunk in text_chunks]
|
| 252 |
+
assignment_text = "\n\n".join(assignments)
|
| 253 |
st.write("### Conceptual Assignment")
|
| 254 |
+
st.write(assignment_text)
|
|
|
|
| 255 |
|
| 256 |
+
# Export to docx
|
| 257 |
+
docx_file = save_to_docx(assignment_text)
|
| 258 |
+
st.download_button("Download Assignment as DOCX", docx_file, file_name="assignment.docx", mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
|
|
|
| 259 |
|
| 260 |
elif task == "Provide Learning Resources":
|
| 261 |
topic = st.text_input("Enter the topic for learning resources:")
|