All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.justai.jaicf.activator.caila.slotfilling.CailaSlotFillingContext.kt Maven / Gradle / Ivy

Go to download

JAICF-Kotlin Caila NLU Activator Adapter. Provides intent recognition and named entity extraction.

There is a newer version: 1.3.8
Show newest version
package com.justai.jaicf.activator.caila.slotfilling

import com.justai.jaicf.activator.caila.caila
import com.justai.jaicf.activator.caila.dto.CailaEntityMarkupData
import com.justai.jaicf.activator.caila.dto.CailaKnownSlotData
import com.justai.jaicf.activator.caila.dto.CailaSlotData
import com.justai.jaicf.context.ActivatorContext
import java.io.Serializable


internal data class CailaSlotFillingContext(
    val initialActivatorContext: ActivatorContext,
    val slots: List,
    val knownSlots: MutableList,
    val knownEntities: MutableList,
    val maxRetries: MutableMap = HashMap()
) : Serializable {
    companion object Factory {
        fun createInitial(initial: ActivatorContext): CailaSlotFillingContext {
            val knownSlots = initial.caila?.result?.inference?.variants?.get(0)?.slots?.toMutableList()
                ?: mutableListOf()
            val knownEntities = initial.caila?.entities?.toMutableList()
                ?: mutableListOf()
            val requiredSlots = initial.caila?.topIntent?.slots?.toMutableList()
                ?: mutableListOf()
            val maxRetries = initial.caila?.topIntent?.slots?.map { it.name to 0 }?.toMap()?.toMutableMap()
                ?: mutableMapOf()

            return CailaSlotFillingContext(
                initialActivatorContext = initial,
                knownSlots = knownSlots,
                knownEntities = knownEntities,
                slots = requiredSlots,
                maxRetries = maxRetries
            )
        }

        private const val serialVersionUID = 6691290642221965774L
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy