import gradio as gr import random # # Predefined lists for character descriptions # names = ["Aria", "Bren", "Cyra", "Derek", "Elara", "Finn", "Gwen", "Hank"] # genders = ["male", "female"] traits = ["brave", "clever", "kind", "mysterious", "strong", "wise"] superpowers = ["flying", "invisibility", "super strength", "telepathy", "time travel", "shape-shifting"] # Example scenarios for different traits and superpowers scenarios = { "brave": { "flying": "Soaring through the skies, {name} defends the helpless and battles evil forces.", "invisibility": "In the shadows, {name} uses their power to uncover hidden secrets and protect the innocent.", "super strength": "With unmatched power, {name} stands as a shield against all dangers, fighting for justice.", "telepathy": "Reading minds, {name} can sense danger before it happens and guide others to safety.", "time travel": "Venturing through time, {name} seeks to correct historical wrongs and ensure a better future.", "shape-shifting": "Assuming different forms, {name} infiltrates enemy ranks and gathers crucial information." }, "clever": { "flying": "Using their intelligence and agility, {name} solves complex problems while soaring through the skies.", "invisibility": "By becoming invisible, {name} cleverly outsmarts opponents and completes covert missions.", "super strength": "With a mind as sharp as their muscles, {name} uses their strength to devise innovative solutions.", "telepathy": "Strategically reading minds, {name} manipulates situations to their advantage and outwits adversaries.", "time travel": "Navigating through different eras, {name} cleverly adjusts their plans to meet changing circumstances.", "shape-shifting": "Transforming into various forms, {name} adapts quickly to solve problems and overcome obstacles." }, "kind": { "flying": "{name} flies gracefully to help those in need, offering support and comfort from above.", "invisibility": "{name} uses their invisibility to provide quiet assistance and aid those who are in trouble.", "super strength": "{name} uses their strength to protect and uplift others, always ready to lend a hand.", "telepathy": "{name} senses the emotions of others and offers empathy and guidance to those who need it.", "time travel": "{name} travels through time to assist and support others, ensuring their well-being across eras.", "shape-shifting": "{name} transforms into different forms to provide help and comfort to those around them." }, "mysterious": { "flying": "{name} glides through the clouds, their true motives and intentions remaining a mystery.", "invisibility": "{name} remains hidden in the shadows, revealing their presence only when necessary.", "super strength": "{name} displays their immense power with an enigmatic aura, leaving others in awe and uncertainty.", "telepathy": "{name} communicates silently, their thoughts and intentions shrouded in secrecy.", "time travel": "{name} moves through time with an air of enigma, their purpose and actions often unclear.", "shape-shifting": "{name} shifts forms unpredictably, keeping others guessing about their true identity." }, "strong": { "flying": "{name} flies with unwavering strength, overcoming any obstacles in their path and protecting the skies.", "invisibility": "{name} uses their power to strike decisively from the shadows, with immense force and precision.", "super strength": "{name} showcases their physical prowess, crushing barriers and defeating foes with sheer might.", "telepathy": "{name} uses their mental strength to control and influence others, bending minds to their will.", "time travel": "{name} travels through time with the strength to face any challenge, reshaping history with power.", "shape-shifting": "{name} transforms into powerful forms, using their enhanced abilities to dominate and control." }, "wise": { "flying": "{name} flies high, offering sage advice and guidance to those they encounter from above.", "invisibility": "{name} remains unseen, providing wisdom and insights discreetly to those who seek it.", "super strength": "{name} uses their strength wisely, knowing when to act and when to support others quietly.", "telepathy": "{name} reads minds with profound understanding, offering guidance and solutions to complex problems.", "time travel": "{name} travels through time with a deep knowledge of history, correcting mistakes with careful precision.", "shape-shifting": "{name} adapts to various forms, using their wisdom to make the best decisions in any situation." } } def generate_character_description(name, gender, trait, superpower): # Ensure the trait and superpower exist in the scenarios dictionary if trait in scenarios and superpower in scenarios[trait]: description = scenarios[trait][superpower].format(name=name) else: description = f"{name} is a character with a {trait} personality and the superpower of {superpower}. More details to come!" return description # Gradio interface iface = gr.Interface( fn=generate_character_description, inputs=[ gr.Textbox(label="Name", placeholder="Enter the character's name"), gr.Radio(label="Gender", choices=['female','male']), gr.Dropdown(label="Personality Trait", choices=traits), gr.Dropdown(label="Superpower", choices=superpowers) ], outputs="text", title="Games Senarios Generator Base on Character Description", description="Enter details about your character to generate a game senario!" ) iface.launch()