| import gradio as gr |
| import random |
| import hashlib |
|
|
| |
| STORY_SEED = None |
|
|
| def generate_unique_story(prompt): |
| global STORY_SEED |
| |
| |
| story_id = hashlib.md5((prompt + str(random.randint(1, 10000))).encode()).hexdigest()[:8] |
| |
| |
| characters = ["चिकू", "मिन्नी", "भूतू"] |
| |
| |
| STORY_SEED = story_id |
| return random.choice(templates) |
|
|
| |
| 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() |
|
|