diff --git a/src/main/java/io/github/ollama4j/models/response/OllamaResult.java b/src/main/java/io/github/ollama4j/models/response/OllamaResult.java index d64ba32..2d340e0 100644 --- a/src/main/java/io/github/ollama4j/models/response/OllamaResult.java +++ b/src/main/java/io/github/ollama4j/models/response/OllamaResult.java @@ -1,37 +1,27 @@ package io.github.ollama4j.models.response; -import static io.github.ollama4j.utils.Utils.getObjectMapper; - -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; - import lombok.Data; import lombok.Getter; -import lombok.NoArgsConstructor; + +import static io.github.ollama4j.utils.Utils.getObjectMapper; /** The type Ollama result. */ @Getter @SuppressWarnings("unused") @Data -@NoArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) public class OllamaResult { /** * -- GETTER -- - * Get the completion/response text + * Get the completion/response text * * @return String completion/response text */ - private String response; + private final String response; /** * -- GETTER -- - * Get the response status code. + * Get the response status code. * * @return int - response status code */ @@ -39,25 +29,12 @@ public class OllamaResult { /** * -- GETTER -- - * Get the response time in milliseconds. + * Get the response time in milliseconds. * * @return long - response time in milliseconds */ private long responseTime = 0; - /** - * -- GETTER -- - * Get the model name used for the response. - * - * @return String - model name - */ - private String model; - - @JsonCreator - public OllamaResult(@JsonProperty("response") String response) { - this.response = response; - } - public OllamaResult(String response, long responseTime, int httpStatusCode) { this.response = response; this.responseTime = responseTime; @@ -72,36 +49,4 @@ public class OllamaResult { throw new RuntimeException(e); } } - - /** - * Get the structured response if the response is a JSON object. - * - * @return Map - structured response - */ - public Map getStructuredResponse() { - try { - Map response = getObjectMapper().readValue(this.getResponse(), - new TypeReference>() { - }); - return response; - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - /** - * Get the structured response mapped to a specific class type. - * - * @param The type of class to map the response to - * @param clazz The class to map the response to - * @return An instance of the specified class with the response data - * @throws RuntimeException if there is an error mapping the response - */ - public T getStructuredResponse(Class clazz) { - try { - return getObjectMapper().readValue(this.getResponse(), clazz); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } }