Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

14 Commits

Folders and files

Repository files navigation

πŸ€– JARVIS β€” Real-Time AI Assistant

A voice + chat personal assistant in Python that talks with you and runs real automations on your machine. Powered by Google Gemini via a single API key, with proper tool-calling so the AI decides when to open apps, search the web, take notes, check the weather, control your system, and more.

You β–Έ jarvis, what's the weather in Visakhapatnam and open youtube
  βš™ running get_weather(city='Visakhapatnam')
  βš™ running play_youtube(query='...')
JARVIS β–Έ It's 31Β°C and sunny in Visakhapatnam. YouTube is open for you.

✨ Features

  • Real-time chat β€” natural conversation with memory that persists between sessions.
  • Voice in & out β€” speak to it (mic β†’ speech-to-text) and it replies aloud (TTS). Falls back to text automatically if no mic/speakers.
  • Tool-calling automations β€” the model calls real Python functions:
    Category Tools
    System open_app, run_command, set_volume, take_screenshot, system_info
    Web open_website, web_search, play_youtube, get_weather, wikipedia
    Files write_file, read_file, append_file, list_files (sandboxed)
    Utility get_datetime, add_note, read_notes, set_reminder, calculate
  • Model-agnostic β€” swap models in .env (GPT-4o-mini, Gemini Flash, Llama 3.3, Grok…).
  • Extensible β€” add a new automation in ~10 lines with one decorator.

πŸ“ Project structure

Jarvis/
β”œβ”€β”€ main.py                 # entry point β†’ python main.py
β”œβ”€β”€ config.py               # loads .env settings
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example            # copy to .env and add your key
└── jarvis/
    β”œβ”€β”€ assistant.py        # interactive loop (UI, input mode, commands)
    β”œβ”€β”€ brain.py            # Gemini client + tool-calling loop
    β”œβ”€β”€ voice.py            # speech-to-text + text-to-speech (optional)
    β”œβ”€β”€ memory.py           # rolling conversation memory + disk persistence
    └── automations/
        β”œβ”€β”€ registry.py     # @tool decorator + dispatch
        β”œβ”€β”€ system.py       # open apps, volume, screenshots, shell
        β”œβ”€β”€ web.py          # search, weather, wikipedia, youtube
        β”œβ”€β”€ files.py        # sandboxed file ops
        └── utils.py        # time, notes, reminders, math

πŸ–₯️ Two ways to use it

1. Web HUD (the interface) β€” animated Iron Man HUD in your browser, with live clock, weather, and system/mobile indicators. This is JARVIS's single front-end:

pip install -r requirements.txt
python main.py            # boots the HUD and opens http://127.0.0.1:5000
# python main.py --no-browser   # HUD without auto-opening the browser

python server.py runs the exact same thing. Set an access PIN in Settings to reach it from your phone over the same Wi-Fi (a QR code is shown for quick pairing).

2. Terminal (CLI) β€” classic voice/text loop in the console, kept as a fallback:

python main.py --cli

