seance:與已停用的程式語言進行降神會
I held a séance with dead programming languages — meet seance 👻
seance 是一款 Python CLI,可讓用戶向 COBOL、FORTRAN、BASIC 或 ALGOL 提問,並以各語言的風格獲得回答。它透過 Ollama 在本機使用 Gemma;無需帳戶或 API 金鑰,問題不會離開用戶的裝置。模型無法連線時,程式會以確定性離線備用模式回覆,並標示回覆來源。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
seance is a small Python CLI that lets you ask a question and get an
answer from the ghost of a long-dead programming language — COBOL (1959),
FORTRAN (1957), BASIC (1964), or ALGOL (1958). Each spirit answers in its
own voice: COBOL in formal ALL-CAPS divisions, FORTRAN in terse numerics
and GOTOs, BASIC in friendly numbered lines, ALGOL in precise
begin/end blocks.
It takes the Week 4 theme two ways at once: it is spooky (a séance, on
Halloween week), and it honors the past (the languages that built
computing, remembered in their own words, in the spirit of Día de los
Muertos).
Repo: https://github.com/sonawaneutkarsh/seance
Demo
Real runs, offline mode, no model needed:
$ python3 -m seance "Will my code outlive me?" --spirit cobol --offline
The spirit of COBOL (1959) speaks:
PROCEDURE DIVISION. I HAVE READ YOUR QUERY, AND I HAVE FILED IT.
Your question — "Will my code outlive me?" — echoes in the machine room.
The dead answer in formal, procedural, ALL-CAPS divisions.
END PROGRAM. I return to the mainframe now. It never sleeps.
[source: offline fallback (deterministic)]
$ python3 -m seance "Why did you disappear?" --spirit basic --offline
The spirit of BASIC (1964) speaks:
30 REM I HAVE BEEN WAITING SINCE 1984. ASK AWAY.
Your question — "Why did you disappear?" — echoes in the machine room.
The dead answer in friendly, numbered lines, eager to help.
GOTO 10. The loop closes. The loop always closes.
[source: offline fallback (deterministic)]
Code
-
seance/spirits.py— the four spirits and the deterministic fallback -
seance/ollama_client.py— minimal stdlib Ollama client -
seance/__main__.py— the CLI: summon, list spirits, offline mode -
tests/test_seance.py— 9 tests, all passing (Ollama mocked)
How I Built It
The question goes to Gemma, running locally through Ollama, prompted
to answer in the chosen spirit's voice. No accounts, no API keys, no
question leaves your machine. And because a séance should work with the
lights off, there is an honest offline fallback: when no model is
reachable, lines are picked by hashing (spirit, question), so the same
question always summons the same answer — and the reply always labels
its source, so a fallback is never passed off as AI.
Why Does Open Innovation Matter?
The whole project only works because the pieces are open. Gemma is an
open-weight model I can run on my own laptop, so communing with the past
does not mean uploading my questions to someone else's server — and the
dead languages themselves are the original open inheritance: ALGOL's
ideas live on in nearly every language used today precisely because they
were shared, not locked away. A closed model behind an API could vanish
tomorrow and take the séance with it; a local open-weight model and a
stdlib-only codebase will still answer in ten years. The past, kept
open, stays reachable.
Prize Categories
- Best Use of Gemma — Gemma (via local Ollama) powers the AI séances.
Tags: #devchallenge #hf26challenge
來源:DEV Community · dev.to