blob: 2ef1b97a8b29943ab1c6135dfc6ae574eacf80b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package ai.vespa.llm;
import ai.vespa.llm.completion.Prompt;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
public class InferenceParameters {
private final String apiKey;
private final Function<String, String> options;
public InferenceParameters(Function<String, String> options) {
this(null, options);
}
public InferenceParameters(String apiKey, Function<String, String> options) {
this.apiKey = apiKey;
this.options = Objects.requireNonNull(options);
}
public Optional<String> getApiKey() {
return Optional.ofNullable(apiKey);
}
public Optional<String> get(String option) {
return Optional.ofNullable(options.apply(option));
}
public Optional<Double> getDouble(String option) {
try {
return Optional.of(Double.parseDouble(options.apply(option)));
} catch (Exception e) {
return Optional.empty();
}
}
public Optional<Integer> getInt(String option) {
try {
return Optional.of(Integer.parseInt(options.apply(option)));
} catch (Exception e) {
return Optional.empty();
}
}
}
|