forked from kherud/java-llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathChatChoice.java
More file actions
53 lines (46 loc) · 1.39 KB
/
Copy pathChatChoice.java
File metadata and controls
53 lines (46 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
//
// SPDX-License-Identifier: MIT
package net.ladenthin.llama;
/**
* One choice in a chat completion response: the assistant message and the finish reason.
* Mirrors the OpenAI {@code choices[i]} object.
*/
public final class ChatChoice {
private final int index;
private final ChatMessage message;
private final String finishReason;
/**
* Construct a chat choice.
*
* @param index the index in the choices array
* @param message the assistant's message for this choice
* @param finishReason the finish reason (e.g. {@code "stop"}, {@code "length"}, {@code "tool_calls"})
*/
public ChatChoice(int index, ChatMessage message, String finishReason) {
this.index = index;
this.message = message;
this.finishReason = finishReason;
}
/**
* Choice index.
* @return the integer index in the choices array
*/
public int getIndex() {
return index;
}
/**
* Assistant message accessor.
* @return the assistant's reply (may include tool_calls)
*/
public ChatMessage getMessage() {
return message;
}
/**
* Finish reason accessor.
* @return the OAI finish reason string, or {@code ""} if absent
*/
public String getFinishReason() {
return finishReason;
}
}