shakuvish commited on
Commit
b0d4f2e
·
verified ·
1 Parent(s): cdd131a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -28
app.py CHANGED
@@ -1,51 +1,56 @@
1
  import gradio as gr
2
 
3
  CLASSES = {
4
- "learn" : "Sage", "grow": "Druid", "build": "Artificer",
5
- "lead" : "Paladin", "create" : "Bard", "fight" : "Warrior",
6
- "heal" : "Cleric", "explore": "Ranger"
7
  }
8
 
9
  QUESTS = {
10
- "fear": "Conquer the Shadow keep of inner doubt",
11
- "time": "Recover the lost Hoourglass of priorities",
12
- "money": "reclaim the treasury of the forgotten kingdom",
13
- "confidence": "Drink from the wellspring of the Unshakable Resolve",
14
- "focus": " destroy the fog wraith scattered across the realm",
15
- "motivation": "relight the ancient flame of purpose",
16
- "skills" : "Apprentice under the Grandmaster hidden in the mountains",
17
  }
18
 
19
  def generate_hero(name, goal, challenge):
20
  name = name.strip() or "Stranger"
21
  goal = goal.lower()
22
  challenge = challenge.lower()
 
23
  hero_class = next((v for k, v in CLASSES.items() if k in goal), "Adventurer")
24
- quest = next((v for k, v in QUESTS.items() for k in challenge),
25
- "unravel the mystery at the end of the world ")
 
 
26
  intro = (
27
- f'In the age when legends were still being written , {name} the {helo_class}'
28
- f'rose from the humble origins with one burning desire: to {goal_rstrip(".")}. '
29
- f' yet the path was not easy . {name} faced a great darkness , {challenge.rstrip(" . ")}. '
30
- f' undettered, they set forth on the quest : to {quest:lower()}. '
31
- f' The world would never be the same'
32
  )
33
 
34
- return hero_class, quest , intro
35
 
36
- with gr.Blocks(title = "HERO GENERATOR") as app:
37
- gr.markdown("This is the hero generator")
38
 
39
  with gr.Row():
40
- name = gr.Textbox(label = "Name", placeholder = "your name")
41
- goal = gr.Textbox(label = "Goal", placeholder = "eg. get a job ")
42
- challenge = gr.Textbox(label = "Biggest Challenge", placeholder = "consistency")
 
43
  btn = gr.Button("Generate Hero", variant="primary")
44
- hero_class = gr.Textbox(label= "Hero Class")
45
- quest = gr.TextBox(label = "Main Quest")
46
- story = gr.TextBox(label = "Stroy Introduction", lines = 10)
47
 
48
- btn.click(generate_hero, inputs = [name, goal, challenge],
49
- outputs = [hero_class, quest, story])
 
 
 
 
50
 
51
  app.launch()
 
1
  import gradio as gr
2
 
3
  CLASSES = {
4
+ "learn": "Sage", "grow": "Druid", "build": "Artificer",
5
+ "lead": "Paladin", "create": "Bard", "fight": "Warrior",
6
+ "heal": "Cleric", "explore": "Ranger",
7
  }
8
 
9
  QUESTS = {
10
+ "fear": "Conquer the Shadow Keep of Inner Doubt",
11
+ "time": "Recover the Lost Hourglass of Priorities",
12
+ "money": "Reclaim the Treasury of the Forgotten Kingdom",
13
+ "confidence": "Drink from the Wellspring of Unshakeable Resolve",
14
+ "focus": "Destroy the Fog Wraith scattered across the realm",
15
+ "motivation": "Relight the Ancient Flame of Purpose",
16
+ "skill": "Apprentice under the Grandmaster hidden in the mountains",
17
  }
18
 
19
  def generate_hero(name, goal, challenge):
20
  name = name.strip() or "Stranger"
21
  goal = goal.lower()
22
  challenge = challenge.lower()
23
+
24
  hero_class = next((v for k, v in CLASSES.items() if k in goal), "Adventurer")
25
+
26
+ quest = next((v for k, v in QUESTS.items() if k in challenge),
27
+ "Unravel the Mystery at the Edge of the Known World")
28
+
29
  intro = (
30
+ f'In the age when legends were still being written, {name} the {hero_class} '
31
+ f'rose from humble origins with one burning desire: to {goal.rstrip(".")}. '
32
+ f'Yet the path was not easy. {name} faced a great darkness — {challenge.rstrip(".")}. '
33
+ f'Undeterred, they set forth on the quest: to {quest.lower()}. '
34
+ f'The world would never be the same.'
35
  )
36
 
37
+ return hero_class, quest, intro
38
 
39
+ with gr.Blocks(title="Hero Generator") as app:
40
+ gr.Markdown("# ⚔️ Hero Generator")
41
 
42
  with gr.Row():
43
+ name = gr.Textbox(label="Name", placeholder="Your name")
44
+ goal = gr.Textbox(label="Goal", placeholder="e.g. learn to code")
45
+ challenge = gr.Textbox(label="Biggest Challenge", placeholder="e.g. lack of focus")
46
+
47
  btn = gr.Button("Generate Hero", variant="primary")
 
 
 
48
 
49
+ hero_class = gr.Textbox(label="Hero Class")
50
+ quest = gr.Textbox(label="Main Quest")
51
+ story = gr.Textbox(label="Story Introduction", lines=5)
52
+
53
+ btn.click(generate_hero, inputs=[name, goal, challenge],
54
+ outputs=[hero_class, quest, story])
55
 
56
  app.launch()