Unofficial Ollama API client for Kotlin multiplatform.
The implementation follows the OpenAPI definition Ollama API described in Ollama API Docs.
Add the dependency to your project:
Warning
nirmato-ollama is not yet available in a repository.
implementation("org.nirmato.ollama:nirmato-ollama-client-ktor:0.1.0")
// example using ktor CIO engine
implementation("io.ktor:ktor-client-cio:3.0.3")
<dependency>
<groupId>org.nirmato.ollama</groupId>
<artifactId>nirmato-ollama-client-ktor</artifactId>
<version>0.1.0</version>
</dependency>
<!-- example using ktor CIO engine -->
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-cio</artifactId>
<version>3.0.3</version>
</dependency>
Alternatively, you can choose individual components of this library.
val ollamaClient = OllamaClient(CIO)
val request = chatRequest {
model("tinyllama")
messages(listOf(Message(role = USER, content = "Why is the sky blue?")))
}
val response = ollamaClient.chat(request)
JetBrains for making Kotlin.
The source code is distributed under Apache License 2.0.