Merge pull request #5 from reckart/bugfix/4-evalCount-in-response-from-ollama-cannot-be-parsed

Issue #4: evalCount in response from ollama cannot be parsed.

Thanks @reckart! I had actually made some updates for the `OllamaResponseModel` class to ignore the unknown fields but somehow had missed the `eval_count`.

About your third point,
> Configure JSON mapping to ignore unknown fields to avoid errors in case ollama expands its response

I believe this would take care of unknown fields and we do not have to explicitly mark the fields to be ignored: df9b9af063/src/main/java/io/github/amithkoujalgi/ollama4j/core/OllamaAPI.java (L40-L41)
This commit is contained in:
Amith Koujalgi 2023-11-13 00:14:55 +05:30 committed by GitHub
commit 0d6af4b4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,32 +1,23 @@
package io.github.amithkoujalgi.ollama4j.core.models;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OllamaResponseModel {
private String model;
@JsonProperty("created_at")
private String createdAt;
private @JsonProperty("created_at") String createdAt;
private String response;
private Boolean done;
private List<Integer> context;
@JsonProperty("total_duration")
private Long totalDuration;
@JsonProperty("load_duration")
private Long loadDuration;
@JsonProperty("prompt_eval_duration")
private Long promptEvalDuration;
@JsonProperty("eval_duration")
private Long evalDuration;
@JsonProperty("prompt_eval_count")
private Integer promptEvalCount;
@JsonProperty("evalCount")
private Integer eval_count;
private @JsonProperty("total_duration") Long totalDuration;
private @JsonProperty("load_duration") Long loadDuration;
private @JsonProperty("prompt_eval_duration") Long promptEvalDuration;
private @JsonProperty("eval_duration") Long evalDuration;
private @JsonProperty("prompt_eval_count") Integer promptEvalCount;
private @JsonProperty("eval_count") Integer evalCount;
public String getModel() {
return model;
@ -108,11 +99,11 @@ public class OllamaResponseModel {
this.promptEvalCount = promptEvalCount;
}
public Integer getEval_count() {
return eval_count;
public Integer getEvalCount() {
return evalCount;
}
public void setEval_count(Integer eval_count) {
this.eval_count = eval_count;
public void setEvalCount(Integer eval_count) {
this.evalCount = eval_count;
}
}