Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OptionsBuilder.java
Go to the documentation of this file.
1/*
2 * Ollama4j - Java library for interacting with Ollama server.
3 * Copyright (c) 2025 Amith Koujalgi and contributors.
4 *
5 * Licensed under the MIT License (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8*/
9package io.github.ollama4j.utils;
10
11import java.util.HashMap;
12
16public class OptionsBuilder {
17
18 private final Options options;
19
23 public OptionsBuilder() {
24 this.options = new Options(new HashMap<>());
25 }
26
34 public OptionsBuilder setMirostat(int value) {
35 options.getOptionsMap().put("mirostat", value);
36 return this;
37 }
38
47 public OptionsBuilder setMirostatEta(float value) {
48 options.getOptionsMap().put("mirostat_eta", value);
49 return this;
50 }
51
59 public OptionsBuilder setMirostatTau(float value) {
60 options.getOptionsMap().put("mirostat_tau", value);
61 return this;
62 }
63
70 public OptionsBuilder setNumCtx(int value) {
71 options.getOptionsMap().put("num_ctx", value);
72 return this;
73 }
74
82 public OptionsBuilder setNumGqa(int value) {
83 options.getOptionsMap().put("num_gqa", value);
84 return this;
85 }
86
94 public OptionsBuilder setNumGpu(int value) {
95 options.getOptionsMap().put("num_gpu", value);
96 return this;
97 }
98
107 public OptionsBuilder setNumThread(int value) {
108 options.getOptionsMap().put("num_thread", value);
109 return this;
110 }
111
119 public OptionsBuilder setRepeatLastN(int value) {
120 options.getOptionsMap().put("repeat_last_n", value);
121 return this;
122 }
123
131 public OptionsBuilder setRepeatPenalty(float value) {
132 options.getOptionsMap().put("repeat_penalty", value);
133 return this;
134 }
135
143 public OptionsBuilder setTemperature(float value) {
144 options.getOptionsMap().put("temperature", value);
145 return this;
146 }
147
155 public OptionsBuilder setSeed(int value) {
156 options.getOptionsMap().put("seed", value);
157 return this;
158 }
159
168 public OptionsBuilder setStop(String value) {
169 options.getOptionsMap().put("stop", value);
170 return this;
171 }
172
181 public OptionsBuilder setTfsZ(float value) {
182 options.getOptionsMap().put("tfs_z", value);
183 return this;
184 }
185
193 public OptionsBuilder setNumPredict(int value) {
194 options.getOptionsMap().put("num_predict", value);
195 return this;
196 }
197
205 public OptionsBuilder setTopK(int value) {
206 options.getOptionsMap().put("top_k", value);
207 return this;
208 }
209
217 public OptionsBuilder setTopP(float value) {
218 options.getOptionsMap().put("top_p", value);
219 return this;
220 }
221
228 public OptionsBuilder setMinP(float value) {
229 options.getOptionsMap().put("min_p", value);
230 return this;
231 }
232
241 public OptionsBuilder setCustomOption(String name, Object value)
242 throws IllegalArgumentException {
243 if (!(value instanceof Integer || value instanceof Float || value instanceof String)) {
244 throw new IllegalArgumentException(
245 "Invalid type for parameter. Allowed types are: Integer, Float, or String.");
246 }
247 options.getOptionsMap().put(name, value);
248 return this;
249 }
250
256 public Options build() {
257 return options;
258 }
259}
OptionsBuilder setRepeatPenalty(float value)
OptionsBuilder setStop(String value)
OptionsBuilder setMirostatEta(float value)
OptionsBuilder setMirostatTau(float value)
OptionsBuilder setCustomOption(String name, Object value)
OptionsBuilder setTemperature(float value)