Rahatara commited on
Commit
d67cbad
·
verified ·
1 Parent(s): 066dea2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -15
app.py CHANGED
@@ -50,22 +50,46 @@ def chatbot_stream(user_input):
50
  response += text_chunk
51
  yield response
52
 
53
- # Gradio UI with button options
54
  def ui():
55
- with gr.Blocks() as app:
56
- gr.Markdown("# AI Storyboard & Chatbot")
57
- with gr.Row():
58
- scenario_btn = gr.Button("Generate Storyboard")
59
- chat_btn = gr.Button("Chat about Storyboarding")
60
-
61
- scenario_input = gr.Textbox(label="Enter your scenario")
62
- storyboard_output = gr.Textbox(label="Generated Storyboard", interactive=False)
63
- scenario_btn.click(generate_storyboard, inputs=scenario_input, outputs=storyboard_output)
64
-
65
- chat_input = gr.Textbox(label="Ask a question about storyboarding")
66
- chat_output = gr.Textbox(label="Chatbot Response", interactive=False)
67
- chat_btn.click(chatbot_stream, inputs=chat_input, outputs=chat_output)
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  app.launch(share=True)
70
 
71
  ui()
 
50
  response += text_chunk
51
  yield response
52
 
53
+ # Gradio UI with enhanced chat interface
54
  def ui():
55
+ with gr.Blocks(theme=gr.themes.Glass(primary_hue="violet", secondary_hue="emerald", neutral_hue="stone")) as app:
56
+ with gr.Tabs():
57
+ with gr.TabItem("💬Chat"):
58
+ gr.Markdown("# AI Storyboard & Chatbot")
59
+ chatbot = gr.Chatbot(label="Storyboard Chatbot")
60
+ with gr.Row():
61
+ chat_input = gr.Textbox(
62
+ label="Your Message",
63
+ placeholder="Type your question here...",
64
+ lines=1
65
+ )
66
+ send_button = gr.Button("✋Ask Question")
67
+
68
+ # Quick question examples
69
+ quick_questions = ["How do I structure a storyboard?", "What makes a good visual scene?", "How to add depth to a story?"]
70
+ with gr.Row():
71
+ for question in quick_questions:
72
+ gr.Button(question, variant="secondary").click(lambda q=question: chatbot_stream(q), inputs=None, outputs=chatbot)
73
+
74
+ # Chatbot functionality
75
+ send_button.click(
76
+ fn=chatbot_stream,
77
+ inputs=chat_input,
78
+ outputs=chatbot,
79
+ queue=True
80
+ ).then(
81
+ fn=lambda: "", # Clear the input box after sending
82
+ inputs=None,
83
+ outputs=chat_input
84
+ )
85
+
86
+ with gr.TabItem("📖 Storyboard Generator"):
87
+ gr.Markdown("## Generate a Storyboard")
88
+ scenario_input = gr.Textbox(label="Enter your scenario")
89
+ generate_btn = gr.Button("Generate Storyboard")
90
+ storyboard_output = gr.Textbox(label="Generated Storyboard", interactive=False)
91
+ generate_btn.click(generate_storyboard, inputs=scenario_input, outputs=storyboard_output)
92
+
93
  app.launch(share=True)
94
 
95
  ui()