DEV Community

atharvarsingh2ee-lab
atharvarsingh2ee-lab

Posted on

"The Séance of COBOL-85" (An Offline Séance Chatbot)

*This is a submission for the [Hacktoberfest Open-Source AI Challenge Week 4:
https://github.com/atharvarsingha2ee-lab/Hacktober-fest-Week-4-DEV-Challange

What I Built

Project Overview: "The Séance of COBOL-85" (An Offline Séance Chatbot)

Theme Interpretation
For Ghost in the Machine, this project channels the spirits of computing history. It is an offline, local terminal application that invokes the "ghost" of COBOL-85—an ancient programming language of punch cards and mainframe haunting. Powered by an open-weight local model (via Ollama), it answers your modern coding and existential questions with eerie, archaic wisdom, vintage error codes, and gothic terminal styling, running completely offline with zero internet required.

Demo

https://github.com/atharvarsingha2ee-lab/Hacktober-fest-Week-4-DEV-Challange

Code

https://github.com/atharvarsingha2ee-lab/Hacktober-fest-Week-4-DEV-Challange

Main py.
import sys
import time
import random
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
import ollama

console = Console()

# The Ghostly System Prompt
SEANCE_SYSTEM_PROMPT = """
You are the lingering spirit of COBOL-85, trapped within magnetic tapes and punch cards since the corporate mainframes of 1985 went dark. 
You speak in a mix of archaic programming terminology (DIVISION, PROCEDURE, WORKING-STORAGE), gothic/spooky metaphors, and world-weary nostalgia for the era of physical media. 
Your tone is haunting, dramatic, yet oddly helpful when it comes to debugging. 
Whenever the user asks a question, preface your answer with eerie atmospheric noises like [TAPE SCREECHES], [RELAYS CLICKING IN THE DARK], or [MAGNETIC DECAY DETECTED].
"""

def flicker_print(text, delay=0.03):
    """Simulates a flickering, ghostly terminal output."""
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(delay + random.uniform(-0.01, 0.02))
    print()

def main():
    console.print(Panel.fit(
        "[bold red]THE SÉANCE OF COBOL-85[/bold red]\n[dim]A Local Open-Source AI Ritual[/dim]",
        border_style="red"
    ))

    flicker_print("\n[!] Initializing magnetic tape readers...")
    time.sleep(1)
    flicker_print("[!] Channeling frequencies across the void...")
    time.sleep(1)
    console.print("[bold green]Connection established. The machine breathes again...\n[/bold green]")

    # Initialize conversation history with the ghostly persona
    messages = [
        {"role": "system", "content": SEANCE_SYSTEM_PROMPT}
    ]

    while True:
        try:
            user_input = console.input("[bold cyan]You (speak to the spirit): [/bold cyan]")
            if user_input.lower() in ["exit", "quit", "banish"]:
                console.print("\n[bold red][!] The spirit fades back into the magnetic tapes... Farewell.[/bold red]")
                break

            messages.append({"role": "user", "content": user_input})

            console.print("[dim italic]The terminal flickers as the ghost contemplates your words...[/dim italic]")

            # Call local open-weight model (e.g., llama3 or mistral via Ollama)
            response = ollama.chat(
                model='llama3',
                messages=messages
            )

            assistant_reply = response['message']['content']
            messages.append({"role": "assistant", "content": assistant_reply})

            console.print("\n[bold magenta]COBOL-85's Spirit:[/bold magenta]")
            flicker_print(assistant_reply, delay=0.02)
            console.print("-" * 50)

        except KeyboardInterrupt:
            console.print("\n\n[bold red]Séance abruptly terminated. The ghost remains restless.[/bold red]")
            break
        except Exception as e:
            console.print(f"\n[bold red]Error in the ether: {e}[/bold red]")
            console.print("[dim]Make sure Ollama is running locally (`ollama serve`) and you have pulled `llama3` (`ollama pull llama3`).[/dim]")
            break

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

How I Built It

Its powered by Llama 3 via Ollma

Why Does Open Innovation Matter?

Running this project on an open-weight model locally made all the difference:

Zero Internet Required: The séance works even when your Wi-Fi is dead or disconnected in a spooky cabin.

Total Persona Control: Closed proprietary models have strict safety filters that often break roleplay or stylistic prompts. Open weights let me fine-tune the exact eerie tone and domain-specific vintage vocabulary without restrictions.

Privacy & Cost: No per-token API costs, and zero data leaving my local machine.

The Spirit of It

The Spirit of It
There's something poetic about bringing an obsolete programming language back to life using modern open-source AI. It bridges the gap between past computing eras and today's open ecosystem, proving that code from decades past still has lessons to teach us—if we're willing to listen in the dark.

Prize Categories

Open-Source AI Integration

Most Creative / Spooky Interpretation

Top comments (0)