Skip to content

About

EpidBot chat client for MicroPythonOS

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

EpidBot_MPOS

Tests License: MIT MicroPython Platform Version

Chat client for EpidBot running on MicroPythonOS. Gives EpidBot users with an API key a mobile chat interface with voice support: replies can be spoken aloud (TTS) and, on devices with a microphone, messages can be dictated (STT) or transcribed from a WAV file.

EpidBot in the MicroPythonOS launcher
EpidBot in the MicroPythonOS launcher
Chatting with EpidBot
Chatting with EpidBot (TTS button on the right)
com_kwarai_epidbot/          the MicroPythonOS app (install this folder)
├── MANIFEST.JSON            app manifest (launcher activity)
├── icon_64x64.png
├── epidbot.py               chat Activity: LVGL UI, lifecycle, settings, voice flows
├── api.py                   EpidBot REST client (async, aiohttp) + markdown stripper
└── voice.py                 AudioManager record/playback helpers
tools/
├── make_icon.py             regenerates the icon (stdlib only)
├── install_desktop.sh       copies the app into a MicroPythonOS checkout
└── install_device.sh        copies the app to an ESP32 via mpremote
tests/test_logic.py          CPython unit tests for the pure logic (api.py)

Features

  • Chat with EpidBot via POST /api/v1/chat + GET /api/v1/chat/{job_id} polling (2 s interval, 3 min cap, cancellable), authenticated with your API key (X-API-Key header).
  • Conversation continuity via EpidBot session_id; "New chat" (⟳) starts fresh.
  • Markdown stripped for on-screen display (images dropped, links unwrapped, tables flattened).
  • TTS: completed replies are read aloud via POST /api/v1/voice/tts (format=wav, the only format MicroPythonOS AudioManager can decode), length-capped (default 800 chars, configurable 200–2000).
  • STT: on mic-equipped devices the 🎙 button records up to 15 s (16 kHz WAV) and transcribes via POST /api/v1/voice/transcribe; on devices without a mic the same button opens a WAV file picker instead.
  • Errors surfaced inline: invalid key (401/403), daily quota (429), network and timeout failures.
  • First-run setup prompts for API key and server URL; everything persists in MicroPythonOS SharedPreferences (per-app), including the last ~20 messages.
  • Browser provisioning: API keys are ~67 characters — impractical on a touchscreen. First run (or a long-press on the gear) opens "Browser setup": the app serves a setup form over HTTP on port 8126 and shows the URL, a QR code and a 4-digit PIN on screen. Open the URL on any phone/computer on the same network, paste the key, enter the PIN, and the device picks it up and validates it. The server auto-closes after 5 minutes or when stopped.
  • Settings (⚙): API key, server URL, language (en/pt/es, sent to the API), TTS voice, TTS max chars, TTS on/off.

Installation

Desktop (Linux/macOS, recommended for development)

git clone https://github.com/MicroPythonOS/MicroPythonOS.git ../MicroPythonOS
# build/run MicroPythonOS on desktop per its docs (scripts/build_mpos.sh linux)
tools/install_desktop.sh          # or: tools/install_desktop.sh /path/to/MicroPythonOS

Then start "EpidBot" from the launcher, or in the REPL:

from mpos import AppManager
AppManager.start_app('com_kwarai_epidbot')

ESP32 device

Flash MicroPythonOS for your board (web installer at install.micropythonos.com, or build + esptool), connect USB, then:

tools/install_device.sh

Note on the Waveshare ESP32-S3-Touch-LCD-1.54: supported as of MicroPythonOS PR #310 — build MicroPythonOS from that branch (or any later release) before installing this app. Validated on hardware: ST7789 display, CST816S touch, TTS speaker output and STT microphone input (ES8311/ES7210), battery gauge and power button.

Power button behavior: hold ~2 s to enter standby (the charger IC then cuts the battery after ~30 s of standby, so the device truly powers off); press to wake/boot — if a long standby let the charger IC power down completely, plug USB briefly to wake it. The ⏻ button in the launcher drawer does the same as holding PWR.

Getting an API key

Keys look like ek_... (64 hex chars). Create one with your EpidBot account:

curl -X POST https://api.epidbot.kwar-ai.com.br/api/v1/auth/login \
  -H "Content-Type: application/json" -d '{"email":"...","password":"..."}'
curl -X POST https://api.epidbot.kwar-ai.com.br/api/v1/auth/api-keys \
  -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" \
  -d '{"name":"micropythonos"}'

API access must be enabled for your account (daily token quotas apply; the app shows quota errors as chat bubbles).

Development

python3 tests/test_logic.py     # pure-logic tests, no device needed
python3 tools/make_icon.py      # regenerate the icon

The app targets MicroPython 1.20+ with the MicroPythonOS frameworks (mpos, LVGL 9 bindings). api.py is deliberately mpos-free so it can be unit-tested on CPython; HTTP goes through the MicroPythonOS-bundled async aiohttp, so all network activity yields to the UI loop (no worker threads).

Local MicroPythonOS build notes (Ubuntu 26.04 / GCC 15)

The desktop build required these small local patches to the MicroPythonOS checkout (kept out of this repo; upstreamable):

  • scripts/build_mpos.sh: added -DSDL_PIPEWIRE=OFF -DSDL_CAMERA=OFF to SDL_FLAGS (PipeWire headers too new; SDL camera pulls libv4l2)
  • lvgl_micropython/builder/unix.py: dropped Clang-only -Wno-unused-command-line-argument, added -Wno-error=unterminated-string-initialization (GCC 15 + secp256k1)
  • secp256k1-embedded-ecdh/micropython.mk: dropped Clang-only -Wno-bitwise-instead-of-logical
  • lvgl_micropython/ext_mod/c_mpos/micropython.mk: webcam module (needs static libv4l2.a, not shipped by Ubuntu) now optional

Roadmap

  • WebSocket streaming (/api/v1/chat/stream) for token-by-token replies
  • Server-driven voice list (from GET /api/v1/voice/status)
  • Conversation history picker (EpidBot sessions API)

License

See LICENSE.

About

EpidBot chat client for MicroPythonOS

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages