Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaRequestBody.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.utils;
10
11import com.fasterxml.jackson.annotation.JsonIgnore;
12import com.fasterxml.jackson.core.JsonProcessingException;
13import java.net.http.HttpRequest.BodyPublisher;
14import java.net.http.HttpRequest.BodyPublishers;
15
19public interface OllamaRequestBody {
20
26 @JsonIgnore
27 default BodyPublisher getBodyPublisher() {
28 try {
29 return BodyPublishers.ofString(Utils.getObjectMapper().writeValueAsString(this));
30 } catch (JsonProcessingException e) {
31 throw new IllegalArgumentException("Request not Body convertible.", e);
32 }
33 }
34}
static ObjectMapper getObjectMapper()
Definition Utils.java:32