File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/main/kotlin/com/cjcrafter/openai Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ data class ChatChoiceChunk(
37
37
message.content + = delta
38
38
finishReason = if (json[" finish_reason" ].isJsonNull) null else FinishReason .valueOf(json[" finish_reason" ].asString.uppercase())
39
39
}
40
+
41
+ /* *
42
+ * Returns `true` if this message chunk is complete. Once complete, no more
43
+ * tokens will be generated, and [ChatChoiceChunk.message] will contain the
44
+ * complete message.
45
+ */
46
+ fun isFinished () = finishReason != null
40
47
}
41
48
42
49
/*
Original file line number Diff line number Diff line change 1
1
package com.cjcrafter.openai.completions
2
2
3
3
import com.cjcrafter.openai.FinishReason
4
+ import com.cjcrafter.openai.chat.ChatChoiceChunk
4
5
import com.google.gson.annotations.SerializedName
5
6
6
7
/* *
@@ -25,4 +26,10 @@ data class CompletionChoiceChunk(
25
26
val index : Int ,
26
27
val logprobs : List <Float >? ,
27
28
@field:SerializedName("finish_reason") val finishReason : FinishReason ?
28
- )
29
+ ) {
30
+ /* *
31
+ * Returns `true` if this message chunk is complete. Once complete, no more
32
+ * tokens will be generated.
33
+ */
34
+ fun isFinished () = finishReason != null
35
+ }
You can’t perform that action at this time.
0 commit comments