Spaces:
Sleeping
Sleeping
applied stat generation functions to all stats
Browse files31 unmodified lines3233343536374 unmodified lines424344454647484950515253545556575859606122 unmodified lines8485868788898 unmodified lines98991001011021031043 unmodified lines1081091101111121131141151161171181191201211221231241253 unmodified lines12913013113213313431 unmodified linessmash = ''pref_traits = ''ick_traits = ''4 unmodified linesoutput1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {prompt}\n\nDescribe:"output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)global acac = random.randint(2,14)global hphp = constitution + random.randint(1,6)global smashsmash = random.randint(1,30)input_file = open('traits.txt', 'r')traits = input_file.readline()global pref_traitspicks = int(random.randint(1,3))pref_traits = random.choice(traits, k=picks)global ick_traitspicks = int(random.randint(1,3))ick_traits = random.choice(traits, k=picks)return output1[0]["generated_text"].strip(),output2[0]["generated_text"].strip()@spaces.GPU22 unmodified linescharisma = random.randint(2,12)return strength, dexterity, constitution, intelligence, wisdom, charisma##UI is fine as-iswith gr.Blocks() as demo:8 unmodified linesbtn = gr.Button("Generate")rand = gr.Button("Random")with gr.Row(equal_height=True):with gr.Column(scale = 0):stre_box = gr.Textbox(value = strength, label = "Strength", interactive = False)3 unmodified lineswis_box = gr.Textbox(value = wisdom, label = "Wisdom", interactive = False)char_box = gr.Textbox(value = charisma, label = "Charisma", interactive = False)btn.click(fn = stats_gen, outputs = [stre_box, dex_box, con_box, intl_box, wis_box, char_box])with gr.Column(scale = 2):text_out1 = gr.Textbox(label = "Description")text_out2 = gr.Textbox(label = "Backstory")btn.click(fn = char_description,inputs = text_in, outputs = [text_out1, text_out2])rand.click(fn = rand_char_description,inputs = None, outputs = [text_out1, text_out2])with gr.Column(scale = 0):ac_box = gr.Textbox(value = ac, label = "AC", interactive = False)hp_box = gr.Textbox(value = hp, label = "HP", interactive = False)speed_box = gr.Textbox(value = "25 ft", label = "Speed", interactive = False)with gr.Row():3 unmodified linesdcs = gr.Textbox(value = smash, label = "DC to Smash")prefs = gr.Textbox(value = pref_traits, label = "Advantage if:")icks = gr.Textbox(value = ick_traits, label = "Disdvantage if:")31 unmodified lines323334353637384 unmodified lines43444546474822 unmodified lines7172737475767778798081828384858687888990919293949596978 unmodified lines1061071081091101111123 unmodified lines1161171181191201211221231241251261271281291301311321331341351363 unmodified lines14014114214314414514614731 unmodified linessmash = ''pref_traits = ''ick_traits = ''speed = ''4 unmodified linesoutput1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {prompt}\n\nDescribe:"output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)return output1[0]["generated_text"].strip(),output2[0]["generated_text"].strip()@spaces.GPU22 unmodified linescharisma = random.randint(2,12)return strength, dexterity, constitution, intelligence, wisdom, charismadef stats_gen_2():global acac = random.randint(2,14)global hphp = constitution + random.randint(1,6)global speedspeed = '25 ft'return ac, hp, speeddef bard_stats_gen():global smashsmash = random.randint(1,30)input_file = open('traits.txt', 'r')traits = input_file.readline()global pref_traitspicks = int(random.randint(1,3))pref_traits = random.choice(traits, k=picks)global ick_traitspicks = int(random.randint(1,3))ick_traits = random.choice(traits, k=picks)return smash, pref_traits, ick_traits##UI is fine as-iswith gr.Blocks() as demo:8 unmodified linesbtn = gr.Button("Generate")rand = gr.Button("Random")with gr.Row():with gr.Column(scale = 0):stre_box = gr.Textbox(value = strength, label = "Strength", interactive = False)3 unmodified lineswis_box = gr.Textbox(value = wisdom, label = "Wisdom", interactive = False)char_box = gr.Textbox(value = charisma, label = "Charisma", interactive = False)btn.click(fn = stats_gen, outputs = [stre_box, dex_box, con_box, intl_box, wis_box, char_box])rand.click(fn = stats_gen, outputs = [stre_box, dex_box, con_box, intl_box, wis_box, char_box])with gr.Column(scale = 2):text_out1 = gr.Textbox(label = "Description")text_out2 = gr.Textbox(label = "Backstory")btn.click(fn = char_description,inputs = text_in, outputs = [text_out1, text_out2])rand.click(fn = rand_char_description, outputs = [text_out1, text_out2])with gr.Column(scale = 0):ac_box = gr.Textbox(value = ac, label = "AC", interactive = False)hp_box = gr.Textbox(value = hp, label = "HP", interactive = False)speed_box = gr.Textbox(value = "25 ft", label = "Speed", interactive = False)btn.click(fn = stats_gen_2, outputs = [ac_box, hp_box, speed_box])rand.click(fn = stats_gen_2, outputs = [ac_box, hp_box, speed_box])with gr.Row():3 unmodified linesdcs = gr.Textbox(value = smash, label = "DC to Smash")prefs = gr.Textbox(value = pref_traits, label = "Advantage if:")icks = gr.Textbox(value = ick_traits, label = "Disdvantage if:")btn.click(fn = bard_stats_gen, outputs = [dcs, prefs, icks])rand.click(fn = bard_stats_gen, outputs = [dcs, prefs, icks])
app.py+29-16