πŸ†• What's inside (v2)

  • Streaming replies β€” text appears token-by-token as the model thinks (SSE).
  • Barge-in β€” tap πŸŽ™ (or press Esc) to cut JARVIS off mid-sentence and speak.
  • Multi-language β€” English / Hindi / Telugu for both understanding and spoken replies.
  • Personas β€” JARVIS (formal), FRIDAY (casual), COACH (study coach) β€” switch in Settings.
  • Long-term memory β€” "remember my sister's birthday is 4 March" persists across sessions (~/.jarvis/facts.json), and is fed back into every conversation.
  • Vision β€” drag-drop, paste, or πŸ–Ό attach an image; JARVIS describes/acts on it (free vision model first, paid fallback). Great for your photography work.
  • RAG over your files β€” "summarize my notes", "find X in my resume" scans your workspace/Documents/Desktop/Downloads.
  • Media & power β€” play/pause, next/prev, brightness, lock, sleep.
  • Win+S launcher β€” "open chrome / vscode / settings" runs the Win+S β†’ type β†’ Enter flow you asked for. Plus quick tabs (Internshala, Instagram, GitHub…).
  • System watchdog β€” pops toast alerts for low battery / high CPU / full RAM (i3-friendly).
  • Themes β€” Arc (cyan), Mark III (gold-red), Ultron (red), Stealth (mono).
  • Command palette β€” Ctrl+K for quick actions.
  • Draggable panels, chat export (Markdown), model fallback (auto-switch on error).
  • Mobile control β€” set an access PIN, open the shown LAN URL on your phone (same Wi-Fi).
  • Telegram bot β€” control the laptop from anywhere via Telegram, with full AI chat, quick-action menu, approval flow for destructive tools, and proactive watchdog alerts.
  • Single-AI brain β€” Gemini drives every tool call (screenshot, open_app, run_command…). Streamed tokens are the final reply β€” no second pass. Falls back across smaller Gemini models automatically on rate-limit, and rotates to a backup key when the primary is exhausted.
  • Personal identity baked in β€” JARVIS starts every session already knowing who you are (name, education, projects, socials, contact). See jarvis/owner.py.
  • Files anywhere β€” write, append, copy, move, rename, mkdir, list, read on any path the OS lets you touch. Delete still requires approval.
  • Create anything β€” Markdown, HTML, CSV, JSON, YAML, XML, TXT, code files (Python, JS, TS, Go, Rust, Java, C++, …), PDF, DOCX, XLSX, PPTX (all from Markdown-lite), and images generated from a text prompt via Gemini 2.5 Flash Image.
  • Run code β€” run_python (approval-gated) executes a Python snippet in a 10s sandbox, returns stdout/stderr.

🎨 The web HUD

python main.py opens the HUD at http://127.0.0.1:5000 (and auto-launches your browser).

  • Arc reactor β€” a live canvas animation that spins faster and glows brighter while JARVIS is thinking or speaking.
  • Boot sequence, animated ring gauges (CPU / RAM), and a status cluster (ONLINE / MODEL / TOOLS).
  • Live indicators β€” clock + date, current weather, and battery / network / CPU / RAM pills, visible on desktop and mobile layouts.
  • Round icon buttons β€” settings, command palette, QR pairing, contacts, session memory, mic, vision, and send, rendered as crisp inline SVG icons (no emoji, fully theme-colored).
  • Settings modal β€” paste API key (saved to .env), pick a model/persona/language/theme, set a mobile PIN, toggle voice.
  • Voice β€” the mic button uses your browser's speech recognition; replies are spoken via speech synthesis. No pyaudio needed for the web UI.
  • Approval flow β€” destructive tools (shutdown, delete, send_whatsapp) trigger an approval card.
  • Tool calls show as glowing chips under each reply so you can see what JARVIS actually did.
  • Telegram β€” the same brain and memory are reachable from your phone via the Telegram bot.

πŸš€ Setup (CLI voice extras)

1. Install dependencies

pip install -r requirements.txt

Microphone (optional, for voice input). pyaudio needs system audio libs:

  • Windows: pip install pyaudio (or pip install pipwin && pipwin install pyaudio)
  • macOS: brew install portaudio && pip install pyaudio
  • Linux: sudo apt install portaudio19-dev && pip install pyaudio

Skip this if you only want to type β€” set JARVIS_STT=0 in .env.

2. Add your Gemini key

cp .env.example .env      # Windows: copy .env.example .env

Then edit .env and paste your key from https://aistudio.google.com/apikey. You can also add a second key as JARVIS_GEMINI_KEY_BACKUP for automatic rotation when the primary key hits its rate limit.

3. Run

python main.py

βš™οΈ Configuration (.env)

Variable Default Meaning
JARVIS_GEMINI_KEY β€” Required. Your Gemini API key.
JARVIS_GEMINI_KEY_BACKUP β€” Optional. Used automatically when the primary is rate-limited.
JARVIS_MODEL gemini-2.0-flash Any Gemini model id (e.g. gemini-2.0-flash, gemini-2.5-flash).
JARVIS_VOICE 1 1 = speak replies aloud, 0 = text only.
JARVIS_STT 1 1 = listen via mic, 0 = type input.
JARVIS_NAME JARVIS Assistant name/personality.
JARVIS_WAKE_WORD jarvis Optional wake word.

