rtpeterson02 commited on
Commit
aaaa185
Β·
verified Β·
1 Parent(s): 63495ec

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +19 -27
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,12 +1,12 @@
1
  """
2
  PowerPoint Script Generator for HuggingFace Spaces
3
  Uses HuggingFace Inference API - No local model download required!
 
4
  """
5
 
6
  import gradio as gr
7
  from huggingface_hub import InferenceClient
8
  import os
9
- import time
10
 
11
  # ============================================================================
12
  # HUGGINGFACE INFERENCE CLIENT SETUP
@@ -126,7 +126,7 @@ Begin generating the presentation script now:"""
126
  # GRADIO INTERFACE FOR HUGGINGFACE SPACES
127
  # ============================================================================
128
 
129
- def create_gradio_interface():
130
  """Create the Gradio UI optimized for HuggingFace Spaces"""
131
 
132
  # Initialize the generator
@@ -178,8 +178,8 @@ def create_gradio_interface():
178
 
179
  yield script
180
 
181
- # Create Gradio interface
182
- with gr.Blocks(theme=gr.themes.Soft(), title="PPT Script Generator") as demo:
183
 
184
  gr.HTML(welcome_html)
185
  gr.HTML(instructions_html)
@@ -192,8 +192,7 @@ def create_gradio_interface():
192
  topic_input = gr.Textbox(
193
  label="πŸ“Œ Presentation Topic",
194
  placeholder="e.g., Introduction to Artificial Intelligence in Healthcare",
195
- lines=3,
196
- info="Enter the main topic of your presentation"
197
  )
198
 
199
  num_slides = gr.Slider(
@@ -201,8 +200,7 @@ def create_gradio_interface():
201
  maximum=10,
202
  value=5,
203
  step=1,
204
- label="πŸ“Š Number of Slides",
205
- info="How many slides do you need scripts for?"
206
  )
207
 
208
  audience = gr.Dropdown(
@@ -217,8 +215,7 @@ def create_gradio_interface():
217
  "Academic researchers"
218
  ],
219
  value="General audience",
220
- label="πŸ‘₯ Target Audience",
221
- info="Who will be listening to this presentation?"
222
  )
223
 
224
  tone = gr.Dropdown(
@@ -231,19 +228,17 @@ def create_gradio_interface():
231
  "Persuasive"
232
  ],
233
  value="Professional",
234
- label="🎨 Presentation Tone",
235
- info="What style should the script have?"
236
  )
237
 
238
  # Advanced settings
239
- with gr.Accordion("βš™οΈ Advanced Generation Settings", open=False):
240
  temperature = gr.Slider(
241
  minimum=0.3,
242
  maximum=0.9,
243
  value=0.7,
244
  step=0.1,
245
- label="🌑️ Temperature",
246
- info="Higher = more creative, Lower = more focused"
247
  )
248
 
249
  max_tokens = gr.Slider(
@@ -251,15 +246,13 @@ def create_gradio_interface():
251
  maximum=3000,
252
  value=2000,
253
  step=100,
254
- label="πŸ“ Max Tokens",
255
- info="Maximum length of generated script"
256
  )
257
 
258
  # Generate button
259
  generate_btn = gr.Button(
260
  "πŸš€ Generate Presentation Script",
261
- variant="primary",
262
- size="lg"
263
  )
264
 
265
  # Example topics
@@ -272,8 +265,7 @@ def create_gradio_interface():
272
  ["Cybersecurity Best Practices for Small Businesses", 6, "Technical professionals", "Technical and detailed"],
273
  ["Building a Strong Company Culture", 5, "Business executives", "Inspirational"]
274
  ],
275
- inputs=[topic_input, num_slides, audience, tone],
276
- label="Click any example to load it"
277
  )
278
 
279
  with gr.Column(scale=1):
@@ -282,10 +274,8 @@ def create_gradio_interface():
282
  output = gr.Textbox(
283
  label="Presentation Script",
284
  lines=30,
285
- max_lines=35,
286
- show_copy_button=True,
287
  placeholder="Your generated presentation script will appear here...\n\n⏱️ Generation typically takes 10-30 seconds.",
288
- info="Copy this script and use it for your presentation!"
289
  )
290
 
291
  # Tips section
@@ -337,7 +327,9 @@ if __name__ == "__main__":
337
  print("="*80)
338
 
339
  # Create and launch the interface
340
- demo = create_gradio_interface()
341
 
342
- # Launch - HuggingFace Spaces will handle the hosting
343
- demo.launch()
 
 
 
1
  """
