forked from Mirror/ollama4j
Updated models with Lombok
This commit is contained in:
parent
1df8622b32
commit
a0d6a5ef97
2
.github/workflows/maven-publish.yml
vendored
2
.github/workflows/maven-publish.yml
vendored
@ -49,7 +49,7 @@ jobs:
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
||||
|
||||
- name: Publish to GitHub Packages Apache Maven
|
||||
run: mvn clean deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"
|
||||
run: mvn clean deploy -Punit-tests -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
|
||||
|
7
pom.xml
7
pom.xml
@ -18,6 +18,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<maven-failsafe-plugin.version>3.0.0-M5</maven-failsafe-plugin.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
@ -143,6 +144,12 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
@ -276,7 +276,7 @@ public class OllamaAPI {
|
||||
} else {
|
||||
OllamaResponseModel ollamaResponseModel =
|
||||
Utils.getObjectMapper().readValue(line, OllamaResponseModel.class);
|
||||
if (!ollamaResponseModel.getDone()) {
|
||||
if (!ollamaResponseModel.isDone()) {
|
||||
responseBuffer.append(ollamaResponseModel.getResponse());
|
||||
}
|
||||
}
|
||||
|
@ -3,20 +3,11 @@ package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Data
|
||||
public class EmbeddingResponse {
|
||||
@JsonProperty("embedding")
|
||||
private List<Double> embedding;
|
||||
|
||||
public EmbeddingResponse() {
|
||||
}
|
||||
|
||||
public List<Double> getEmbedding() {
|
||||
return embedding;
|
||||
}
|
||||
|
||||
public void setEmbedding(List<Double> embedding) {
|
||||
this.embedding = embedding;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ListModelsResponse {
|
||||
private List<Model> models;
|
||||
|
||||
public List<Model> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(List<Model> models) {
|
||||
this.models = models;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Model {
|
||||
|
||||
private String name;
|
||||
@ -12,19 +14,6 @@ public class Model {
|
||||
@JsonProperty("details")
|
||||
private ModelMeta modelMeta;
|
||||
|
||||
/**
|
||||
* Returns the model's tag. This includes model name and its version separated by a colon
|
||||
* character `:`
|
||||
*
|
||||
* @return model tag
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model name without its version
|
||||
@ -44,31 +33,4 @@ public class Model {
|
||||
return name.split(":")[1];
|
||||
}
|
||||
|
||||
public String getModifiedAt() {
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt) {
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public ModelMeta getModelMeta() {
|
||||
return modelMeta;
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,14 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ModelDetail {
|
||||
private String license;
|
||||
@JsonProperty("modelfile")
|
||||
private String modelFile;
|
||||
private String parameters, template;
|
||||
private String parameters;
|
||||
private String template;
|
||||
private String system;
|
||||
|
||||
public String getSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
public void setSystem(String system) {
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public String getModelFile() {
|
||||
return modelFile;
|
||||
}
|
||||
|
||||
public void setModelFile(String modelFile) {
|
||||
this.modelFile = modelFile;
|
||||
}
|
||||
|
||||
public String getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(String parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public String getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
public void setTemplate(String template) {
|
||||
this.template = template;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ModelMeta {
|
||||
|
||||
@JsonProperty("format")
|
||||
private String format;
|
||||
|
||||
@ -18,44 +21,4 @@ public class ModelMeta {
|
||||
|
||||
@JsonProperty("quantization_level")
|
||||
private String quantizationLevel;
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return family;
|
||||
}
|
||||
|
||||
public void setFamily(String family) {
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
public String[] getFamilies() {
|
||||
return families;
|
||||
}
|
||||
|
||||
public void setFamilies(String[] families) {
|
||||
this.families = families;
|
||||
}
|
||||
|
||||
public String getParameterSize() {
|
||||
return parameterSize;
|
||||
}
|
||||
|
||||
public void setParameterSize(String parameterSize) {
|
||||
this.parameterSize = parameterSize;
|
||||
}
|
||||
|
||||
public String getQuantizationLevel() {
|
||||
return quantizationLevel;
|
||||
}
|
||||
|
||||
public void setQuantizationLevel(String quantizationLevel) {
|
||||
this.quantizationLevel = quantizationLevel;
|
||||
}
|
||||
}
|
||||
|
@ -1,44 +1,13 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ModelPullResponse {
|
||||
private String status;
|
||||
|
||||
private String digest;
|
||||
private long total;
|
||||
private long completed;
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public long getCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
public void setCompleted(long completed) {
|
||||
this.completed = completed;
|
||||
}
|
||||
}
|
||||
|
@ -68,12 +68,11 @@ public class OllamaAsyncResultCallback extends Thread {
|
||||
OllamaResponseModel ollamaResponseModel =
|
||||
Utils.getObjectMapper().readValue(line, OllamaResponseModel.class);
|
||||
queue.add(ollamaResponseModel.getResponse());
|
||||
if (!ollamaResponseModel.getDone()) {
|
||||
if (!ollamaResponseModel.isDone()) {
|
||||
responseBuffer.append(ollamaResponseModel.getResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
|
||||
this.isDone = true;
|
||||
this.succeeded = true;
|
||||
|
@ -3,16 +3,11 @@ package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class OllamaErrorResponseModel {
|
||||
|
||||
private String error;
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OllamaRequestModel {
|
||||
private String model;
|
||||
private String prompt;
|
||||
@ -9,20 +12,4 @@ public class OllamaRequestModel {
|
||||
this.model = model;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
public void setPrompt(String prompt) {
|
||||
this.prompt = prompt;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class OllamaResponseModel {
|
||||
private String model;
|
||||
@ -18,92 +20,4 @@ public class OllamaResponseModel {
|
||||
private @JsonProperty("eval_duration") Long evalDuration;
|
||||
private @JsonProperty("prompt_eval_count") Integer promptEvalCount;
|
||||
private @JsonProperty("eval_count") Integer evalCount;
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public boolean getDone() {
|
||||
return done;
|
||||
}
|
||||
|
||||
public void setDone(boolean done) {
|
||||
this.done = done;
|
||||
}
|
||||
|
||||
public List<Integer> getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(List<Integer> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Long getTotalDuration() {
|
||||
return totalDuration;
|
||||
}
|
||||
|
||||
public void setTotalDuration(Long totalDuration) {
|
||||
this.totalDuration = totalDuration;
|
||||
}
|
||||
|
||||
public Long getLoadDuration() {
|
||||
return loadDuration;
|
||||
}
|
||||
|
||||
public void setLoadDuration(Long loadDuration) {
|
||||
this.loadDuration = loadDuration;
|
||||
}
|
||||
|
||||
public Long getPromptEvalDuration() {
|
||||
return promptEvalDuration;
|
||||
}
|
||||
|
||||
public void setPromptEvalDuration(Long promptEvalDuration) {
|
||||
this.promptEvalDuration = promptEvalDuration;
|
||||
}
|
||||
|
||||
public Long getEvalDuration() {
|
||||
return evalDuration;
|
||||
}
|
||||
|
||||
public void setEvalDuration(Long evalDuration) {
|
||||
this.evalDuration = evalDuration;
|
||||
}
|
||||
|
||||
public Integer getPromptEvalCount() {
|
||||
return promptEvalCount;
|
||||
}
|
||||
|
||||
public void setPromptEvalCount(Integer promptEvalCount) {
|
||||
this.promptEvalCount = promptEvalCount;
|
||||
}
|
||||
|
||||
public Integer getEvalCount() {
|
||||
return evalCount;
|
||||
}
|
||||
|
||||
public void setEvalCount(Integer eval_count) {
|
||||
this.evalCount = eval_count;
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,36 @@ package io.github.amithkoujalgi.ollama4j.core.models;
|
||||
import static io.github.amithkoujalgi.ollama4j.core.utils.Utils.getObjectMapper;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
/** The type Ollama result. */
|
||||
@Getter
|
||||
@SuppressWarnings("unused")
|
||||
@Data
|
||||
public class OllamaResult {
|
||||
/**
|
||||
* -- GETTER --
|
||||
* Get the response text
|
||||
*
|
||||
* @return String - response text
|
||||
*/
|
||||
private final String response;
|
||||
|
||||
/**
|
||||
* -- GETTER --
|
||||
* Get the response status code.
|
||||
*
|
||||
* @return int - response status code
|
||||
*/
|
||||
private int httpStatusCode;
|
||||
|
||||
/**
|
||||
* -- GETTER --
|
||||
* Get the response time in milliseconds.
|
||||
*
|
||||
* @return long - response time in milliseconds
|
||||
*/
|
||||
private long responseTime = 0;
|
||||
|
||||
public OllamaResult(String response, long responseTime, int httpStatusCode) {
|
||||
@ -19,33 +41,6 @@ public class OllamaResult {
|
||||
this.httpStatusCode = httpStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response text
|
||||
*
|
||||
* @return String - response text
|
||||
*/
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response time in milliseconds.
|
||||
*
|
||||
* @return long - response time in milliseconds
|
||||
*/
|
||||
public long getResponseTime() {
|
||||
return responseTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response status code.
|
||||
*
|
||||
* @return int - response status code
|
||||
*/
|
||||
public int getHttpStatusCode() {
|
||||
return httpStatusCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user