ChatHaikuCLI includes two Python clients:

  • chathaiku.py — the simple public chat client for everyday terminal use.
  • chathaiku_dev.py — the developer client with endpoint switching, sampling controls, health checks, retry/undo tools, latency output, and local preference-data collection.

Both clients use Python’s standard library only. No package installation is required beyond Python itself.


Table of contents


Overview

ChatHaikuCLI lets you talk to a RootComputer model from your terminal.

The default endpoint is:

https://chathaiku.com/api/haiku.php

That means a new user can usually run:

python chathaiku.py

and start chatting immediately, as long as the public endpoint is online.

The developer version is intended for model testing, prompt evaluation, preference collection, and local/self-hosted endpoint development:

python chathaiku_dev.py

Repository files

File Purpose
chathaiku.py Public CLI client. Minimal, friendly interface for chatting with the default public Haiku endpoint or a custom endpoint.
chathaiku_dev.py Developer CLI client. Adds sampling controls, endpoint hot-swapping, health checks, retry/undo, latency stats, and JSONL feedback collection.

If your files downloaded as chathaiku(1).py and chathaiku_dev(1).py, rename them before publishing the repo:

mv "chathaiku(1).py" chathaiku.py
mv "chathaiku_dev(1).py" chathaiku_dev.py

On Windows Command Prompt:

rename chathaiku(1).py chathaiku.py
rename chathaiku_dev(1).py chathaiku_dev.py

Requirements

ChatHaikuCLI is intentionally dependency-free.

You need:

  • Python 3.8 or newer
  • An internet connection when using the public endpoint
  • A reachable RootComputer-compatible server when using a custom endpoint

No pip install step is required.

The clients use only Python standard-library modules:

  • argparse
  • json
  • os
  • sys
  • time
  • urllib
  • typing

Quick start

Clone the repo or download the two Python files, then run:

python chathaiku.py

You should see the ChatHaiku banner and a connection check. Once the client is ready, type a message:

you: Hello, what can you do?
haiku: ...

Exit with:

/quit

or press Ctrl-C.


Installing Python

If python is not recognized, install Python from the official Python website and make sure Add Python to PATH is enabled during installation.

After installation, verify Python works:

python --version

On some systems, the command may be:

python3 --version

If your system uses python3, replace python with python3 in all examples.


Running the public client

The public client is the normal user-facing CLI.

python chathaiku.py

Run with a custom server or endpoint:

python chathaiku.py --server https://chathaiku.com/api/haiku.php

Disable terminal colors:

python chathaiku.py --no-color

You can also disable colors with the NO_COLOR environment variable:

NO_COLOR=1 python chathaiku.py

Windows PowerShell:

$env:NO_COLOR=1
python chathaiku.py

Public client startup behavior

When the public client starts, it:

  1. normalizes the configured server URL,
  2. prints the banner,
  3. checks whether the endpoint is reachable when a health route is available,
  4. starts an interactive chat loop.

For public PHP proxy endpoints, there may be no health endpoint. In that case, the client treats the endpoint as configured and lets the first chat request report any real error.


Running the developer client

The developer client has advanced tools for testing and data collection.

python chathaiku_dev.py

Run against the public endpoint:

python chathaiku_dev.py --server https://chathaiku.com/api/haiku.php

Run against a local server:

python chathaiku_dev.py --server http://localhost:8000

Run against a direct chat route:

python chathaiku_dev.py --server http://localhost:8000/api/chat

Write collected preference data to custom files:

python chathaiku_dev.py \
  --dpo-out data/my_dpo_pairs.jsonl \
  --sft-positive-out data/my_sft_positive.jsonl

Disable colors:

python chathaiku_dev.py --no-color

Choosing a server or endpoint

Both clients accept --server.

The value can be:

  1. a full public PHP proxy endpoint,
  2. a direct /api/chat endpoint,
  3. a base server URL,
  4. a pasted /api/health URL, or
  5. a relative /api/... path for the public ChatHaiku site.

Examples:

python chathaiku.py --server https://chathaiku.com/api/haiku.php
python chathaiku.py --server http://localhost:8000
python chathaiku.py --server http://localhost:8000/api/chat
python chathaiku.py --server http://localhost:8000/api/health
python chathaiku.py --server /api/haiku.php

