ollama4j/docs/docs/intro.md
Amith Koujalgi 8b2145913c Updated docs
2023-12-26 15:34:37 +05:30

1.9 KiB

sidebar_position
sidebar_position
1

Intro

Let's discover Ollama4J in less than 5 minutes.

Getting Started

What you'll need

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/.

Setup your project

Get started by creating a new Maven project on your favorite IDE.

Add the dependency to your project's pom.xml.


<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);
  }
}