Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OptionsBuilder.java
Go to the documentation of this file.
1package io.github.ollama4j.utils;
2
3import java.io.IOException;
4import java.util.HashMap;
5
7public class OptionsBuilder {
8
9 private final Options options;
10
12 public OptionsBuilder() {
13 this.options = new Options(new HashMap<>());
14 }
15
23 public OptionsBuilder setMirostat(int value) {
24 options.getOptionsMap().put("mirostat", value);
25 return this;
26 }
27
36 public OptionsBuilder setMirostatEta(float value) {
37 options.getOptionsMap().put("mirostat_eta", value);
38 return this;
39 }
40
48 public OptionsBuilder setMirostatTau(float value) {
49 options.getOptionsMap().put("mirostat_tau", value);
50 return this;
51 }
52
59 public OptionsBuilder setNumCtx(int value) {
60 options.getOptionsMap().put("num_ctx", value);
61 return this;
62 }
63
71 public OptionsBuilder setNumGqa(int value) {
72 options.getOptionsMap().put("num_gqa", value);
73 return this;
74 }
75
83 public OptionsBuilder setNumGpu(int value) {
84 options.getOptionsMap().put("num_gpu", value);
85 return this;
86 }
87
96 public OptionsBuilder setNumThread(int value) {
97 options.getOptionsMap().put("num_thread", value);
98 return this;
99 }
100
108 public OptionsBuilder setRepeatLastN(int value) {
109 options.getOptionsMap().put("repeat_last_n", value);
110 return this;
111 }
112
120 public OptionsBuilder setRepeatPenalty(float value) {
121 options.getOptionsMap().put("repeat_penalty", value);
122 return this;
123 }
124
132 public OptionsBuilder setTemperature(float value) {
133 options.getOptionsMap().put("temperature", value);
134 return this;
135 }
136
144 public OptionsBuilder setSeed(int value) {
145 options.getOptionsMap().put("seed", value);
146 return this;
147 }
148
157 public OptionsBuilder setStop(String value) {
158 options.getOptionsMap().put("stop", value);
159 return this;
160 }
161
170 public OptionsBuilder setTfsZ(float value) {
171 options.getOptionsMap().put("tfs_z", value);
172 return this;
173 }
174
182 public OptionsBuilder setNumPredict(int value) {
183 options.getOptionsMap().put("num_predict", value);
184 return this;
185 }
186
194 public OptionsBuilder setTopK(int value) {
195 options.getOptionsMap().put("top_k", value);
196 return this;
197 }
198
206 public OptionsBuilder setTopP(float value) {
207 options.getOptionsMap().put("top_p", value);
208 return this;
209 }
210
217 public OptionsBuilder setMinP(float value) {
218 options.getOptionsMap().put("min_p", value);
219 return this;
220 }
221
229 public OptionsBuilder setCustomOption(String name, Object value) throws IllegalArgumentException {
230 if (!(value instanceof Integer || value instanceof Float || value instanceof String)) {
231 throw new IllegalArgumentException("Invalid type for parameter. Allowed types are: Integer, Float, or String.");
232 }
233 options.getOptionsMap().put(name, value);
234 return this;
235 }
236
237
238
244 public Options build() {
245 return options;
246 }
247
248
249}
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)