Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
Model.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.response;
10
11import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
12import com.fasterxml.jackson.annotation.JsonProperty;
13import com.fasterxml.jackson.core.JsonProcessingException;
14import io.github.ollama4j.utils.Utils;
15import java.time.OffsetDateTime;
16import lombok.Data;
17
18@Data
19@JsonIgnoreProperties(ignoreUnknown = true)
20public class Model {
21
22 private String name;
23 private String model;
24
25 @JsonProperty("modified_at")
26 private OffsetDateTime modifiedAt;
27
28 @JsonProperty("expires_at")
29 private OffsetDateTime expiresAt;
30
31 private String digest;
32 private long size;
33
34 @JsonProperty("details")
35 private ModelMeta modelMeta;
36
42 public String getModelName() {
43 return name.split(":")[0];
44 }
45
51 public String getModelVersion() {
52 return name.split(":")[1];
53 }
54
55 @Override
56 public String toString() {
57 try {
58 return Utils.getObjectMapper()
59 .writerWithDefaultPrettyPrinter()
60 .writeValueAsString(this);
61 } catch (JsonProcessingException e) {
62 throw new RuntimeException(e);
63 }
64 }
65}
static ObjectMapper getObjectMapper()
Definition Utils.java:32