Kal1510 commited on
Commit
257b65b
·
verified ·
1 Parent(s): 1f6b9d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +122 -23
app.py CHANGED
@@ -233,45 +233,134 @@ def format_output(plan_text):
233
  """
234
  return styled_html
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  def create_gradio_app():
237
  with gr.Blocks(css="""
238
  .gradio-container {
239
- background: linear-gradient(to right, #fdfbfb, #ebedee);
240
- font-family: 'Segoe UI', sans-serif;
241
- padding: 30px;
242
  }
243
  .main-title {
244
  text-align: center;
245
- font-size: 40px;
246
  font-weight: bold;
247
- color: #2c3e50;
248
- margin-bottom: 10px;
249
  }
250
  .sub-title {
251
  text-align: center;
252
- font-size: 18px;
253
- color: #555;
254
- margin-bottom: 30px;
255
  }
256
  .gradio-button {
257
- background-color: #4CAF50;
258
  color: white;
259
- font-size: 18px;
260
- padding: 14px;
261
- border-radius: 8px;
262
- margin-top: 20px;
 
263
  }
264
  .gradio-button:hover {
265
- background-color: #45a049;
266
  }
267
  #output-box {
268
  height: 600px;
269
  overflow-y: scroll;
270
  padding: 20px;
271
- background-color: white;
272
- border: 1px solid #ccc;
273
  border-radius: 12px;
274
- box-shadow: 0 2px 10px rgba(0,0,0,0.05);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  }
276
  """) as demo:
277
  gr.Markdown("<div class='main-title'>Fantasy Novel Outline Generator</div>")
@@ -283,7 +372,8 @@ def create_gradio_app():
283
  label="Enter Your Fantasy Novel Idea",
284
  placeholder="e.g., A young orphan discovers they're heir to a ruined magical kingdom...",
285
  lines=5,
286
- interactive=True
 
287
  )
288
 
289
  generate_btn = gr.Button("Generate Outline", elem_classes="gradio-button")
@@ -291,14 +381,23 @@ def create_gradio_app():
291
  with gr.Column(scale=2):
292
  output_html = gr.HTML(label="AI-Generated Outline", elem_id="output-box")
293
 
 
 
 
294
  # Button logic
 
 
 
 
 
 
 
295
  generate_btn.click(
296
- fn=lambda idea: format_output(generate_fantasy_outline(idea)),
297
  inputs=[user_idea],
298
  outputs=output_html
299
  )
300
 
301
- demo.launch()
302
-
303
 
304
- create_gradio_app()
 
233
  """
234
  return styled_html
235
 
236
+ # def create_gradio_app():
237
+ # with gr.Blocks(css="""
238
+ # .gradio-container {
239
+ # background: linear-gradient(to right, #fdfbfb, #ebedee);
240
+ # font-family: 'Segoe UI', sans-serif;
241
+ # padding: 30px;
242
+ # }
243
+ # .main-title {
244
+ # text-align: center;
245
+ # font-size: 40px;
246
+ # font-weight: bold;
247
+ # color: #2c3e50;
248
+ # margin-bottom: 10px;
249
+ # }
250
+ # .sub-title {
251
+ # text-align: center;
252
+ # font-size: 18px;
253
+ # color: #555;
254
+ # margin-bottom: 30px;
255
+ # }
256
+ # .gradio-button {
257
+ # background-color: #4CAF50;
258
+ # color: white;
259
+ # font-size: 18px;
260
+ # padding: 14px;
261
+ # border-radius: 8px;
262
+ # margin-top: 20px;
263
+ # }
264
+ # .gradio-button:hover {
265
+ # background-color: #45a049;
266
+ # }
267
+ # #output-box {
268
+ # height: 600px;
269
+ # overflow-y: scroll;
270
+ # padding: 20px;
271
+ # background-color: white;
272
+ # border: 1px solid #ccc;
273
+ # border-radius: 12px;
274
+ # box-shadow: 0 2px 10px rgba(0,0,0,0.05);
275
+ # }
276
+ # """) as demo:
277
+ # gr.Markdown("<div class='main-title'>Fantasy Novel Outline Generator</div>")
278
+ # gr.Markdown("<div class='sub-title'>Turn your novel idea into a rich, detailed outline with AI-powered agents.</div>")
279
+
280
+ # with gr.Row():
281
+ # with gr.Column(scale=1):
282
+ # user_idea = gr.Textbox(
283
+ # label="Enter Your Fantasy Novel Idea",
284
+ # placeholder="e.g., A young orphan discovers they're heir to a ruined magical kingdom...",
285
+ # lines=5,
286
+ # interactive=True
287
+ # )
288
+
289
+ # generate_btn = gr.Button("Generate Outline", elem_classes="gradio-button")
290
+
291
+ # with gr.Column(scale=2):
292
+ # output_html = gr.HTML(label="AI-Generated Outline", elem_id="output-box")
293
+
294
+ # # Button logic
295
+ # generate_btn.click(
296
+ # fn=lambda idea: format_output(generate_fantasy_outline(idea)),
297
+ # inputs=[user_idea],
298
+ # outputs=output_html
299
+ # )
300
+
301
+ # demo.launch()
302
+
303
  def create_gradio_app():
