zach commited on
Commit
b4a99f1
·
1 Parent(s): dfbb840

Update UI layout for randomize btn and social links

Browse files
src/assets/styles.css CHANGED
@@ -26,7 +26,7 @@ footer.svelte-1byz9vf {
26
  display: flex;
27
  align-items: center;
28
  gap: 8px;
29
- margin-right: 8px;
30
  overflow: visible !important;
31
  }
32
 
@@ -34,8 +34,8 @@ footer.svelte-1byz9vf {
34
  #github-link,
35
  #discord-link {
36
  display: inline-block !important;
37
- width: 30px !important;
38
- height: 30px !important;
39
  background-size: cover !important;
40
  background-position: center !important;
41
  background-repeat: no-repeat !important;
@@ -47,7 +47,7 @@ footer.svelte-1byz9vf {
47
  /* Hover effect for social media icons */
48
  #github-link:hover,
49
  #discord-link:hover {
50
- transform: scale(1.1);
51
  }
52
 
53
  /* Discord icon specific styling */
 
26
  display: flex;
27
  align-items: center;
28
  gap: 8px;
29
+ margin: 0px 8px;
30
  overflow: visible !important;
31
  }
32
 
 
34
  #github-link,
35
  #discord-link {
36
  display: inline-block !important;
37
+ width: 32px !important;
38
+ height: 32px !important;
39
  background-size: cover !important;
40
  background-position: center !important;
41
  background-repeat: no-repeat !important;
 
47
  /* Hover effect for social media icons */
48
  #github-link:hover,
49
  #discord-link:hover {
50
+ transform: scale(1.15);
51
  }
52
 
53
  /* Discord icon specific styling */
src/{app.py → frontend.py} RENAMED
@@ -1,5 +1,5 @@
1
  """
2
- app.py
3
 
4
  Gradio UI for interacting with the Anthropic API, Hume TTS API, and ElevenLabs TTS API.
5
 
@@ -39,7 +39,7 @@ from src.utils import (
39
  )
40
 
41
 
42
- class App:
43
  config: Config
44
  db_session_maker: AsyncDBSessionMaker
45
 
@@ -47,10 +47,7 @@ class App:
47
  self.config = config
48
  self.db_session_maker = db_session_maker
49
 
50
- async def _generate_text(
51
- self,
52
- character_description: str,
53
- ) -> Tuple[gr.Textbox, str]:
54
  """
55
  Validates the character_description and generates text using Anthropic API.
56
 
@@ -343,7 +340,7 @@ class App:
343
  False, # Reset should_enable_vote_buttons state
344
  )
345
 
346
- def _build_heading_section(self) -> Tuple[gr.HTML, gr.Button, gr.HTML]:
347
  """
348
  Builds heading section including title, randomize all button, and instructions
349
  """
@@ -372,12 +369,9 @@ class App:
372
  </div>
373
  """
374
  )
375
- randomize_all_button = gr.Button("🎲 Randomize All", variant="primary", scale=1)
376
  instructions = gr.HTML(
377
  """
378
- <p style="font-size: 16px; font-weight: bold;">
379
- <strong>Instructions</strong>
380
- </p>
381
  <ol style="margin-left: 12px;">
382
  <li>
383
  Select a sample character, or input a custom character description and click
@@ -397,20 +391,22 @@ class App:
397
  </ol>
398
  """
399
  )
400
- return (title_with_social_links, randomize_all_button, instructions)
401
 
402
- def _build_input_section(self) -> Tuple[gr.Dropdown, gr.Textbox, gr.Button, gr.Textbox, gr.Button]:
403
  """
404
  Builds the input section including the sample character description dropdown, character
405
  description input, and generate text button.
