Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaCommonRequest.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.models.request;
10
11import com.fasterxml.jackson.annotation.JsonInclude;
12import com.fasterxml.jackson.annotation.JsonProperty;
13import com.fasterxml.jackson.core.JsonProcessingException;
14import io.github.ollama4j.utils.Utils;
15import java.util.Map;
16import lombok.Data;
17
18@Data
19@JsonInclude(JsonInclude.Include.NON_NULL)
20public abstract class OllamaCommonRequest {
21
22 protected String model;
23
30 @JsonProperty(value = "format", required = false, defaultValue = "json")
31 protected Object format;
32
33 protected Map<String, Object> options;
34 protected String template;
35 protected boolean stream;
36
37 @JsonProperty(value = "keep_alive")
38 protected String keepAlive;
39
40 public String toString() {
41 try {
42 return Utils.getObjectMapper()
43 .writerWithDefaultPrettyPrinter()
44 .writeValueAsString(this);
45 } catch (JsonProcessingException e) {
46 throw new RuntimeException(e);
47 }
48 }
49}
static ObjectMapper getObjectMapper()
Definition Utils.java:32