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
private
final
List<OllamaChatMessage> chatHistory;
18
19
private
final
OllamaChatResponseModel
responseModel;
20
21
public
OllamaChatResult
(
OllamaChatResponseModel
responseModel, List<OllamaChatMessage> chatHistory) {
22
this.chatHistory = chatHistory;
23
this.responseModel = responseModel;
24
appendAnswerToChatHistory(responseModel);
25
}
26
27
private
void
appendAnswerToChatHistory(
OllamaChatResponseModel
response
) {
28
this.chatHistory.add(
response
.getMessage());
29
}
30
31
@Override
32
public
String
toString
() {
33
try
{
34
return
getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(
this
);
35
}
catch
(JsonProcessingException e) {
36
throw
new
RuntimeException(e);
37
}
38
}
39
40
@Deprecated
41
public
String
getResponse
(){
42
return
responseModel !=
null
? responseModel.getMessage().getContent() :
""
;
43
}
44
45
@Deprecated
46
public
int
getHttpStatusCode
(){
47
return
200;
48
}
49
50
@Deprecated
51
public
long
getResponseTime
(){
52
return
responseModel !=
null
? responseModel.getTotalDuration() : 0L;
53
}
54
}
io.github.ollama4j.models.chat.OllamaChatResponseModel
Definition
OllamaChatResponseModel.java:9
io.github.ollama4j.models.chat.OllamaChatResult.getHttpStatusCode
int getHttpStatusCode()
Definition
OllamaChatResult.java:46
io.github.ollama4j.models.chat.OllamaChatResult.getResponseTime
long getResponseTime()
Definition
OllamaChatResult.java:51
io.github.ollama4j.models.chat.OllamaChatResult.OllamaChatResult
OllamaChatResult(OllamaChatResponseModel responseModel, List< OllamaChatMessage > chatHistory)
Definition
OllamaChatResult.java:21
io.github.ollama4j.models.chat.OllamaChatResult.toString
String toString()
Definition
OllamaChatResult.java:32
io.github.ollama4j.models.chat.OllamaChatResult.getResponse
String getResponse()
Definition
OllamaChatResult.java:41
io.github.ollama4j.models.response
Definition
LibraryModel.java:1
src
main
java
io
github
ollama4j
models
chat
OllamaChatResult.java
Generated by
1.13.2