406
  """
407
- sample_character_description_dropdown = gr.Dropdown(
408
- choices=list(constants.SAMPLE_CHARACTER_DESCRIPTIONS.keys()),
409
- label="Sample Characters",
410
- info="Generate text with a sample character description.",
411
- value=None,
412
- interactive=True,
413
- )
 
 
414
  with gr.Group():
415
  character_description_input = gr.Textbox(
416
  label="Character Description",
@@ -434,11 +430,12 @@ class App:
434
  )
435
  synthesize_speech_button = gr.Button("Synthesize Speech", variant="primary")
436
  return (
437
- text_input,
438
- synthesize_speech_button,
439
  sample_character_description_dropdown,
440
  character_description_input,
441
  generate_text_button,
 
 
442
  )
443
 
444
  def _build_output_section(self) -> Tuple[gr.Audio, gr.Audio, gr.Button, gr.Button, gr.Textbox, gr.Textbox]:
@@ -501,15 +498,15 @@ class App:
501
 
502
  (
503
  title_with_social_links,
504
- randomize_all_button,
505
  instructions,
506
  ) = self._build_heading_section()
507
  (
508
- text_input,
509
- synthesize_speech_button,
510
  sample_character_description_dropdown,
511
  character_description_input,
512
  generate_text_button,
 
 
513
  ) = self._build_input_section()
514
  (
515
  option_a_audio_player,
 
1
  """
2
+ frontend.py
3
 
4
  Gradio UI for interacting with the Anthropic API, Hume TTS API, and ElevenLabs TTS API.
5
 
 
39
  )
40
 
41
 
42
+ class Frontend:
43
  config: Config
44
  db_session_maker: AsyncDBSessionMaker
45
 
 
47
  self.config = config
48
  self.db_session_maker = db_session_maker
49
 
50
+ async def _generate_text(self, character_description: str) -> Tuple[gr.Textbox, str]:
 
 
 
51
  """
52
  Validates the character_description and generates text using Anthropic API.
53
 
 
340
  False, # Reset should_enable_vote_buttons state
341
  )
342
 
343
+ def _build_heading_section(self) -> Tuple[gr.HTML, gr.HTML]:
344
  """
345
  Builds heading section including title, randomize all button, and instructions
346
  """
 
369
  </div>
370
  """
371
  )
 
372
  instructions = gr.HTML(
373
  """
374
+ <h2 style="font-size: 16px;">Instructions</h2>
 
 
375
  <ol style="margin-left: 12px;">
376
  <li>
377
  Select a sample character, or input a custom character description and click
 
391
  </ol>
392
  """
393
  )
394
+ return (title_with_social_links, instructions)
395
 
396
+ def _build_input_section(self) -> Tuple[gr.Button, gr.Dropdown, gr.Textbox, gr.Button, gr.Textbox, gr.Button]:
397
  """
398
  Builds the input section including the sample character description dropdown, character
399
  description input, and generate text button.
400
  """
401
+ with gr.Group():
402
+ randomize_all_button = gr.Button("🎲 Randomize All", variant="primary")
403
+ sample_character_description_dropdown = gr.Dropdown(
404
+ choices=list(constants.SAMPLE_CHARACTER_DESCRIPTIONS.keys()),
405
+ label="Sample Characters",
406
+ info="Generate text with a sample character description.",
407
+ value=None,
408
+ interactive=True,
409
+ )
410
  with gr.Group():
411
  character_description_input = gr.Textbox(
412
  label="Character Description",
 
430
  )
431
  synthesize_speech_button = gr.Button("Synthesize Speech", variant="primary")
432
  return (
433
+ randomize_all_button,
 
434
  sample_character_description_dropdown,
435
  character_description_input,
436
  generate_text_button,
437
+ text_input,
438
+ synthesize_speech_button,
439
  )
440
 
441
  def _build_output_section(self) -> Tuple[gr.Audio, gr.Audio, gr.Button, gr.Button, gr.Textbox, gr.Textbox]:
 
498
 
499
  (
500
  title_with_social_links,
 
501
  instructions,
502
  ) = self._build_heading_section()
503
  (
504
+ randomize_all_button,
 
505
  sample_character_description_dropdown,
506
  character_description_input,
507
  generate_text_button,
508
+ text_input,
509
+ synthesize_speech_button,
510
  ) = self._build_input_section()
511
  (
512
  option_a_audio_player,