httpPostStreaming

fun httpPostStreaming(endpoint: String, jsonBody: String, onLine: (String) -> Unit, shouldStop: () -> Boolean = { false }, timeoutMs: Int, port: Int = defaultPort())

Sendet eine POST-Anfrage an den LLAMA-Server und streamt die Antwort als SSE-Zeilen.

SSE-Rahmenvertrag

Der llama.cpp-Server gibt einen minimalen SSE-Stream aus: – Jeder Block ist eine „data: {json}“-Zeile, gefolgt von einer Leerzeile.

  • Der Stream endet mit „Daten: FERTIG“.

  • Im Normalbetrieb werden keine Felder „event:“, „id:“ oder „retry:“ gesendet.

Wenn der Server diese Felder jemals ausgibt (z. B. nach einem Upgrade von llama.cpp), werden sie unter INFO protokolliert so dass die Änderung in der Diagnose sichtbar ist.

Parameters

endpoint

The API endpoint path.

jsonBody

The JSON request body (should include "stream": true).

onLine

Callback invoked for each SSE data: line as it arrives.

shouldStop

Callback that returns true to abort streaming early.

timeoutMs

Read timeout in milliseconds.

port

Optional port override. Defaults to the current server port.

Throws

if the server returns a non-2xx status code.