What if you could create your own spooky ghost stories without sending every prompt to an online AI service? 👻
For the Hacktoberfest 2026 Week 4 challenge, Ghost in the Machine, I built GhostStoriesAI — a Python command-line application that generates spooky stories using a locally running AI model.
This project was a fun way to explore local AI, Python, and the possibilities of open-source AI tools.
👻 What is GhostStoriesAI?
GhostStoriesAI lets users enter a theme and generate a short, spooky ghost story. They can save stories they like and revisit them later.
For example, I entered this theme:
"A school constructed on a graveyard"
The AI generated a chilling story about an old school, strange whispers in its corridors, and a spirit searching for a lost student.
The application then allowed me to save the story and read it again from the saved stories menu.
✨ Features
Here are the features I've implemented so far:
- AI-powered story generation: Generate five-sentence ghost stories based on a theme provided by the user.
- Save stories: Store generated stories as text files.
- Read saved stories: Browse saved stories and select one to read.
- Input validation: Handle empty themes, invalid menu choices, and invalid story numbers.
- Error handling: Handle errors during AI generation and when reading saved files.
- Local model execution: Generate stories using a model running through Ollama on my machine.
🛠️ Tech Stack
I used the following technologies:
- Python — application logic and file handling.
- Ollama — to run and interact with the local AI model.
-
Gemma 3 1B (
gemma3:1b) — the model used to generate stories. -
Python's
osmodule — to create directories, list saved stories, and manage story files.
🧠 How does it work?
The application follows a simple workflow:
- The user chooses an option from the menu.
- If they choose to generate a story, they enter a theme.
- Python sends the prompt to the locally running Gemma model through Ollama.
- The generated story is displayed in the terminal.
- The user can choose to save it in the
saved_stories/directory. - Saved stories can be listed and read whenever the application runs again.
Here's a small example of how I call the model:
response = ollama.chat(
model="gemma3:1b",
messages=[
{
"role": "user",
"content": (
f"Write a short, spooky ghost story "
f"in 5 sentences about {theme}."
)
}
]
)
story = response["message"]["content"]
print(story)
This is the core of the application: a Python program communicating with an AI model running locally through Ollama.
🌱 Why does open innovation matter?
For me, one of the most interesting parts of this project was experimenting with local AI instead of relying on a hosted AI API.
Here are a few things I appreciate about this approach:
1. More control over the setup
I can choose the model I want to run and experiment with different prompts. The application isn't tied to a single hosted AI API.
2. Local inference and privacy
After the model has been downloaded and configured, story generation can happen locally. The prompts and generated stories do not need to be sent to a third-party AI inference service by this application.
3. Learning by building
Tools like Ollama make it easier for beginners to experiment with AI models and integrate them into their own Python applications.
4. Room to experiment
This project could be extended with different storytelling styles, additional models, or a graphical interface. Working with accessible tools gives me a foundation for exploring those possibilities.
Local inference still requires suitable hardware and disk space, and downloading the model initially requires an internet connection. But once everything is set up, the application can generate stories without needing an online inference API.
👩💻 What I learned
Building GhostStoriesAI helped me practise several concepts:
- Integrating a local AI model into a Python application.
- Working with user input and menu-driven programs.
- Reading and writing text files.
- Managing saved files without overwriting existing stories.
- Adding input validation and exception handling.
- Turning an idea into a working project step by step.
I also learned that a useful AI application doesn't have to be complicated. Even a small command-line project can demonstrate how AI can be integrated into everyday programming.
🚀 Try GhostStoriesAI
GitHub repository: [Add your GhostStoriesAI repository link here]
To run the project locally:
- Install Python and Ollama.
- Download the model:
ollama pull gemma3:1b
- Install the Python dependency:
pip install -r requirements.txt
- Start the application:
python app.py
Make sure Ollama is running before generating stories.
🔮 What's next?
I'd love to improve GhostStoriesAI with features such as:
- More genres and storytelling styles.
- Custom story lengths and intensity settings.
- A graphical user interface.
- A more polished experience for managing saved stories.
For now, I'm happy to have built a working local AI story generator and explored how accessible AI tools can support small, creative projects.
🎃 Final thoughts
GhostStoriesAI started with a simple idea: what if a locally running AI could tell spooky stories?
Building it gave me an opportunity to experiment with Python, Ollama, and Gemma while exploring the Ghost in the Machine theme for Hacktoberfest 2026.
Open innovation matters because it gives developers the freedom to experiment, learn, adapt, and build on accessible technologies.
I'd love to hear your thoughts!
What would you build with a locally running AI model?
Top comments (0)