File size: 681 Bytes
f3d703a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

# Load a storytelling model
story_gen = pipeline("text-generation", model="gpt2")

def generate_story(prompt):
    try:
        story = story_gen(prompt, max_length=300, do_sample=True, temperature=0.9)[0]["generated_text"]
        return story
    except Exception as e:
        return f"โš ๏ธ Error: {str(e)}"

demo = gr.Interface(
    fn=generate_story,
    inputs=gr.Textbox(lines=2, placeholder="Enter a story prompt..."),
    outputs=gr.Textbox(lines=15, label="๐Ÿ“– Your AI-generated story"),
    title="๐Ÿ“ Narrative Generator",
    description="Enter a prompt and let the AI write a story for you!"
)

demo.launch()