Crateen / app.py
Saachu's picture
Update app.py
81041d1 verified
raw
history blame contribute delete
975 Bytes
import gradio as gr
import random
import hashlib
# Fixed seed for unique stories (no repeats)
STORY_SEED = None
def generate_unique_story(prompt):
global STORY_SEED
# Create unique hash from prompt + time
story_id = hashlib.md5((prompt + str(random.randint(1, 10000))).encode()).hexdigest()[:8]
# 3 Fixed Characters ALWAYS
characters = ["चिकू", "मिन्नी", "भूतू"]
# Pick random + unique
STORY_SEED = story_id
return random.choice(templates)
# UI
with gr.Blocks() as demo:
gr.Markdown("# 📖 **Unique Story Generator** (No Repeats!)")
prompt = gr.Textbox(
label="1-2 Line Idea",
placeholder="jungle me kho gaye / magic school / flying cycle",
lines=2
)
story = gr.Textbox(label="Generated Story", lines=4)
btn = gr.Button("✨ Generate New Story", variant="primary")
btn.click(generate_unique_story, prompt, story)
demo.launch()