Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaChatResult.java
Go to the documentation of this file.
1
package
io.github.ollama4j.models.chat;
2
3
import
java.util.List;
4
5
import
com.fasterxml.jackson.core.JsonProcessingException;
6
import
lombok.Getter;
7
8
import
static
io.github.ollama4j.utils.Utils.getObjectMapper;
9
14
@Getter
15
public
class
OllamaChatResult
{
16
17
18
private
List<OllamaChatMessage> chatHistory;
19
20
private
OllamaChatResponseModel
responseModel;
21
22
public
OllamaChatResult
(
OllamaChatResponseModel
responseModel, List<OllamaChatMessage> chatHistory) {
23
this.chatHistory = chatHistory;
24
this.responseModel = responseModel;
25
appendAnswerToChatHistory(responseModel);
26
}
27
28
private
void
appendAnswerToChatHistory(
OllamaChatResponseModel
response
) {
29
this.chatHistory.add(
response
.getMessage());
30
}
31
32
@Override
33
public
String
toString
() {
34
try
{
35
return
getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(
this
);
36
}
catch
(JsonProcessingException e) {
37
throw
new
RuntimeException(e);
38
}
39
}
40
41
@Deprecated
42
public
String
getResponse
(){
43
return
responseModel !=
null
? responseModel.getMessage().getContent() :
""
;
44
}
45
46
@Deprecated
47
public
int
getHttpStatusCode
(){
48
return
200;
49
}
50
51
@Deprecated
52
public
long
getResponseTime
(){
53
return
responseModel !=
null
? responseModel.getTotalDuration() : 0L;
54
}
55
}
io.github.ollama4j.models.chat.OllamaChatResponseModel
Definition
OllamaChatResponseModel.java:9
io.github.ollama4j.models.chat.OllamaChatResult.getHttpStatusCode
int getHttpStatusCode()
Definition
OllamaChatResult.java:47
io.github.ollama4j.models.chat.OllamaChatResult.getResponseTime
long getResponseTime()
Definition
OllamaChatResult.java:52
io.github.ollama4j.models.chat.OllamaChatResult.OllamaChatResult
OllamaChatResult(OllamaChatResponseModel responseModel, List< OllamaChatMessage > chatHistory)
Definition
OllamaChatResult.java:22
io.github.ollama4j.models.chat.OllamaChatResult.toString
String toString()
Definition
OllamaChatResult.java:33
io.github.ollama4j.models.chat.OllamaChatResult.getResponse
String getResponse()
Definition
OllamaChatResult.java:42
io.github.ollama4j.models.response
Definition
LibraryModel.java:1
src
main
java
io
github
ollama4j
models
chat
OllamaChatResult.java
Generated by
1.13.2