Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaRequestBody.java
Go to the documentation of this file.
1package io.github.ollama4j.utils;
2
3import java.net.http.HttpRequest.BodyPublisher;
4import java.net.http.HttpRequest.BodyPublishers;
5
6import com.fasterxml.jackson.annotation.JsonIgnore;
7import com.fasterxml.jackson.core.JsonProcessingException;
8
12public interface OllamaRequestBody {
13
19 @JsonIgnore
20 default BodyPublisher getBodyPublisher(){
21 try {
22 return BodyPublishers.ofString(
23 Utils.getObjectMapper().writeValueAsString(this));
24 } catch (JsonProcessingException e) {
25 throw new IllegalArgumentException("Request not Body convertible.",e);
26 }
27 }
28}
static ObjectMapper getObjectMapper()
Definition Utils.java:17