1package io.github.ollama4j.models.response;
3import static io.github.ollama4j.utils.Utils.getObjectMapper;
7import com.fasterxml.jackson.annotation.JsonCreator;
8import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
9import com.fasterxml.jackson.annotation.JsonProperty;
10import com.fasterxml.jackson.core.JsonProcessingException;
11import com.fasterxml.jackson.core.type.TypeReference;
15import lombok.NoArgsConstructor;
18@SuppressWarnings(
"unused")
21@JsonIgnoreProperties(ignoreUnknown =
true)
23 private String response;
25 private int httpStatusCode;
27 private long responseTime = 0;
32 this.response = response;
33 this.responseTime = responseTime;
34 this.httpStatusCode = httpStatusCode;
40 return getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(
this);
41 }
catch (JsonProcessingException e) {
42 throw new RuntimeException(e);
53 Map<String, Object> response = getObjectMapper().readValue(this.getResponse(),
54 new TypeReference<Map<String, Object>>() {
57 }
catch (JsonProcessingException e) {
58 throw new RuntimeException(e);
70 public <T> T getStructuredResponse(Class<T> clazz) {
72 return getObjectMapper().readValue(this.getResponse(), clazz);
73 }
catch (JsonProcessingException e) {
74 throw new RuntimeException(e);
Map< String, Object > getStructuredResponse()
OllamaStructuredResult(String response, long responseTime, int httpStatusCode)