If you provide a server without a URL scheme, the client adds one automatically:

  • local/private hosts use http://
  • public hosts use https://

Example:

python chathaiku.py --server localhost:8000

is treated as:

http://localhost:8000

Supported endpoint formats

Public PHP proxy endpoint

https://chathaiku.com/api/haiku.php

Used directly as the chat URL.

Health check:

none

Public PHP proxy endpoints do not expose /api/health.


Server base URL

http://localhost:8000

Resolved to:

chat:   http://localhost:8000/api/chat
health: http://localhost:8000/api/health

Direct chat URL

http://localhost:8000/api/chat

Used directly as the chat URL.

The health route is inferred as:

http://localhost:8000/api/health

Health URL

http://localhost:8000/api/health

Resolved back to the server base:

http://localhost:8000

and chat requests are sent to:

http://localhost:8000/api/chat

Public client commands

The public client supports a small command set:

Command Description
/clear Clear the current conversation history.
/save FILE Save the conversation transcript to a text file.
/help Show command help.
/quit Exit the client.
/exit Exit alias.
/q Exit alias.
/bye Exit alias.

Example:

you: /save conversation.txt

Developer client commands

The developer client supports all common chat controls plus model-testing tools.

Conversation commands

Command Description
/clear Reset conversation history.
/history Show the current conversation transcript.
/save FILE Save the transcript to a file.
/retry Drop the last bot reply and re-ask the last user message.
/undo Drop the last exchange.
/help Show the full command list.
/quit Exit the client.
/exit Exit alias.
/q Exit alias.

Server commands

Command Description
/endpoint URL Switch to a new endpoint without restarting the client.
/ping Check endpoint health or reachability.
/info Show the last known endpoint information.

Sampling commands

Command Description
/temp F Set temperature.
/top-p F Set nucleus sampling value.
/top-k N Set top-k sampling value. 0 disables top-k.
/max-new N Set maximum generated tokens per reply.
/rep-penalty F Set repetition penalty.
/no-repeat-ngram N Block repeated n-grams of size N. 0 disables this.
/params Show the current sampling parameters.

Feedback collection commands

Command Description
/good Save the last bot reply as a positive SFT example.
/bad Mark the last bot reply as bad, enter a corrected answer, and save a DPO pair.
/rewrite Rewrite the last bot reply and save a DPO pair.
/stats Show collected JSONL counts for this session and on disk.
/dpo-stats Alias for /stats.

Sampling controls

The public client sends a fixed sampling payload with each request:

{
  "temperature": 0.85,
  "top_p": 0.92,
  "max_new_tokens": 200
}

The developer client sends configurable sampling values with each request.

Current developer defaults are:

{
  "temperature": 0.35,
  "top_p": 0.37,
  "top_k": 0,
  "max_new_tokens": 80,
  "repetition_penalty": 1.15,
  "no_repeat_ngram": 4
}

To inspect the current values during a developer session:

/params

To change values:

/temp 0.7
/top-p 0.9
/top-k 40
/max-new 200
/rep-penalty 1.15
/no-repeat-ngram 4

Note: the developer script’s built-in /help text may mention older sampling defaults for temperature, top-p, and max tokens. The actual defaults are the values initialized in the SamplingParams class.


Saving conversations

Public client transcript format

The public client saves transcripts like this:

You: Hello.

Haiku: Hello. How can I help?

Use:

/save chat.txt

Developer client transcript format

The developer client saves numbered transcripts like this:

[1] you: Hello.
[2] haiku: Hello. How can I help?

Use:

/save dev-chat.txt

Collecting SFT and DPO data

The developer client can collect local JSONL data while you evaluate the model.

By default, it writes:

data/dpo_pairs.jsonl
data/sft_positive.jsonl

The data/ folder is created automatically when needed.

Positive SFT examples with /good

After a good model reply:

/good

The client appends one JSON object to data/sft_positive.jsonl:

{
  "prompt": "User message that caused the reply",
  "chosen": "The model reply marked as good",
  "history": [],
  "server": "https://chathaiku.com/api/haiku.php",
  "model": "Haiku public PHP proxy",
  "ts": "2026-01-01T12:00:00"
}

