Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaCommonRequest.java
Go to the documentation of this file.
1package io.github.ollama4j.models.request;
2
3import java.util.Map;
4import com.fasterxml.jackson.annotation.JsonInclude;
5import com.fasterxml.jackson.annotation.JsonProperty;
6import com.fasterxml.jackson.core.JsonProcessingException;
7import com.fasterxml.jackson.databind.annotation.JsonSerialize;
8
9import io.github.ollama4j.utils.BooleanToJsonFormatFlagSerializer;
10import io.github.ollama4j.utils.Utils;
11import lombok.Data;
12
13@Data
14@JsonInclude(JsonInclude.Include.NON_NULL)
15public abstract class OllamaCommonRequest {
16
17 protected String model;
18 @JsonSerialize(using = BooleanToJsonFormatFlagSerializer.class)
19 @JsonProperty(value = "format")
20 protected Boolean returnFormatJson;
21 protected Map<String, Object> options;
22 protected String template;
23 protected boolean stream;
24 @JsonProperty(value = "keep_alive")
25 protected String keepAlive;
26
27
28 public String toString() {
29 try {
30 return Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
31 } catch (JsonProcessingException e) {
32 throw new RuntimeException(e);
33 }
34 }
35}
static ObjectMapper getObjectMapper()
Definition Utils.java:17