Closed
Description
I have the following code:
val completions: Flow<ChatCompletionChunk> = ai!!.chatCompletions(chatCompletionRequest)
completions.collect { v ->
run {
if (stopper) {
stopper = false
return@collect
}
if (v.choices[0].delta.content != "null") {
response += v.choices[0].delta.content
if (response != "null") {
messages[messages.size - 1]["message"] = response
adapter?.notifyDataSetChanged()
saveSettings()
}
}
}
}
I want to stop completions when user clicked a button. I tried to do this using stopper variable but id doesn't work. It there any official API solution to do this?