Samurai719214 commited on
Commit
d489bb6
Β·
verified Β·
1 Parent(s): 298614c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -39
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 with Gradio Blocks
45
- gr.Markdown("## 🏺 Mythology Storyteller")
46
- gr.Markdown(
47
- "Enter a phrase from a chapter of your choice "
48
- "(please include Parv, key event, and section for better results)."
49
- )
 
50
 
51
- with gr.Row():
52
- with gr.Column():
53
- user_input = gr.Textbox(
54
- label="Incomplete story excerpt",
55
- placeholder="Enter an excerpt from the Mahabharata here...",
56
- lines=4,
57
- )
58
- summary_input = gr.Textbox(
59
- label="Chapter summary (optional)",
60
- placeholder="Enter summary if available...",
61
- lines=2,
62
- )
63
- generate_btn = gr.Button("✨ Generate Story")
64
 
65
- with gr.Column():
66
- output_text = gr.Textbox(
67
- label="Generated Story",
68
- placeholder="Your generated story will appear here...",
69
- lines=12,
70
- )
71
- clear_btn = gr.Button("πŸ—‘οΈ Clear Conversation")
72
 
73
- gr.Markdown("---")
74
- gr.Markdown("πŸ”Œ Use via API (see Hugging Face Inference docs).")
75
 
76
- # Button wiring with streaming-safe generator
77
- generate_btn.click(
78
- fn=generate_full_story_chunks,
79
- inputs=user_input,
80
- outputs=output_text,
81
- )
82
 
83
- clear_btn.click(
84
- fn=clear_history,
85
- inputs=None,
86
- outputs=output_text,
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__":