import gradio as gr
import random
def char_description(prompt):
output1 = "I see you asked for " + prompt + "!"
output2 = "I cannot create " + prompt + " yet, because I do not have a brain."
return output1, output2
with gr.Blocks() as demo:
title = gr.HTML("
NPC Generator
")
description = gr.HTML("For tabletop GMs when players ask for a description of random people in the tavern.")
tags = gr.HTML("| Backyard AI | Tiny Titan | Well Tuned |")
with gr.Row(equal_height = True):
with gr.Column(scale = 2):
text_in = gr.Textbox(label="What npc do you need?")
with gr.Column(scale = 0):
btn = gr.Button("Generate")
rand = gr.Button("Random")
with gr.Row():
with gr.Column(scale = 0):
str = gr.Textbox(value = lambda:random.randint(1,20), label = "Strength", interactive = False)
dex = gr.Textbox(value = lambda:random.randint(1,20), label = "Dexterity", interactive = False)
con = gr.Textbox(value = lambda:random.randint(1,20), label = "Constitution", interactive = False)
int = gr.Textbox(value = lambda:random.randint(1,20), label = "Intelligence", interactive = False)
wis = gr.Textbox(value = lambda:random.randint(1,20), label = "Wisdom", interactive = False)
char = gr.Textbox(value = lambda:random.randint(1,20), label = "Charisma", interactive = False)
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 = char_description,inputs = text_in, outputs = [text_out1, text_out2])
with gr.Column(scale = 0):
ac = gr.Textbox(value = lambda:random.randint(1,20), label = "AC", interactive = False)
speed = gr.Textbox(value = lambda:"25 ft", label = "Speed", interactive = False)
with gr.Row():
with gr.Accordion("Bard Stats", open = False):
with gr.Row():
dcs = gr.Textbox(label = "DC to Smash")
prefs = gr.Textbox(label = "Advantage if:")
demo.launch(theme = gr.themes.Monochrome())