mecoffey commited on
Commit
9b0c803
·
1 Parent(s): b2bd2e5

refining stat generation

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -42,18 +42,6 @@ def char_description(prompt):
42
  output1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)
43
  prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {prompt}\n\nDescribe:"
44
  output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
45
- global strength
46
- strength = random.randint(2,12)
47
- global dexterity
48
- dexterity = random.randint(2,12)
49
- global constitution
50
- constitution = random.randint(2,12)
51
- global intelligence
52
- intelligence = random.randint(2,12)
53
- global wisdom
54
- wisdom = random.randint(2,12)
55
- global charisma
56
- charisma = random.randint(2,12)
57
  global ac
58
  ac = random.randint(2,14)
59
  global hp
@@ -79,6 +67,9 @@ def rand_char_description():
79
  output1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)
80
  prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {rand_race}\n\nDescribe:"
81
  output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
 
 
 
82
  global strength
83
  strength = random.randint(2,12)
84
  global dexterity
@@ -91,10 +82,11 @@ def rand_char_description():
91
  wisdom = random.randint(2,12)
92
  global charisma
93
  charisma = random.randint(2,12)
94
- return output1[0]["generated_text"].strip(),output2[0]["generated_text"].strip()
 
95
 
96
  ##UI is fine as-is
97
- with gr.Blocks(live = True) as demo:
98
  title = gr.HTML("<center><h1>NPC Generator</h1></center>")
99
  description = gr.HTML("<center>For tabletop GMs when players ask for a description of random people in the tavern.</center>")
100
  tags = gr.HTML("<center>| Backyard AI | Tiny Titan |</center>")
@@ -115,6 +107,7 @@ with gr.Blocks(live = True) as demo:
115
  intl_box = gr.Textbox(value = intelligence, label = "Intelligence", interactive = False)
116
  wis_box = gr.Textbox(value = wisdom, label = "Wisdom", interactive = False)
117
  char_box = gr.Textbox(value = charisma, label = "Charisma", interactive = False)
 
118
 
119
  with gr.Column(scale = 2):
120
  text_out1 = gr.Textbox(label = "Description")
@@ -136,6 +129,7 @@ with gr.Blocks(live = True) as demo:
136
  dcs = gr.Textbox(value = smash, label = "DC to Smash")
137
  prefs = gr.Textbox(value = pref_traits, label = "Advantage if:")
138
  icks = gr.Textbox(value = ick_traits, label = "Disdvantage if:")
 
139
 
140
 
141
  # Need to add export feature.
 
42
  output1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)
43
  prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {prompt}\n\nDescribe:"
44
  output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
 
 
 
 
 
 
 
 
 
 
 
 
45
  global ac
46
  ac = random.randint(2,14)
47
  global hp
 
67
  output1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)
68
  prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {rand_race}\n\nDescribe:"
69
  output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
70
+ return output1[0]["generated_text"].strip(),output2[0]["generated_text"].strip()
71
+
72
+ def stats_gen():
73
  global strength
74
  strength = random.randint(2,12)
75
  global dexterity
 
82
  wisdom = random.randint(2,12)
83
  global charisma
84
  charisma = random.randint(2,12)
85
+ return strength, dexterity, constitution, intelligence, wisdom, charisma
86
+
87
 
88
  ##UI is fine as-is
89
+ with gr.Blocks() as demo:
90
  title = gr.HTML("<center><h1>NPC Generator</h1></center>")
91
  description = gr.HTML("<center>For tabletop GMs when players ask for a description of random people in the tavern.</center>")
92
  tags = gr.HTML("<center>| Backyard AI | Tiny Titan |</center>")
 
107
  intl_box = gr.Textbox(value = intelligence, label = "Intelligence", interactive = False)
108
  wis_box = gr.Textbox(value = wisdom, label = "Wisdom", interactive = False)
109
  char_box = gr.Textbox(value = charisma, label = "Charisma", interactive = False)
110
+ btn.click(fn = stats_gen, outputs = [stre_box, dex_box, con_box, intl_box, wis_box, char_box])
111
 
112
  with gr.Column(scale = 2):
113
  text_out1 = gr.Textbox(label = "Description")
 
129
  dcs = gr.Textbox(value = smash, label = "DC to Smash")
130
  prefs = gr.Textbox(value = pref_traits, label = "Advantage if:")
131
  icks = gr.Textbox(value = ick_traits, label = "Disdvantage if:")
132
+
133
 
134
 
135
  # Need to add export feature.