OllamaGateway

class OllamaGateway(host: String = DEFAULT_OLLAMA_HOST, engine: HttpClientEngine? = null, json: Json = DEFAULT_JSON) : LlmGateway, StreamEventsGateway

Ktor-Client backed gateway to a local or remote Ollama server.

Parameters

host

Base URL of the Ollama HTTP API. Default is DEFAULT_OLLAMA_HOST.

engine

Optional Ktor engine override. Tests pass a MockEngine here.

json

Json codec used for request / response (de)serialisation.

Constructors

Link copied to clipboard
constructor(host: String = DEFAULT_OLLAMA_HOST, engine: HttpClientEngine? = null, json: Json = DEFAULT_JSON)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun availableModels(): List<String>
Link copied to clipboard
fun close()

Closes the underlying Ktor client. Call when you're done with the gateway — apps that keep one gateway around for the process lifetime can skip this.

Link copied to clipboard
open suspend override fun complete(model: String, messages: List<LlmMessage>, tools: List<LlmTool>?, config: CompletionConfig): LlmGatewayResponse
Link copied to clipboard
open suspend override fun completeJson(model: String, messages: List<LlmMessage>, schema: JsonObject, config: CompletionConfig): JsonObject
Link copied to clipboard
open suspend override fun completeJsonResponse(model: String, messages: List<LlmMessage>, schema: JsonObject, config: CompletionConfig): LlmGatewayResponse
Link copied to clipboard
open override fun stream(model: String, messages: List<LlmMessage>, tools: List<LlmTool>?, config: CompletionConfig): Flow<GatewayStreamEvent>
Link copied to clipboard