Download app.py from DGRDN/TheWriter: direct link, hf CLI and curl.
- Browser
- Download file 681 Bytes
-
https://huggingface.co/spaces/DGRDN/TheWriter/resolve/main/app.py
- Command line
-
hf download hf://spaces/DGRDN/TheWriter/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DGRDN/TheWriter/resolve/main/app.py
681 Bytes
| 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() |