- replaced GSON with Jackson

- Updated readme
- general cleanup
This commit is contained in:
Amith Koujalgi
2023-11-09 12:56:45 +05:30
parent 1f28e61234
commit 6678cd3f69
7 changed files with 73 additions and 22 deletions

View File

@@ -279,6 +279,28 @@ FROM sales
GROUP BY customers.name;
```
#### Async API with streaming response
```java
public class Main {
public static void main(String[] args) throws Exception {
String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host);
String prompt = "List all cricket world cup teams of 2019.";
OllamaAsyncResultCallback callback = ollamaAPI.askAsync(OllamaModelType.LLAMA2, prompt);
while (!callback.isComplete() || !callback.getStream().isEmpty()) {
// poll for data from the response stream
String response = callback.getStream().poll();
if (response != null) {
System.out.print(response);
}
Thread.sleep(1000);
}
}
}
```
#### API Spec
Find the full `Javadoc` (API specifications) [here](https://amithkoujalgi.github.io/ollama4j/).