mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-10-27 14:40:42 +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
|
||||
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 static void main(String[] args) {
|
||||
@@ -129,7 +147,7 @@ public class OllamaAPITest {
|
||||
|
||||
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: {
|
||||
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",
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "^3.4.0",
|
||||
"@docusaurus/plugin-google-gtag": "^3.4.0",
|
||||
"@docusaurus/preset-classic": "^3.4.0",
|
||||
"@docusaurus/theme-mermaid": "^3.4.0",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "^3.4.0",
|
||||
"@docusaurus/plugin-google-gtag": "^3.4.0",
|
||||
"@docusaurus/preset-classic": "^3.4.0",
|
||||
"@docusaurus/theme-mermaid": "^3.4.0",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
|
||||
@@ -58,7 +58,14 @@ public class OllamaAPI {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.github.ollama4j.models.ps;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -7,29 +9,55 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ModelsProcessResponse {
|
||||
@JsonProperty("models")
|
||||
private List<ModelProcess> models;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class ModelProcess {
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("model")
|
||||
private String model;
|
||||
|
||||
@JsonProperty("size")
|
||||
private long size;
|
||||
|
||||
@JsonProperty("digest")
|
||||
private String digest;
|
||||
|
||||
@JsonProperty("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;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class ModelDetails {
|
||||
@JsonProperty("parent_model")
|
||||
private String parentModel;
|
||||
|
||||
@JsonProperty("format")
|
||||
private String format;
|
||||
|
||||
@JsonProperty("family")
|
||||
private String family;
|
||||
|
||||
@JsonProperty("families")
|
||||
private List<String> families;
|
||||
|
||||
@JsonProperty("parameter_size")
|
||||
private String parameterSize;
|
||||
|
||||
@JsonProperty("quantization_level")
|
||||
private String quantizationLevel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user