In-session commands: exit, reset (clear memory), text / voice (switch input mode).


πŸ€– Telegram bot (control the laptop from anywhere)

Run JARVIS on your PC and DM it from any phone on any network β€” same AI brain, same automations, with an inline keyboard and proactive alerts.

1. Create the bot

  1. Open Telegram, message @BotFather.
  2. Send /newbot, follow the prompts, copy the token.

2. Configure JARVIS

Edit .env (set JARVIS_PIN first if you haven't β€” Telegram reuses it):

JARVIS_PIN=5252
JARVIS_TELEGRAM_ENABLED=1
JARVIS_TELEGRAM_TOKEN=123456:ABC-DEF...

Install the dependency and restart:

pip install -r requirements.txt   # adds python-telegram-bot
python server.py

You should see [telegram] bot started in the startup output.

3. Link your chat

  1. Open your bot in Telegram.
  2. Send /start β€” it'll ask for the PIN.
  3. Send /start 5252 (or whatever your PIN is). The PIN message is deleted for safety. You now see the main menu.

Features

  • Quick-action menu β€” πŸ“Έ Screenshot Β· πŸ–₯ System Β· πŸ”‹ Battery Β· πŸ’» CPU/RAM Β· 🌐 Open URL Β· πŸ“‚ Files Β· πŸ”Š Volume Β· πŸͺŸ Windows Β· ⏻ Shutdown Β· πŸ”„ Restart.
  • Commands β€” /me, /myprojects, /screenshot, /battery, /windows, /volume 50, /open chrome, /cancel_shutdown, /reset, /help.
  • File ops β€” /file write <path> (then attach a file), /file write_text <path> <content>, /file append <path>, /file mkdir <path>, /file list [path], /file read <path>, /file delete <path> (asks for approval). Files work anywhere your OS user can write.
  • Free chat β€” any non-command text is sent to JARVIS's brain, so you can ask "open YouTube and search lo-fi" or "summarize my notes".
  • Screenshots come back as photos β€” the bot detects Screenshot saved to … and sends the file.
  • Approval flow β€” destructive tools (shutdown, restart, delete file) show a βœ… / ❌ inline keyboard. Approve from anywhere.
  • Proactive alerts β€” low battery / high CPU / full RAM alerts get DMed automatically (forwarded from the same watchdog the web UI uses).
  • Shared memory β€” Telegram conversation and web/CLI share the same Memory, so context carries between devices.
  • Single-AI replies β€” Gemini handles both the tool-calling and the final wording. Falls back across smaller Gemini models automatically.
  • Multi-user β€” multiple Telegram accounts can be linked (each sends /start <PIN>). Revoke by deleting ~/.jarvis/telegram_authorized.json.

Disable

Set JARVIS_TELEGRAM_ENABLED=0 in .env and restart. The Flask server keeps running normally.


🧩 Add your own automation

Drop a function in any file under jarvis/automations/ (or a new one):

from .registry import tool

@tool(
    name="lock_screen",
    description="Lock the computer screen.",
)
def lock_screen() -> str:
    import os, platform
    if platform.system() == "Windows":
        os.system("rundll32.exe user32.dll,LockWorkStation")
    return "Screen locked."

Import it in jarvis/automations/__init__.py and JARVIS can now call it β€” no other wiring needed. The model reads the description to decide when to use it.


πŸ”’ Safety notes

  • File tools are sandboxed to ~/jarvis_workspace.
  • run_command executes shell commands β€” the model is told to be cautious, but treat it like giving the AI a terminal. Remove that tool from automations/__init__.py if you want a locked-down build.
  • Your .env (API key) is git-ignored.

Built by Sampath Satya Saran Β· powered by Google Gemini.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages