LlamaHttpClient

class LlamaHttpClient(defaultPort: () -> Int, log: (CodBi.LogLevel, String) -> Unit)

HTTP-Client zur Kommunikation mit einer lokalen LLAMA-Server-Instanz.

Stellt synchrone und Streaming-POST-Anfragen an die LLAMA-Server-API bereit. Port wird als geliefert Lambda, damit es immer zum aktuell aktiven Port aufgelöst wird.

Parameters

defaultPort

Lambda returning the current server port. Called on each request.

log

Log function for diagnostic output.

Constructors

Link copied to clipboard
constructor(defaultPort: () -> Int, log: (CodBi.LogLevel, String) -> Unit)

Properties

Link copied to clipboard

Base URL using the default port.

Functions

Link copied to clipboard
fun httpPost(endpoint: String, jsonBody: String, timeoutMs: Int, port: Int = defaultPort()): String

Sendet eine POST-Anfrage an den LLAMA-Server und gibt den Antworttext zurück.

Link copied to clipboard
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.

Link copied to clipboard

Base URL for a specific port.