304
  with gr.Blocks(css="""
305
  .gradio-container {
306
+ background: linear-gradient(to right, #3c3b6e, #121062);
307
+ font-family: 'Cinzel', serif;
308
+ padding: 40px;
309
  }
310
  .main-title {
311
  text-align: center;
312
+ font-size: 48px;
313
  font-weight: bold;
314
+ color: #f1c40f;
315
+ margin-bottom: 20px;
316
  }
317
  .sub-title {
318
  text-align: center;
319
+ font-size: 20px;
320
+ color: #ecf0f1;
321
+ margin-bottom: 40px;
322
  }
323
  .gradio-button {
324
+ background-color: #8e44ad;
325
  color: white;
326
+ font-size: 20px;
327
+ padding: 16px;
328
+ border-radius: 10px;
329
+ margin-top: 30px;
330
+ width: 100%;
331
  }
332
  .gradio-button:hover {
333
+ background-color: #9b59b6;
334
  }
335
  #output-box {
336
  height: 600px;
337
  overflow-y: scroll;
338
  padding: 20px;
339
+ background-color: #ecf0f1;
340
+ border: 1px solid #dcdde1;
341
  border-radius: 12px;
342
+ box-shadow: 0 4px 15px rgba(0,0,0,0.1);
343
+ margin-top: 20px;
344
+ }
345
+ .gradio-input {
346
+ background-color: #ecf0f1;
347
+ border-radius: 8px;
348
+ padding: 10px;
349
+ border: 1px solid #dcdde1;
350
+ font-size: 16px;
351
+ }
352
+ .gradio-input:focus {
353
+ outline: none;
354
+ border-color: #8e44ad;
355
+ }
356
+ .gradio-column {
357
+ display: flex;
358
+ justify-content: center;
359
+ }
360
+ .loading {
361
+ color: #f39c12;
362
+ font-size: 18px;
363
+ text-align: center;
364
  }
365
  """) as demo:
366
  gr.Markdown("<div class='main-title'>Fantasy Novel Outline Generator</div>")
 
372
  label="Enter Your Fantasy Novel Idea",
373
  placeholder="e.g., A young orphan discovers they're heir to a ruined magical kingdom...",
374
  lines=5,
375
+ interactive=True,
376
+ elem_classes="gradio-input"
377
  )
378
 
379
  generate_btn = gr.Button("Generate Outline", elem_classes="gradio-button")
 
381
  with gr.Column(scale=2):
382
  output_html = gr.HTML(label="AI-Generated Outline", elem_id="output-box")
383
 
384
+ # Add a loading message for user feedback
385
+ loading_message = gr.Markdown("<div class='loading'>Generating outline, please wait...</div>", visible=False)
386
+
387
  # Button logic
388
+ def generate_and_format_output(idea):
389
+ loading_message.visible = True
390
+ result = generate_fantasy_outline(idea)
391
+ formatted_result = format_output(result)
392
+ loading_message.visible = False
393
+ return formatted_result
394
+
395
  generate_btn.click(
396
+ fn=generate_and_format_output,
397
  inputs=[user_idea],
398
  outputs=output_html
399
  )
400
 
401
+ demo.launch()
 
402
 
403
+ create_gradio_app()