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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +122 -53
app.py CHANGED
@@ -300,67 +300,147 @@ def format_output(plan_text):
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,8 +452,7 @@ def create_gradio_app():
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,23 +460,13 @@ def create_gradio_app():
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()
 
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>")
367
+ # gr.Markdown("<div class='sub-title'>Turn your novel idea into a rich, detailed outline with AI-powered agents.</div>")
368
+
369
+ # with gr.Row():
370
+ # with gr.Column(scale=1):
371
+ # user_idea = gr.Textbox(
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")
380
+
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
+
404
  def create_gradio_app():
405
  with gr.Blocks(css="""
406
  .gradio-container {
407
+ background: url('https://www.freepik.com/free-photos-vectors/fantasy-background') no-repeat center center fixed;
408
+ background-size: cover;
409
+ font-family: 'Segoe UI', sans-serif;
410
+ padding: 30px;
411
  }
412
  .main-title {
413
  text-align: center;
414
+ font-size: 50px;
415
  font-weight: bold;
416
+ color: #FAF3E0;
417
  margin-bottom: 20px;
418
  }
419
  .sub-title {
420
  text-align: center;
421
+ font-size: 24px;
422
+ color: #D1C6E1;
423
+ margin-bottom: 30px;
424
  }
425
  .gradio-button {
426
+ background-color: #A2C2E1;
427
  color: white;
428
+ font-size: 18px;
429
+ padding: 14px;
430
+ border-radius: 8px;
431
+ margin-top: 20px;
 
432
  }
433
  .gradio-button:hover {
434
+ background-color: #A8E6CF;
435
  }
436
  #output-box {
437
  height: 600px;
438
  overflow-y: scroll;
439
  padding: 20px;
440
+ background-color: white;
441
+ border: 1px solid #ccc;
442
  border-radius: 12px;
443
+ box-shadow: 0 2px 10px rgba(0,0,0,0.05);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
  """) as demo:
446
  gr.Markdown("<div class='main-title'>Fantasy Novel Outline Generator</div>")
 
452
  label="Enter Your Fantasy Novel Idea",
453
  placeholder="e.g., A young orphan discovers they're heir to a ruined magical kingdom...",
454
  lines=5,
455
+ interactive=True
 
456
  )
457
 
458
  generate_btn = gr.Button("Generate Outline", elem_classes="gradio-button")
 
460
  with gr.Column(scale=2):
461
  output_html = gr.HTML(label="AI-Generated Outline", elem_id="output-box")
462
 
 
 
 
463
  # Button logic
 
 
 
 
 
 
 
464
  generate_btn.click(
465
+ fn=lambda idea: format_output(generate_fantasy_outline(idea)),
466
  inputs=[user_idea],
467
  outputs=output_html
468
  )
469
 
470
+ demo.launch()
471
 
472
  create_gradio_app()