Am I doing something wrong? Is there any other way to stop the process of generation? Thanks
Library version: 1.0.2-beta
Android OS. No matter what Android version I use.
private suspend fun generateCompletionCancellable(
messages: List<ChatMessage>,
params: CactusCompletionParams,
onToken: (String) -> Unit
): CactusCompletionResult? = suspendCancellableCoroutine { cont ->
val workerJob = SupervisorJob()
val workerScope = CoroutineScope(Dispatchers.IO + workerJob)
workerScope.launch {
try {
cactusLM.generateCompletion(
messages = messages,
params = params,
onToken = { token, _ ->
Log.d("debug", "cactusLM token: $token")
if (!isActive) return@generateCompletion
onToken(token)
}
)
try {
cont.resume(result)
} catch (_: Throwable) {
}
} catch (t: Throwable) {
try {
cont.resumeWithException(t)
} catch (_: Throwable) {
}
}
}
cont.invokeOnCancellation {
workerJob.cancel()
Log.d("debug", "cactusLM token: cancel the job")
}
}
From logs

Am I doing something wrong? Is there any other way to stop the process of generation? Thanks
Library version: 1.0.2-beta
Android OS. No matter what Android version I use.
From logs