This commit is contained in:
Amith Koujalgi 2023-11-07 23:06:02 +05:30
parent 153f516d9f
commit c74e70f3fa
2 changed files with 7 additions and 2 deletions

View File

@ -11,6 +11,7 @@ Install:
From [Maven Central](https://s01.oss.sonatype.org/#nexus-search;quick~ollama4j):
```xml
<dependency>
<groupId>io.github.amithkoujalgi</groupId>
<artifactId>ollama4j</artifactId>
@ -21,9 +22,10 @@ From [Maven Central](https://s01.oss.sonatype.org/#nexus-search;quick~ollama4j):
You might want to include the Maven repository to pull the ollama4j library from. Include this in your `pom.xml`:
```xml
<repositories>
<repository>
<id>ollama-from-ossrh</id>
<id>ollama4j-from-ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
@ -36,6 +38,7 @@ mvn clean install
```
Start Ollama Container:
```
docker run -v ~/ollama:/root/.ollama -p 11434:11434 ollama/ollama
```
@ -51,6 +54,7 @@ public class Main {
}
}
```
Post a question to Ollama using Ollama4j:
Using sync API:
@ -86,6 +90,7 @@ public class Main {
```
You'd then get a response from Ollama:
```
I am LLaMA, an AI assistant developed by Meta AI that can understand and respond to human input in a conversational manner. I am trained on a massive dataset of text from the internet and can generate human-like responses to a wide range of topics and questions. I can be used to create chatbots, virtual assistants, and other applications that require natural language understanding and generation capabilities.
```

View File

@ -10,7 +10,7 @@ public class Main {
OllamaAPI ollamaAPI = new OllamaAPI(host);
String prompt1 = SamplePrompts.getSampleDatabasePromptWithQuestion("List all customer names who have bought one or more products");
String response1 = ollamaAPI.ask(OllamaModelType.LLAMA2, prompt1);
String response1 = ollamaAPI.ask(OllamaModelType.SQLCODER, prompt1);
System.out.println(response1);
String prompt2 = "Give me a list of world cup cricket teams.";