Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,50 +41,51 @@ def generate_full_story_chunks(excerpt):
|
|
| 41 |
def clear_history():
|
| 42 |
return gr.Textbox.update(value="")
|
| 43 |
|
| 44 |
-
# Build UI
|
| 45 |
-
gr.
|
| 46 |
-
gr.Markdown(
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
)
|
|
|
|
| 50 |
|
| 51 |
-
with gr.Row():
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
-
gr.Markdown("---")
|
| 74 |
-
gr.Markdown("π Use via API (see Hugging Face Inference docs).")
|
| 75 |
|
| 76 |
-
# Button wiring
|
| 77 |
-
generate_btn.click(
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
)
|
| 82 |
|
| 83 |
-
clear_btn.click(
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
)
|
| 88 |
|
| 89 |
# Launch app
|
| 90 |
if __name__ == "__main__":
|
|
|
|
| 41 |
def clear_history():
|
| 42 |
return gr.Textbox.update(value="")
|
| 43 |
|
| 44 |
+
# Build UI inside Blocks
|
| 45 |
+
with gr.Blocks() as demo:
|
| 46 |
+
gr.Markdown("## πΊ Mythology Storyteller")
|
| 47 |
+
gr.Markdown(
|
| 48 |
+
"Enter a phrase from a chapter of your choice "
|
| 49 |
+
"(please include Parv, key event, and section for better results)."
|
| 50 |
+
)
|
| 51 |
|
| 52 |
+
with gr.Row():
|
| 53 |
+
with gr.Column():
|
| 54 |
+
user_input = gr.Textbox(
|
| 55 |
+
label="Incomplete story excerpt",
|
| 56 |
+
placeholder="Enter an excerpt from the Mahabharata here...",
|
| 57 |
+
lines=4,
|
| 58 |
+
)
|
| 59 |
+
summary_input = gr.Textbox(
|
| 60 |
+
label="Chapter summary (optional)",
|
| 61 |
+
placeholder="Enter summary if available...",
|
| 62 |
+
lines=2,
|
| 63 |
+
)
|
| 64 |
+
generate_btn = gr.Button("β¨ Generate Story")
|
| 65 |
|
| 66 |
+
with gr.Column():
|
| 67 |
+
output_text = gr.Textbox(
|
| 68 |
+
label="Generated Story",
|
| 69 |
+
placeholder="Your generated story will appear here...",
|
| 70 |
+
lines=12,
|
| 71 |
+
)
|
| 72 |
+
clear_btn = gr.Button("ποΈ Clear Conversation")
|
| 73 |
|
| 74 |
+
gr.Markdown("---")
|
| 75 |
+
gr.Markdown("π Use via API (see Hugging Face Inference docs).")
|
| 76 |
|
| 77 |
+
# Button wiring inside the Blocks context
|
| 78 |
+
generate_btn.click(
|
| 79 |
+
fn=generate_full_story_chunks,
|
| 80 |
+
inputs=user_input,
|
| 81 |
+
outputs=output_text,
|
| 82 |
+
)
|
| 83 |
|
| 84 |
+
clear_btn.click(
|
| 85 |
+
fn=clear_history,
|
| 86 |
+
inputs=None,
|
| 87 |
+
outputs=output_text,
|
| 88 |
+
)
|
| 89 |
|
| 90 |
# Launch app
|
| 91 |
if __name__ == "__main__":
|