A Java library (wrapper/binding) for Ollama server.
Find more details on the website.
flowchart LR
o4j[Ollama4j]
o[Ollama Server]
o4j -->|Communicates with| o;
m[Models]
subgraph Ollama Deployment
direction TB
o -->|Manages| m
end
In your Maven project, add this dependency:
<dependency>
<groupId>io.github.amithkoujalgi</groupId>
<artifactId>ollama4j</artifactId>
<version>1.0.57</version>
</dependency>Latest release:
Find the full API specifications on the website.
Build:
make buildRun unit tests:
make utRun integration tests:
make itReleases (newer artifact versions) are done automatically on pushing the code to the main branch through GitHub
Actions CI workflow.
- Use Java-naming conventions for attributes in the request/response models instead of the
snake-case conventions. (
possibly with Jackson-mapper's
@JsonProperty) - Fix deprecated HTTP client code
- Setup logging
- Use lombok
- Update request body creation with Java objects
- Async APIs for images
- Add custom headers to requests
- Add additional params for
askAPIs such as:-
options: additional model parameters for the Modelfile such astemperature- Supported params. -
system: system prompt to (overrides what is defined in the Modelfile) -
template: the full prompt or prompt template (overrides what is defined in the Modelfile) -
context: the context parameter returned from a previous request, which can be used to keep a short conversational memory -
stream: Add support for streaming responses from the model
-
- Add test cases
- Handle exceptions better (maybe throw more appropriate exceptions)
Contributions are most welcome! Whether it's reporting a bug, proposing an enhancement, or helping with code - any sort of contribution is much appreciated.
The nomenclature and the icon have been adopted from the incredible Ollama project.