Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ book_data = {
|
|
| 24 |
def clean_formatting(text):
|
| 25 |
text = re.sub(r"\*\*(.*?)\*\*", r"\1", text)
|
| 26 |
text = re.sub(r"\*(.*?)\*", r"\1", text)
|
| 27 |
-
text = re.sub(r"[#β’βββ
πΉπΈππππ€π₯β¬οΈπ>
|
| 28 |
text = re.sub(r"\s{2,}", " ", text)
|
| 29 |
return text.strip()
|
| 30 |
|
|
@@ -159,26 +159,26 @@ def export_book():
|
|
| 159 |
|
| 160 |
# Gradio Interface
|
| 161 |
with gr.Blocks() as demo:
|
| 162 |
-
gr.Markdown("##
|
| 163 |
|
| 164 |
with gr.Row():
|
| 165 |
title = gr.Textbox(label="Subject Title")
|
| 166 |
grade = gr.Textbox(label="Grade Level")
|
| 167 |
|
| 168 |
slos = gr.Textbox(label="Paste SLOs (One per Line)", lines=10)
|
| 169 |
-
generate_structure = gr.Button("
|
| 170 |
structure_output = gr.Textbox(label="Generated Preface and TOC", lines=15)
|
| 171 |
|
| 172 |
generate_structure.click(fn=generate_book_intro, inputs=[title, grade, slos], outputs=structure_output)
|
| 173 |
|
| 174 |
-
gr.Markdown("###
|
| 175 |
chapter_output = gr.Textbox(label="Generated Chapter Content", lines=25)
|
| 176 |
|
| 177 |
with gr.Row():
|
| 178 |
for i in range(1, 7):
|
| 179 |
gr.Button(f"Generate Chapter {i}").click(fn=generate_chapter, inputs=gr.Number(value=i, visible=False), outputs=chapter_output)
|
| 180 |
|
| 181 |
-
gr.Markdown("###
|
| 182 |
download_btn = gr.Button("Download MS Word Textbook")
|
| 183 |
download_file = gr.File()
|
| 184 |
|
|
|
|
| 24 |
def clean_formatting(text):
|
| 25 |
text = re.sub(r"\*\*(.*?)\*\*", r"\1", text)
|
| 26 |
text = re.sub(r"\*(.*?)\*", r"\1", text)
|
| 27 |
+
text = re.sub(r"[#β’βββ
πΉπΈππππ€π₯β¬οΈπ>]", "", text)
|
| 28 |
text = re.sub(r"\s{2,}", " ", text)
|
| 29 |
return text.strip()
|
| 30 |
|
|
|
|
| 159 |
|
| 160 |
# Gradio Interface
|
| 161 |
with gr.Blocks() as demo:
|
| 162 |
+
gr.Markdown("## \ud83d\udcd8 AI Textbook Generator \u2013 Step-by-Step (APA Style)")
|
| 163 |
|
| 164 |
with gr.Row():
|
| 165 |
title = gr.Textbox(label="Subject Title")
|
| 166 |
grade = gr.Textbox(label="Grade Level")
|
| 167 |
|
| 168 |
slos = gr.Textbox(label="Paste SLOs (One per Line)", lines=10)
|
| 169 |
+
generate_structure = gr.Button("\ud83e\udde0 Generate TOC + Preface")
|
| 170 |
structure_output = gr.Textbox(label="Generated Preface and TOC", lines=15)
|
| 171 |
|
| 172 |
generate_structure.click(fn=generate_book_intro, inputs=[title, grade, slos], outputs=structure_output)
|
| 173 |
|
| 174 |
+
gr.Markdown("### \ud83d\udcc5 Generate Chapters One by One")
|
| 175 |
chapter_output = gr.Textbox(label="Generated Chapter Content", lines=25)
|
| 176 |
|
| 177 |
with gr.Row():
|
| 178 |
for i in range(1, 7):
|
| 179 |
gr.Button(f"Generate Chapter {i}").click(fn=generate_chapter, inputs=gr.Number(value=i, visible=False), outputs=chapter_output)
|
| 180 |
|
| 181 |
+
gr.Markdown("### \ud83d\udcc2 Download Complete Textbook")
|
| 182 |
download_btn = gr.Button("Download MS Word Textbook")
|
| 183 |
download_file = gr.File()
|
| 184 |
|