DEV Community

Jarvis Wick
Jarvis Wick

Posted on

Trailhead: Walking to Remember with Gemma 3 (Ghost in the Machine)

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

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

What I Built

Trailhead is a local-first Streamlit app that turns a few taps into a short outdoor outing — and helps you carry the past with you while you go.

You pick an activity, how much time you have, and where you are. Trailhead pulls live weather and remaining daylight from Open-Meteo, then asks a locally running open-weight model — Gemma 3 4B via Ollama — for an "outing card": a plain-language route, what to look and listen for this week at your latitude, three off-screen challenges, and a one-line safety note. The card exports as a printable HTML file or a PDF. When you're ready, hit "Take me outside" for a minimal screen that just tells you when to head back. After your walk, you can save notes to a local journal.

For Week 4's theme Ghost in the Machine, I wanted Trailhead to do more than just guide you outside — I wanted it to help you remember.

I added a Remembrance Mode: before you head out, you can dedicate your walk to someone or something you want to remember. The card then weaves that intention into its suggestions — prompting you to notice the things that would have caught their eye, to sit with a memory at a quiet spot, and to reflect on stories worth carrying forward. As Día de los Muertos approaches, those small moments of remembrance feel all the more meaningful.

Demo

Code

How I Built It

The engine. The model is constrained to a JSON schema and validated with Pydantic, so the output is structured rather than prose to parse:

response = client.chat(
    model=OLLAMA_MODEL,                       # default: gemma3:4b
    messages=[{"role": "system", "content": SYSTEM_PROMPT},
              {"role": "user", "content": prompt}],
    format=OUTING_CARD_JSON_SCHEMA,           # Ollama constrains generation
    options={"temperature": 0.3},
)
data = json.loads(response.message.content)
card = OutingCard(**data)                     # Pydantic validates
Enter fullscreen mode Exit fullscreen mode

Remembrance Mode. When a remembrance name/description is provided, I inject it into the prompt so Gemma tailors the suggestions to that intention:

if remembrance:
    prompt += f"\n\nDedicate this walk in memory of: {remembrance}. "
    prompt += "Suggest gentle ways to honor their memory — notice what they might have loved, "
    prompt += "sit quietly for a moment in their honor, or reflect on a story worth keeping."
Enter fullscreen mode Exit fullscreen mode

The card still enforces the same constraints — no fake trail names, exactly three off-screen challenges, a safety note grounded in actual weather. Just a different kind of attention.

Everything else. Open-Meteo's geocoding and forecast APIs are free and keyless, so only a city name or coordinates leave the machine. Cards export as self-contained HTML (print CSS) or PDF via fpdf2. Journal entries are stored in a local SQLite database with cards serialized via model_dump_json(). No Node, no build step, no custom JavaScript.

Stack: Python 3.15, Streamlit, httpx, the official ollama client, Pydantic, fpdf2, SQLite.

Why Does Open Innovation Matter?

For a project about preserving memories, keeping them private isn't optional — it's the point:

  1. Memories stay on your machine. Your dedication, your notes in the journal, your location — none of it goes to a cloud service. The only network call is to a keyless weather API. Everything else stays local.
  2. It works when you need it. Walks happen in all kinds of places, sometimes with spotty signal. Once Gemma is pulled, Trailhead runs entirely against a local ollama serve. The past shouldn't require perfect connectivity to be honored.
  3. No one can disappear your memories. A closed API could change terms, raise prices, or shut down. With an open-weight model running locally, the tool to remember stays yours as long as your machine does.
  4. It belongs to everyone. OLLAMA_MODEL lets you swap models freely. A 4B model is enough for a quiet moment of remembrance on most laptops. The project is minimal and swappable by design.

The ghost in the machine, in this case, is just memory — and open tools are what keep it from being harvested.

My Agent Session

Prize Categories

I'm entering Best Use of Gemma — Remembrance Mode is powered by Gemma 3 4B running locally through Ollama, constrained by a JSON schema and validated with Pydantic to keep the output grounded and respectful.

Top comments (0)