跳到正文
DEV Community· NAVEENSRI V·· 24 天前AI 評分31

GhostWriter AI:用本機 AI 創作恐怖故事

"GhostWriter AI 👻: Stories from the Other Side"

AI 導讀

GhostWriter AI 是一款在本機運行的 AI 恐怖故事生成器,讓用戶輸入故事構想、選擇恐怖類別和結局風格,再由 Qwen2.5 3B 在電腦上生成故事。應用程式以 Ollama 執行模型,提示詞可留在用戶電腦上,無須傳送至第三方雲端 AI API。測試中,模型約用 56 秒生成一篇約 414 字的恐怖故事。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

👻 GhostWriter AI — Stories from the Other Side

What if your imagination could summon a ghost to write your next horror story?

GhostWriter AI is a local AI-powered horror story generator that transforms simple ideas into chilling tales. Built for the Hacktoberfest Week 4 challenge, it explores the spooky side of artificial intelligence while demonstrating the power of running AI directly on your own computer.

Users can enter a story premise, choose a horror category, and select how the story ends.

✨ Features

  • 👻 AI Horror Story Generation: Transform simple prompts into original horror stories.
  • 🏚️ Five Horror Categories: Haunted House, Supernatural, Psychological Horror, Ghost Stories, and Urban Legends.
  • 💀 Three Ending Styles: Terrifying, Tragic, and Unexpected Twist.
  • 🖤 Cinematic Interface: A dark Halloween-inspired UI with crimson accents, spectral purple effects, and atmospheric animations.
  • 📋 Copy and Download: Save generated stories locally.
  • 🔄 Regenerate Stories: Generate different variations using the same settings.
  • 🟢 AI Health Monitoring: Check whether Ollama and the configured model are available.
  • 🔒 Local AI Inference: Generate stories without sending prompts to a third-party cloud AI API.

The goal was simple: build something spooky, visually engaging, and fun while demonstrating that AI doesn't always need to live in the cloud.

Demo

🎬 Watch GhostWriter AI in Action!

The demo showcases the spooky interface, local AI story generation, horror category selection, and different ending styles.

📹 Demo Video: Watch GhostWriter AI in Action

💻 GitHub Repository: GhostWriter AI

How to Run Locally

  1. Install Python and Ollama.
  2. Download the AI model specified in the README.
  3. Start the Flask application.
  4. Open http://127.0.0.1:5000 in your browser.

The application runs locally; the URL above is not a public deployment. See the GitHub README for complete setup instructions.

Code

👨‍💻 Explore the source code:

GhostWriter AI — GitHub Repository

The repository includes the Flask backend, HTML frontend, CSS styling, JavaScript functionality, setup instructions, and verification script.

Feel free to explore the implementation and suggest improvements!

How I Built It

I wanted to keep the architecture simple, beginner-friendly, and centered on local AI inference.

🛠️ Technology Stack

  • HTML5: Webpage structure.
  • CSS3: Cinematic horror-themed design and animations.
  • Vanilla JavaScript: User interactions, API requests, loading states, and clipboard functionality.
  • Python + Flask: Backend API and input validation.
  • Ollama: Local AI model runtime.
  • Qwen2.5 3B: Open-weight language model used for story generation.

⚙️ How It Works

  1. The user enters a story premise and selects a horror category and ending style.
  2. JavaScript sends the configuration to the Flask backend.
  3. Flask constructs the generation instructions and sends a request to the locally running Ollama API.
  4. Qwen2.5 generates the story on the user's computer.
  5. The backend returns the generated story to the frontend.
  6. The interface displays the result with options to copy, download, or regenerate it.

I also implemented a health endpoint to check whether the local AI service and configured model are available.

🧪 Testing and Verification

I verified the homepage, AI health endpoint, empty-input validation, and live story generation.

During testing, the local model successfully generated a horror story of approximately 414 words in 56 seconds.

This demonstrated that the application could generate stories without relying on a hosted AI API. Generation speed depends on the model, computer hardware, and output length.

Why Does Open Innovation Matter?

For GhostWriter AI, open innovation is more than a technology choice. It changes where AI runs and who controls the experience.

🔒 Privacy

The application communicates with a locally running Ollama instance. Prompts can remain on the user's computer rather than being sent to an external AI provider.

🌐 Offline Possibilities

Once the model has been downloaded, story generation can work without an internet connection, provided Ollama is running locally and the required resources are available.

🔧 Model Flexibility

The application can be configured to use other compatible models available through Ollama. This allows users to experiment with different models without redesigning the entire application.

💰 No Per-Request Cloud AI Charges

There are no per-request charges from a hosted AI API. Local inference still consumes computing resources and electricity, but users can experiment without depending on a paid generation service.

👨‍💻 Learning Through Open Technology

Building this application helped me understand how an AI-powered application connects its frontend, backend, and inference runtime.

Instead of treating AI as a mysterious external service, I could inspect the integration and control how the application interacts with the model.

Open innovation makes AI more accessible, customizable, and controllable.

The Spirit of It

Halloween is the perfect time to explore the strange relationship between technology and imagination.

GhostWriter AI takes the familiar idea of a ghost story and gives it a modern twist: the storyteller is an AI model running on your own computer.

There is something fun about entering a simple sentence like:

A ghost appears in my college hostel at midnight.

…and watching a local AI turn it into a supernatural mystery.

The machine may not contain a real ghost, but it can certainly create a few sleepless nights. 👻

The idea behind GhostWriter AI is simple:

Let your imagination summon the story, and let the machine bring it to life.

Built independently for the Hacktoberfest Open-Source AI Challenge Week 4.

來源:DEV Community · dev.to