http Post Streaming
fun httpPostStreaming(endpoint: String, jsonBody: String, onLine: (String) -> Unit, shouldStop: () -> Boolean = { false }, timeoutMs: Int, port: Int = defaultPort())
Sends a POST request to the LLAMA-Server and streams the response as SSE lines.
SSE framing contract
The llama.cpp server emits a minimal SSE stream:
Each chunk is a
data: {json}line followed by a blank line.The stream ends with
data: [DONE].No
event:,id:, orretry:fields are sent under normal operation.
If the server ever emits those fields (e.g. after a llama.cpp upgrade), they are logged at INFO level so the change is visible in diagnostics.
Parameters
endpoint
The API endpoint path.
json Body
The JSON request body (should include "stream": true).
on Line
Callback invoked for each SSE data: line as it arrives.
should Stop
Callback that returns true to abort streaming early.
timeout Ms
Read timeout in milliseconds.
port
Optional port override. Defaults to the current server port.
Throws
if the server returns a non-2xx status code.