This commit is contained in:
Amith Koujalgi
2023-10-27 16:26:40 +05:30
parent d593e974ee
commit 10ffe0f14a
4 changed files with 40 additions and 15 deletions

View File

@@ -1,13 +0,0 @@
package io.github.amithkoujalgi.ollama4j;
public class Main {
public static void main(String[] args) throws Exception {
String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host);
ollamaAPI.pullModel(OllamaModel.LLAMA2);
String response = ollamaAPI.runSync(OllamaModel.LLAMA2, "Who are you?");
System.out.println(response);
}
}

View File

@@ -0,0 +1,24 @@
package io.github.amithkoujalgi.ollama4j;
import org.apache.hc.core5.http.ParseException;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.IOException;
import static org.mockito.Mockito.*;
public class TestMockedAPIs {
@Test
public void testMockPullModel() {
OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class);
OllamaModel model = OllamaModel.LLAMA2;
try {
doNothing().when(ollamaAPI).pullModel(model);
ollamaAPI.pullModel(model);
verify(ollamaAPI, times(1)).pullModel(model);
} catch (IOException | ParseException | OllamaBaseException e) {
throw new RuntimeException(e);
}
}
}