httpPostStreaming

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

Invia una richiesta POST al server LLAMA e trasmette la risposta come linee SSE.

Contratto di inquadramento SSE

Il server llama.cpp emette un flusso SSE minimo:

  • Ogni blocco è una riga data: {json} seguita da una riga vuota.

  • Lo stream termina con "data: DONE".

  • Nessun campo "event:", "id:" o "retry:" viene inviato durante il normale funzionamento.

Se il server emette mai questi campi (ad esempio dopo un aggiornamento llama.cpp), vengono registrati in INFO livello in modo che la modifica sia visibile nella diagnostica.

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.