THX-02 / mobile /README.md
doofz's picture
Add the thx02 PyPI package: API client, CLI (Termux, tmux), lazy local runtime
8262da0 verified
|
Raw History Blame Contribute Delete
2.26 kB

THX-02 on a phone

Two ways to use THX-02 from Android (Termux) or any terminal.

Mode What runs on the phone Needs Speed
API (recommended) pip install thx02: the thx02 command and Python client, no dependencies Python, an API key network round trip plus about 80 ms on the server
Local the full model on the CPU aarch64, 12 GB+ RAM, about 9 GB storage about 0.6 s per short request on an 8-core x86 CPU in BF16; phone CPUs are slower

API mode (recommended)

pkg install -y python tmux
pip install thx02
export HALX_API_KEY=sk-...
thx02 "I was charged twice, please refund" \
    --choice "team=billing:charges and refunds,support:technical problems,sales:buying a product" \
    --yesno "Does the customer ask for a refund?"

Interactive session: run thx02 without a state and type messages. Keep it running in tmux (tmux new -s thx, detach with Ctrl-b d, come back with tmux attach -t thx). --think auto or --think on --thoughts lets the model reason first, --image photo.jpg includes a photo, --json prints raw output, --server http://HOST:8200 uses your own thx02 serve instead of api.hal-x.ai. bash install_termux.sh does all of this in one step. thx.py in this folder is the same client as a single file for phones without pip.

Local mode (experimental)

bash install_termux.sh --local

Then thx02 --local HAL-X-AI/THX-02 "..." inside the Ubuntu userland (the script prints the exact command).

The script installs an Ubuntu userland with proot-distro (PyPI ships aarch64 wheels for torch and the tokenizers), downloads nothing large by itself, and prints the two commands to fetch the model and run it. Local mode answers directly (no thinking; the thinker needs a GPU server) and reads images too.

Environment variables for local mode:

Variable Default Meaning
THX02_CPU_DTYPE bfloat16 (set by thx.py) float32 is more exact and needs about 18 GB RAM
THX02_THREADS all cores CPU threads

Measured on a server CPU (8 threads, BF16): 0.6 to 0.7 s per short request, 7.6 GB peak memory. Local mode has not been timed on a phone yet; expect several seconds per request on current flagship phones.