Skip to content

[Stop chat completions] #329

Closed
Closed
@AndraxDev

Description

@AndraxDev

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions