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(
3737 message.content + = delta
3838 finishReason = if (json[" finish_reason" ].isJsonNull) null else FinishReason .valueOf(json[" finish_reason" ].asString.uppercase())
3939 }
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
4047}
4148
4249/*
Original file line number Diff line number Diff line change 11package com.cjcrafter.openai.completions
22
33import com.cjcrafter.openai.FinishReason
4+ import com.cjcrafter.openai.chat.ChatChoiceChunk
45import com.google.gson.annotations.SerializedName
56
67/* *
@@ -25,4 +26,10 @@ data class CompletionChoiceChunk(
2526 val index : Int ,
2627 val logprobs : List <Float >? ,
2728 @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