Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaChatResult.java
Go to the documentation of this file.
1
/*
2
* Ollama4j - Java library for interacting with Ollama server.
3
* Copyright (c) 2025 Amith Koujalgi and contributors.
4
*
5
* Licensed under the MIT License (the "License");
6
* you may not use this file except in compliance with the License.
7
*
8
*/
9
package
io.github.ollama4j.models.chat;
10
11
import
static
io.github.ollama4j.utils.Utils.getObjectMapper;
12
13
import
com.fasterxml.jackson.core.JsonProcessingException;
14
import
java.util.List;
15
import
lombok.Getter;
16
21
@Getter
22
public
class
OllamaChatResult
{
23
24
private
final
List<OllamaChatMessage> chatHistory;
25
26
private
final
OllamaChatResponseModel
responseModel;
27
28
public
OllamaChatResult
(
29
OllamaChatResponseModel
responseModel, List<OllamaChatMessage> chatHistory) {
30
this.chatHistory = chatHistory;
31
this.responseModel = responseModel;
32
appendAnswerToChatHistory(responseModel);
33
}
34
35
private
void
appendAnswerToChatHistory(
OllamaChatResponseModel
response) {
36
this.chatHistory.add(response.getMessage());
37
}
38
39
@Override
40
public
String
toString
() {
41
try
{
42
return
getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(
this
);
43
}
catch
(JsonProcessingException e) {
44
throw
new
RuntimeException(e);
45
}
46
}
47
}
io.github.ollama4j.models.chat.OllamaChatResponseModel
Definition
OllamaChatResponseModel.java:18
io.github.ollama4j.models.chat.OllamaChatResult
Definition
OllamaChatResult.java:22
io.github.ollama4j.models.chat.OllamaChatResult.OllamaChatResult
OllamaChatResult(OllamaChatResponseModel responseModel, List< OllamaChatMessage > chatHistory)
Definition
OllamaChatResult.java:28
io.github.ollama4j.models.chat.OllamaChatResult.toString
String toString()
Definition
OllamaChatResult.java:40
src
main
java
io
github
ollama4j
models
chat
OllamaChatResult.java
Generated by
1.12.0