What if you could talk to a ghost without needing an internet connection?
With Halloween approaching, I wanted to build something different from the usual productivity tools and experiment with open-source AI in a more creative way.
Introducing GhostWriter AI, a spooky AI storytelling application where users can interact with a mysterious ghost persona and generate creepy stories using a locally running open-weight language model.
The idea is simple: enter a prompt, summon the ghost, and see what story it tells.
No cloud-based AI API. No paid inference service. Just a local AI model bringing spooky stories to life.
What I Built
GhostWriter AI is a horror-themed AI storytelling web application powered by an open-weight language model.
Users can interact with an AI ghost that generates creepy responses and short horror stories based on their prompts.
Key Features
- AI Ghost Chat: Have conversations with a mysterious ghost persona.
- Horror Story Generator: Generate original horror stories from user prompts.
- Multiple Horror Themes: Explore haunted houses, paranormal encounters, abandoned places, mysterious disappearances, and supernatural events.
- Story Regeneration: Generate alternative versions of a story.
- Save Favorites: Save interesting stories and revisit them later.
- Offline AI Inference: Generate responses using a locally running model through Ollama.
- Haunted UI: A dark terminal-inspired interface with glowing text and spooky visual effects.
The goal was to combine a simple AI application with an entertaining user experience.
Code
GitHub Repository: [https://github.com/Leafyte/GhostwriterAi]
The project is built with a lightweight architecture:
GhostWriter-AI/
│
├── app.py
├── requirements.txt
│
├── templates/
│ └── index.html
│
├── static/
│ ├── style.css
│ └── script.js
│
└── README.md
The application separates the frontend, backend, and AI integration to keep the code simple and maintainable.
How I Built It
I wanted to keep the technology stack simple and focus on integrating open-weight AI into a working application.
Technology Stack
| Component | Technology |
|---|---|
| Frontend | HTML, CSS, JavaScript |
| Backend | Python Flask |
| AI Model | Gemma via Ollama |
| AI Inference | Local inference |
| Storage | Browser localStorage |
1. Frontend – The Haunted Interface
The frontend is built using HTML, CSS, and JavaScript.
I chose a dark, terminal-inspired visual style to create the feeling of interacting with something mysterious.
The interface includes:
- A ghost-themed chat interface.
- A prompt input area.
- Horror theme selection.
- A story generation interface.
- Saved stories.
The objective was to make the application feel like a small haunted terminal rather than a conventional chatbot.
2. Backend – Python Flask
Python Flask handles communication between the frontend and the local AI model.
When a user submits a prompt, the frontend sends a request to the Flask backend.
The backend prepares the prompt, adds the ghost persona instructions, and sends the request to Ollama.
Once the model generates a response, Flask returns it to the frontend for display.
3. AI – Gemma Through Ollama
This is the most important part of the project.
I used the Gemma open-weight model through Ollama for local AI inference.
Instead of depending on an external AI API, the application communicates with a model running on the user's own computer.
I also use prompt instructions to define the ghost's personality and storytelling behavior.
For example, the model is instructed to:
- Speak in a mysterious and eerie tone.
- Create suspense before revealing important details.
- Generate imaginative supernatural scenarios.
- Adapt its storytelling style to the user's prompt.
This makes the model behave like a fictional ghost storyteller rather than a generic assistant.
4. Saving Stories
The application uses browser localStorage to save favorite stories.
This means users can revisit saved stories without needing an account or a remote database.
It also keeps the initial project lightweight.
Why Does Open Innovation Matter?
Open innovation is not just a technology choice for GhostWriter AI. It is what makes the local AI experience possible without depending on a paid hosted inference service.
1. Local AI Processing
By running Gemma through Ollama, the application can generate stories locally.
User prompts are sent to the local model instead of an external AI provider.
This reduces dependence on remote services and gives users more control over their data.
2. No Per-Request API Charges
Traditional hosted AI APIs may charge based on token usage or the number of requests.
With a locally running open-weight model, there are no per-request charges from a hosted AI provider.
Of course, local inference still requires hardware resources and electricity.
For a small storytelling application, this makes experimenting with repeated generations more accessible.
3. Freedom to Customize
Open-weight models give developers more flexibility to experiment.
I can modify prompts, change the ghost's personality, experiment with different storytelling styles, and replace the model with another compatible open-weight model.
I'm not tied to one AI provider's API, pricing structure, or hosted model behavior.
4. Learning Through Open Source
Another benefit is the opportunity to understand how AI applications work behind the scenes.
Rather than simply calling an external API, I can explore local inference, model configuration, prompt engineering, and backend integration.
That flexibility makes open-source AI particularly interesting for independent developers and small projects.
The Ghost in the Machine
The interesting part of this project is that the ghost itself is not a predefined collection of stories.
Its responses are generated dynamically by the language model based on the user's prompts and the instructions defining its personality.
Every interaction can produce a different story.
One prompt might lead to a haunted house. Another might create a mysterious encounter in an abandoned railway station.
The model acts as the storytelling engine, while the application provides the experience around it.
Challenges I Faced
Building a local AI application also comes with some practical challenges.
Model performance: Local inference depends on the available hardware. Larger models may take longer to generate responses.
Prompt consistency: Getting the model to maintain a consistent ghost personality requires carefully written instructions.
Response quality: AI-generated stories can sometimes be repetitive or unpredictable.
Local setup: Users need to install Ollama and download the required model before using the application.
These are areas I would like to improve as the project evolves.
What's Next?
GhostWriter AI is a starting point, and there are several directions I would like to explore:
- Voice interaction with the ghost.
- Text-to-speech for reading stories aloud.
- More detailed horror personalities.
- Story history and collections.
- Customizable story length and intensity.
- Additional locally supported open-weight models.
The long-term idea is to make it feel more like an interactive storytelling experience than a regular chatbot.
Conclusion
GhostWriter AI started as a small experiment inspired by Halloween and the idea of bringing something mysterious to life using open-source AI.
By combining Flask, JavaScript, Ollama, and an open-weight Gemma model, I created a local AI storytelling application that generates spooky stories without relying on a paid hosted AI API.
This project reminded me that AI doesn't always need to solve a complicated business problem. Sometimes, it can simply make an experience more interesting, creative, and fun.
The ghost lives in the machine, and this time, it runs locally.
Happy Halloween! Stay curious, and don't trust every voice coming from your terminal. 👻
Thanks for reading!
Top comments (0)