LlamaHttpClient

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

Client HTTP per comunicare con un'istanza LLAMA-Server locale.

Fornisce richieste POST sincrone e in streaming all'API LLAMA-Server. La porta viene fornita come a lambda in modo che si risolva sempre sulla porta attiva corrente.

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

Invia una richiesta POST al server LLAMA e restituisce il corpo della risposta.

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

Link copied to clipboard

Base URL for a specific port.