Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaChatMessage.java
Go to the documentation of this file.
1package io.github.ollama4j.models.chat;
2
3import static io.github.ollama4j.utils.Utils.getObjectMapper;
4
5import com.fasterxml.jackson.core.JsonProcessingException;
6import com.fasterxml.jackson.databind.annotation.JsonSerialize;
7
8import io.github.ollama4j.utils.FileToBase64Serializer;
9
10import java.util.List;
11
12import lombok.AllArgsConstructor;
13import lombok.Data;
14import lombok.NoArgsConstructor;
15import lombok.NonNull;
16import lombok.RequiredArgsConstructor;
17
23@Data
24@AllArgsConstructor
25@RequiredArgsConstructor
26@NoArgsConstructor
27public class OllamaChatMessage {
28
29 @NonNull
30 private OllamaChatMessageRole role;
31
32 @NonNull
33 private String content;
34
35 @JsonSerialize(using = FileToBase64Serializer.class)
36 private List<byte[]> images;
37
38 @Override
39 public String toString() {
40 try {
41 return getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
42 } catch (JsonProcessingException e) {
43 throw new RuntimeException(e);
44 }
45 }
46}