DPO pairs with /bad

After a bad model reply:

/bad

The client asks what the reply should have been. Enter the corrected reply, then finish with:

/end

Cancel with:

/cancel

The client appends one JSON object to data/dpo_pairs.jsonl:

{
  "prompt": "User message that caused the reply",
  "chosen": "Your corrected reply",
  "rejected": "The model's original bad reply",
  "history": [],
  "source": "bad",
  "server": "https://chathaiku.com/api/haiku.php",
  "model": "Haiku public PHP proxy",
  "ts": "2026-01-01T12:00:00"
}

DPO pairs with /rewrite

Use /rewrite when the model answer is not necessarily bad, but you want to provide a better preferred answer.

/rewrite

The saved JSONL object uses:

"source": "rewrite"

Checking collection stats

/stats

shows:

  • DPO pair file path
  • DPO records on disk
  • DPO records collected this session
  • SFT-positive file path
  • SFT-positive records on disk
  • SFT-positive records collected this session

Expected server API

ChatHaikuCLI expects a RootComputer-compatible HTTP API.

Chat route

The chat route accepts POST requests with JSON.

For a server base URL, the route should be:

/api/chat

Example request:

{
  "history": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "temperature": 0.85,
  "top_p": 0.92,
  "max_new_tokens": 200
}

The developer client may also send:

{
  "top_k": 0,
  "repetition_penalty": 1.15,
  "no_repeat_ngram": 4
}

The expected response is JSON with a string reply field:

{
  "reply": "Hello. How can I help?"
}

If the response contains an error field and no usable reply, the developer client reports it as a server error.

Health route

For self-hosted servers, the optional health route is:

/api/health

Expected response:

{
  "model": "Haiku",
  "params": 217000000,
  "device": "cuda"
}

The clients can still use a direct PHP proxy or direct chat route without a health route.


Color output

Both clients use ANSI colors by default.

Disable colors with:

python chathaiku.py --no-color
python chathaiku_dev.py --no-color

or with:

NO_COLOR=1 python chathaiku.py

On Windows, modern terminals such as Windows Terminal and recent PowerShell versions generally support ANSI colors. Older terminals may show raw escape codes. Use --no-color if that happens.


Troubleshooting

python is not recognized

Python is not installed or is not on PATH.

Try:

python3 --version

If that works, run:

python3 chathaiku.py

Otherwise, reinstall Python and enable Add Python to PATH.


The client says the server is offline

Check that:

  • the endpoint is typed correctly,
  • your internet connection is working,
  • the public endpoint is currently online,
  • your local server is actually running if using localhost,
  • the server exposes /api/chat if using a base URL.

Try the developer client:

python chathaiku_dev.py --server YOUR_ENDPOINT

Then run:

/ping

Public endpoint has no health route

This is expected for PHP proxy endpoints such as:

https://chathaiku.com/api/haiku.php

The client will say no health endpoint is exposed and will test the endpoint on the first chat request.


HTTP 412 from the public PHP endpoint

Some shared-host or WAF setups can block Python-origin POST requests to a public PHP proxy. The clients include a backend fallback for this case. If both the public endpoint and fallback fail, the client prints the fallback error.


Server returns JSON decode error

The endpoint did not return valid JSON. Common causes:

  • the URL points to an HTML page instead of /api/chat,
  • the server crashed and returned an error page,
  • a proxy or firewall injected an HTML response,
  • the server route is not RootComputer-compatible.

Server returned an empty reply

The server responded, but the reply field was missing or empty.

Check the server logs and confirm that the response format is:

{
  "reply": "text here"
}

Conversation history gets too long

The public client sends the full in-memory conversation history.

The developer client sends only the most recent 10 turns to match the public frontend behavior.

Use:

/clear

to reset the session.


Colors look broken

Run with:

python chathaiku.py --no-color

or:

python chathaiku_dev.py --no-color

Security notes

ChatHaikuCLI sends your conversation text to the configured server endpoint.

When using the public endpoint, do not send secrets, passwords, private keys, or sensitive personal data. When using a self-hosted endpoint, review your own server logging and retention behavior.

The developer client writes feedback data locally to JSONL files. Review those files before sharing them or using them for model training.