2
  PowerPoint Script Generator for HuggingFace Spaces
3
  Uses HuggingFace Inference API - No local model download required!
4
+ Compatible with Gradio 4.x and 6.x
5
  """
6
 
7
  import gradio as gr
8
  from huggingface_hub import InferenceClient
9
  import os
 
10
 
11
  # ============================================================================
12
  # HUGGINGFACE INFERENCE CLIENT SETUP
 
126
  # GRADIO INTERFACE FOR HUGGINGFACE SPACES
127
  # ============================================================================
128
 
129
+ def create_interface():
130
  """Create the Gradio UI optimized for HuggingFace Spaces"""
131
 
132
  # Initialize the generator
 
178
 
179
  yield script
180
 
181
+ # Create interface using Blocks
182
+ with gr.Blocks(title="PPT Script Generator") as demo:
183
 
184
  gr.HTML(welcome_html)
185
  gr.HTML(instructions_html)
 
192
  topic_input = gr.Textbox(
193
  label="πŸ“Œ Presentation Topic",
194
  placeholder="e.g., Introduction to Artificial Intelligence in Healthcare",
195
+ lines=3
 
196
  )
197
 
198
  num_slides = gr.Slider(
 
200
  maximum=10,
201
  value=5,
202
  step=1,
203
+ label="πŸ“Š Number of Slides"
 
204
  )
205
 
206
  audience = gr.Dropdown(
 
215
  "Academic researchers"
216
  ],
217
  value="General audience",
218
+ label="πŸ‘₯ Target Audience"
 
219
  )
220
 
221
  tone = gr.Dropdown(
 
228
  "Persuasive"
229
  ],
230
  value="Professional",
231
+ label="🎨 Presentation Tone"
 
232
  )
233
 
234
  # Advanced settings
235
+ with gr.Accordion("βš™οΈ Advanced Settings", open=False):
236
  temperature = gr.Slider(
237
  minimum=0.3,
238
  maximum=0.9,
239
  value=0.7,
240
  step=0.1,
241
+ label="🌑️ Temperature"
 
242
  )
243
 
244
  max_tokens = gr.Slider(
 
246
  maximum=3000,
247
  value=2000,
248
  step=100,
249
+ label="πŸ“ Max Tokens"
 
250
  )
251
 
252
  # Generate button
253
  generate_btn = gr.Button(
254
  "πŸš€ Generate Presentation Script",
255
+ variant="primary"
 
256
  )
257
 
258
  # Example topics
 
265
  ["Cybersecurity Best Practices for Small Businesses", 6, "Technical professionals", "Technical and detailed"],
266
  ["Building a Strong Company Culture", 5, "Business executives", "Inspirational"]
267
  ],
268
+ inputs=[topic_input, num_slides, audience, tone]
 
269
  )
270
 
271
  with gr.Column(scale=1):
 
274
  output = gr.Textbox(
275
  label="Presentation Script",
276
  lines=30,
 
 
277
  placeholder="Your generated presentation script will appear here...\n\n⏱️ Generation typically takes 10-30 seconds.",
278
+ interactive=False
279
  )
280
 
281
  # Tips section
 
327
  print("="*80)
328
 
329
  # Create and launch the interface
330
+ demo = create_interface()
331
 
332
+ # Launch with appropriate settings
333
+ demo.launch(
334
+ show_error=True
335
+ )
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio
2
  huggingface_hub
 
1
+ gradio>=4.0.0,<5.0.0
2
  huggingface_hub