mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-11-01 17:10:41 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 893e5dd763 | |||
| c520604f4b | |||
| a85c23d64a | |||
| d32a8b7d88 |
32
.gitea/workflows/publish.yaml
Normal file
32
.gitea/workflows/publish.yaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Build and Publish
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: standard-22.04
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set Up Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '21'
|
||||||
|
#cache: 'maven'
|
||||||
|
#server-id: 'gitea'
|
||||||
|
|
||||||
|
- name: Set up Maven
|
||||||
|
uses: stCarolas/setup-maven@v5
|
||||||
|
with:
|
||||||
|
maven-version: 3.8.2
|
||||||
|
|
||||||
|
- run: cat /root/.m2/toolchains.xml
|
||||||
|
- run: cat /root/.m2/settings.xml
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: mvn -B package --file pom.xml
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: mvn deploy
|
||||||
|
|
||||||
16
pom.xml
16
pom.xml
@@ -129,6 +129,13 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -178,8 +185,13 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
|
</snapshotRepository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>mvn-repo-id</id>
|
<id>gitea</id>
|
||||||
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
@@ -319,4 +331,4 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -16,16 +16,10 @@ public class OllamaChatResult extends OllamaResult{
|
|||||||
List<OllamaChatMessage> chatHistory) {
|
List<OllamaChatMessage> chatHistory) {
|
||||||
super(response, responseTime, httpStatusCode);
|
super(response, responseTime, httpStatusCode);
|
||||||
this.chatHistory = chatHistory;
|
this.chatHistory = chatHistory;
|
||||||
appendAnswerToChatHistory(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OllamaChatMessage> getChatHistory() {
|
public List<OllamaChatMessage> getChatHistory() {
|
||||||
return chatHistory;
|
return chatHistory;
|
||||||
}
|
|
||||||
|
|
||||||
private void appendAnswerToChatHistory(String answer){
|
|
||||||
OllamaChatMessage assistantMessage = new OllamaChatMessage(OllamaChatMessageRole.ASSISTANT, answer);
|
|
||||||
this.chatHistory.add(assistantMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ public class OllamaChatStreamObserver {
|
|||||||
|
|
||||||
private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
|
private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
|
||||||
|
|
||||||
private String message = "";
|
|
||||||
|
|
||||||
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
|
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
|
||||||
this.streamHandler = streamHandler;
|
this.streamHandler = streamHandler;
|
||||||
}
|
}
|
||||||
@@ -23,8 +21,7 @@ public class OllamaChatStreamObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart) {
|
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart) {
|
||||||
message = message + currentResponsePart.getMessage().getContent();
|
streamHandler.accept(currentResponsePart.getMessage().getContent());
|
||||||
streamHandler.accept(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user