mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 11:57:12 +02:00
1.9 KiB
1.9 KiB
sidebar_position
sidebar_position |
---|
1 |
Intro
Let's discover Ollama4J in less than 5 minutes.
Getting Started
What you'll need
- Ollama
- Oracle JDK or Open JDK 11.0 or above.
- Maven or Gradle
Start Ollama server
The easiest way of getting started with Ollama server is with * *Docker**. But if you choose to run the Ollama server directly, download the distribution of your choice and follow the installation process.
With Docker
Run in CPU mode:
docker run -it -v ~/ollama:/root/.ollama -p 11434:11434 ollama/ollama
Run in GPU mode:
docker run -it --gpus=all -v ~/ollama:/root/.ollama -p 11434:11434 ollama/ollama
You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.
The command runs the Ollama server locally at http://localhost:11434/.
Start your project
Get started by creating a new Maven project on your favorite IDE.
Add the dependency to your project.
<dependency>
<groupId>io.github.amithkoujalgi</groupId>
<artifactId>ollama4j</artifactId>
<version>1.0.27</version>
</dependency>
Create a new Java class in your project and add this code.
public class OllamaAPITest {
public static void main(String[] args) {
String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host);
ollamaAPI.setVerbose(true);
boolean isOllamaServerReachable = ollamaAPI.ping();
System.out.println("Is Ollama server alive: " + isOllamaServerReachable);
}
}