跳到正文
DEV Community· Anton Luckshman·· 3 小時前AI 評分42

Ghost Archive:以本機開放權重 AI 保存故事與回憶

Ghost Archive: a home for stories that stay, powered by local open-weight AI

AI 導讀

Ghost Archive 是一款以本機開放權重 AI 撰寫鬼故事或紀念文字的私密寫作工具,採用 Qwen3-4B 和 Ollama,並可在設定中選擇其他已下載的本機聊天模型。完成設定後,寫作流程無需連接互聯網;回憶不會傳送至託管模型服務,作品可儲存或匯出為純文字或 JSON。

正文

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

What I Built

Ghost Archive is a small, private writing room for two kinds of stories: the ones that make an empty hallway feel occupied, and the ones that make a person feel a little less far away.

In ghost-story mode, a few fragments become supernatural fiction. A light that comes on at 3:17. A radio without a power cord. A second cup on an empty table.

In remembrance mode, those fragments become a tribute: a favorite song, a windowsill full of marigolds, a small ritual someone left behind. This mode has a separate prompt that forbids inventing biography, impersonating a loved one, or claiming contact with the dead. A tribute is something to review and keep, rather than a simulated conversation.

The app is inspired by Halloween and by the act of keeping memories alive. It does not claim to reproduce an ofrenda or speak for any cultural tradition.

Try It Locally

The source is available in the Ghost Archive repository. To use it on your own computer:

  1. Start Ollama and download Qwen3-4B with ollama pull qwen3:4b.
  2. Run python server.py and open http://127.0.0.1:8787.
  3. Open Model & settings, refresh, and choose the downloaded model.
  4. Begin a story, watch the prose stream in, and keep or export it.
  5. Disconnect from the internet after setup and repeat the writing flow.

Three labeled illustrative samples let someone explore the archive before installing a model. They are sample content, not evidence of live model inference.

Code

View the source on GitHub: antonluckshman/ghost-archive

The app is MIT-licensed. It contains a Python standard-library server, plain HTML/CSS/JavaScript, original SVG artwork and tests. There is no frontend build step, Python package installation or external asset dependency.

How I Built It

The writing engine is Qwen3-4B, an Apache 2.0 open-weight model, served by the MIT-licensed Ollama runtime. Other locally downloaded chat models can be selected in settings.

The browser posts fragments to a loopback Python server. The server checks the input and verifies the model is in Ollama's local model list, excluding models marked as remote or cloud. It sends the source material with the appropriate fiction or remembrance system prompt to Ollama's chat endpoint.

The response is streamed back as newline-delimited JSON. If the stream fails, the reader keeps the words that arrived as an unfinished draft. A successful completion saves the prose in browser storage. The source fragments are not saved to the server.

flowchart LR
    A[Browser editor] --> B[Python on loopback]
    B --> C[Ollama]
    C --> D[Local open-weight model]
    C -->|Streamed prose| B
    B --> A
    A --> E[Local browser archive]
    A --> F[Text or JSON export]

A simple bridge was enough for this task. Damiano's dependency-free Python/Ollama article helped ground that choice. Nazar Boyko's discussion of local inference informed the explicit context budget and attention to local-model memory and latency.

Validation so far: 13 Python HTTP contract tests and 8 frontend behavior checks pass. They cover streaming, partial output, Unicode, invalid requests, remote-model filtering, storage failures and backup validation. Browser review covered category filters, sample provenance, saving, favorites, persistence across reload, search empty states, the remembrance editor and a mobile layout with no horizontal overflow. These checks used a simulated Ollama service; actual model inference was not tested on the build machine.

Why Does Open Innovation Matter?

A memory should not require an account on a service that may disappear.

Open weights let the writing engine live alongside the archive. Once the runtime and model are downloaded, a session does not depend on an internet connection. The app sends no memories to a hosted model provider.

The prompts are editable Python source. The model can be replaced. If another model writes better in a family's language, the app does not need to be rebuilt around a new provider. The archive can leave the app too, as plain text or JSON.

There is no per-request AI service fee. Local hardware, disk space and electricity still have costs, and a small CPU model will not match the speed or quality of every hosted model. This project chooses local control because its material can be personal, and the task is narrow enough for a small model.

The Spirit of It

The visual design leaves room for both a shiver and a memory: lavender shadows, candlelight, a small floating ghost, and a book that remains open.

The idea is simple: let a spooky story be fiction, and let a remembrance belong to the person who brings it.

AI Assistance

AI assistance was used to implement this application, create illustrative sample prose and draft this write-up. The included sample stories are illustrative examples.

來源:DEV Community · dev.to