mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-11-02 17:40:41 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11a98a72a1 | ||
|
|
422601c0fc | ||
|
|
75e6576a13 | ||
|
|
51dd3f3e1e |
@@ -118,6 +118,24 @@ Create a new Java class in your project and add this code.
|
|||||||
```java
|
```java
|
||||||
import io.github.ollama4j.OllamaAPI;
|
import io.github.ollama4j.OllamaAPI;
|
||||||
|
|
||||||
|
public class OllamaAPITest {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
OllamaAPI ollamaAPI = new OllamaAPI();
|
||||||
|
|
||||||
|
boolean isOllamaServerReachable = ollamaAPI.ping();
|
||||||
|
|
||||||
|
System.out.println("Is Ollama server running: " + isOllamaServerReachable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
This uses the default Ollama host as `http://localhost:11434`.
|
||||||
|
|
||||||
|
Specify a different Ollama host that you want to connect to.
|
||||||
|
|
||||||
|
```java
|
||||||
|
import io.github.ollama4j.OllamaAPI;
|
||||||
|
|
||||||
public class OllamaAPITest {
|
public class OllamaAPITest {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -129,7 +147,7 @@ public class OllamaAPITest {
|
|||||||
|
|
||||||
boolean isOllamaServerReachable = ollamaAPI.ping();
|
boolean isOllamaServerReachable = ollamaAPI.ping();
|
||||||
|
|
||||||
System.out.println("Is Ollama server alive: " + isOllamaServerReachable);
|
System.out.println("Is Ollama server running: " + isOllamaServerReachable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ const config = {
|
|||||||
theme: {
|
theme: {
|
||||||
customCss: './src/css/custom.css',
|
customCss: './src/css/custom.css',
|
||||||
},
|
},
|
||||||
|
gtag: {
|
||||||
|
trackingID: 'G-G7FLH6FNDC',
|
||||||
|
anonymizeIP: false,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
1
docs/package-lock.json
generated
1
docs/package-lock.json
generated
@@ -9,6 +9,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "^3.4.0",
|
"@docusaurus/core": "^3.4.0",
|
||||||
|
"@docusaurus/plugin-google-gtag": "^3.4.0",
|
||||||
"@docusaurus/preset-classic": "^3.4.0",
|
"@docusaurus/preset-classic": "^3.4.0",
|
||||||
"@docusaurus/theme-mermaid": "^3.4.0",
|
"@docusaurus/theme-mermaid": "^3.4.0",
|
||||||
"@mdx-js/react": "^3.0.0",
|
"@mdx-js/react": "^3.0.0",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "^3.4.0",
|
"@docusaurus/core": "^3.4.0",
|
||||||
|
"@docusaurus/plugin-google-gtag": "^3.4.0",
|
||||||
"@docusaurus/preset-classic": "^3.4.0",
|
"@docusaurus/preset-classic": "^3.4.0",
|
||||||
"@docusaurus/theme-mermaid": "^3.4.0",
|
"@docusaurus/theme-mermaid": "^3.4.0",
|
||||||
"@mdx-js/react": "^3.0.0",
|
"@mdx-js/react": "^3.0.0",
|
||||||
|
|||||||
@@ -58,7 +58,14 @@ public class OllamaAPI {
|
|||||||
private final ToolRegistry toolRegistry = new ToolRegistry();
|
private final ToolRegistry toolRegistry = new ToolRegistry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the Ollama API.
|
* Instantiates the Ollama API with default Ollama host: <a href="http://localhost:11434">http://localhost:11434</a>
|
||||||
|
**/
|
||||||
|
public OllamaAPI() {
|
||||||
|
this.host = "http://localhost:11434";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates the Ollama API with specified Ollama host address.
|
||||||
*
|
*
|
||||||
* @param host the host address of Ollama server
|
* @param host the host address of Ollama server
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package io.github.ollama4j.models.ps;
|
package io.github.ollama4j.models.ps;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@@ -7,29 +9,55 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class ModelsProcessResponse {
|
public class ModelsProcessResponse {
|
||||||
|
@JsonProperty("models")
|
||||||
private List<ModelProcess> models;
|
private List<ModelProcess> models;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class ModelProcess {
|
public static class ModelProcess {
|
||||||
|
@JsonProperty("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty("model")
|
||||||
private String model;
|
private String model;
|
||||||
|
|
||||||
|
@JsonProperty("size")
|
||||||
private long size;
|
private long size;
|
||||||
|
|
||||||
|
@JsonProperty("digest")
|
||||||
private String digest;
|
private String digest;
|
||||||
|
|
||||||
|
@JsonProperty("details")
|
||||||
private ModelDetails details;
|
private ModelDetails details;
|
||||||
private String expiresAt;
|
|
||||||
|
@JsonProperty("expires_at")
|
||||||
|
private String expiresAt; // Consider using LocalDateTime if you need to process date/time
|
||||||
|
|
||||||
|
@JsonProperty("size_vram")
|
||||||
private long sizeVram;
|
private long sizeVram;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class ModelDetails {
|
public static class ModelDetails {
|
||||||
|
@JsonProperty("parent_model")
|
||||||
private String parentModel;
|
private String parentModel;
|
||||||
|
|
||||||
|
@JsonProperty("format")
|
||||||
private String format;
|
private String format;
|
||||||
|
|
||||||
|
@JsonProperty("family")
|
||||||
private String family;
|
private String family;
|
||||||
|
|
||||||
|
@JsonProperty("families")
|
||||||
private List<String> families;
|
private List<String> families;
|
||||||
|
|
||||||
|
@JsonProperty("parameter_size")
|
||||||
private String parameterSize;
|
private String parameterSize;
|
||||||
|
|
||||||
|
@JsonProperty("quantization_level")
|
||||||
private String quantizationLevel;
|
private String quantizationLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user