From 8b20be4a762d1aaa5ac6843df5e6ff2ae13370f4 Mon Sep 17 00:00:00 2001 From: scezen Date: Mon, 10 Feb 2025 12:29:07 +0100 Subject: [PATCH 01/12] withAnnotations bool --- .../server/src/main/kotlin/model/DialogsSearchQuery.kt | 6 ++++-- .../src/main/kotlin/admin/dialog/DialogReportQuery.kt | 4 +++- bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt index 1c6a1dcb21..bb87c24885 100644 --- a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt +++ b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt @@ -36,7 +36,8 @@ data class DialogsSearchQuery( val ratings: Set = emptySet(), val applicationId: String?, val intentsToHide: Set = emptySet(), - val isGenAiRagDialog: Boolean? + val isGenAiRagDialog: Boolean?, + val withAnnotations: Boolean?, ) : PaginatedQuery() { fun toDialogReportQuery(): DialogReportQuery { @@ -57,7 +58,8 @@ data class DialogsSearchQuery( ratings = ratings, applicationId = applicationId, intentsToHide = intentsToHide, - isGenAiRagDialog = isGenAiRagDialog + isGenAiRagDialog = isGenAiRagDialog, + withAnnotations = withAnnotations, ) } } diff --git a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt index ce6c4e7df9..1275c4dc84 100644 --- a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt +++ b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt @@ -60,5 +60,7 @@ data class DialogReportQuery( val intentsToHide : Set = emptySet(), - val isGenAiRagDialog: Boolean? = null + val isGenAiRagDialog: Boolean? = null, + + val withAnnotations: Boolean? = null ) diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index 23273eb861..7620ec349c 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -597,7 +597,10 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep if (query.intentName.isNullOrBlank()) null else Stories.currentIntent.name_ eq query.intentName, if (query.ratings.isNotEmpty()) DialogCol_.Rating `in` query.ratings.toSet() else null, if (query.applicationId.isNullOrBlank()) null else DialogCol_.ApplicationIds `in` setOf( query.applicationId), - if (query.isGenAiRagDialog == true) Stories.actions.botMetadata.isGenAiRagAnswer eq true else null + if (query.isGenAiRagDialog == true) Stories.actions.botMetadata.isGenAiRagAnswer eq true else null, + //if (query.withAnnotations == true) Stories.actions.annotation ne null else null + //if (query.withAnnotations == null || query.withAnnotations == false) null else Stories.actions.annotation null + if (query.withAnnotations == true) Stories.actions.annotation. true else null ) logger.debug { "dialog search query: $filter" } val c = dialogCol.withReadPreference(secondaryPreferred()) From 8971f4da42f25e1d7c478d7b85daea46c98db07b Mon Sep 17 00:00:00 2001 From: Mohamed ASSOUKTI Date: Mon, 10 Feb 2025 16:51:56 +0100 Subject: [PATCH 02/12] [DERCBOT-1329] Fix annotation filter --- .../kotlin/admin/annotation/BotAnnotation.kt | 3 - .../src/main/kotlin/BotDataRegistry.kt | 4 +- .../src/main/kotlin/UserTimelineMongoDAO.kt | 7 +- .../bot/admin/annotation/BotAnnotation_.kt | 123 ++++++++++++++++ .../ai/tock/bot/mongo/ActionMongoWrapper_.kt | 17 ++- .../shared/config/FaqSettings_Deserializer.kt | 131 ------------------ .../shared/config/FaqSettings_Serializer.kt | 41 ------ 7 files changed, 143 insertions(+), 183 deletions(-) create mode 100644 bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/admin/annotation/BotAnnotation_.kt delete mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt delete mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt diff --git a/bot/engine/src/main/kotlin/admin/annotation/BotAnnotation.kt b/bot/engine/src/main/kotlin/admin/annotation/BotAnnotation.kt index 73d3975a68..e728b873b4 100644 --- a/bot/engine/src/main/kotlin/admin/annotation/BotAnnotation.kt +++ b/bot/engine/src/main/kotlin/admin/annotation/BotAnnotation.kt @@ -17,12 +17,9 @@ package ai.tock.bot.admin.annotation -import org.litote.kmongo.Id -import org.litote.kmongo.newId import java.time.Instant data class BotAnnotation( - val _id: Id = newId(), var state: BotAnnotationState, var reason: BotAnnotationReasonType?, var description: String, diff --git a/bot/storage-mongo/src/main/kotlin/BotDataRegistry.kt b/bot/storage-mongo/src/main/kotlin/BotDataRegistry.kt index 7cd6cdaf33..f0d8090f6e 100644 --- a/bot/storage-mongo/src/main/kotlin/BotDataRegistry.kt +++ b/bot/storage-mongo/src/main/kotlin/BotDataRegistry.kt @@ -16,6 +16,7 @@ package ai.tock.bot.mongo +import ai.tock.bot.admin.annotation.BotAnnotation import ai.tock.bot.admin.bot.BotApplicationConfiguration import ai.tock.bot.admin.bot.BotConfiguration import ai.tock.bot.admin.story.StoryDefinitionConfiguration @@ -49,7 +50,8 @@ import org.litote.kmongo.DataRegistry PlayerId::class, EventState::class, ConnectorType::class, - ActionMetadata::class + ActionMetadata::class, + BotAnnotation::class ] ) @JacksonDataRegistry( diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index 7620ec349c..7089022902 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -63,9 +63,6 @@ import com.mongodb.client.model.ReplaceOptions import mu.KotlinLogging import org.litote.kmongo.* import org.litote.kmongo.MongoOperator.* -import kotlinx.coroutines.newSingleThreadContext -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext import java.time.Instant import java.time.Instant.now import java.time.ZoneOffset @@ -598,9 +595,7 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep if (query.ratings.isNotEmpty()) DialogCol_.Rating `in` query.ratings.toSet() else null, if (query.applicationId.isNullOrBlank()) null else DialogCol_.ApplicationIds `in` setOf( query.applicationId), if (query.isGenAiRagDialog == true) Stories.actions.botMetadata.isGenAiRagAnswer eq true else null, - //if (query.withAnnotations == true) Stories.actions.annotation ne null else null - //if (query.withAnnotations == null || query.withAnnotations == false) null else Stories.actions.annotation null - if (query.withAnnotations == true) Stories.actions.annotation. true else null + if (query.withAnnotations == true) Stories.actions.annotation.state `in` BotAnnotationState.entries else null ) logger.debug { "dialog search query: $filter" } val c = dialogCol.withReadPreference(secondaryPreferred()) diff --git a/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/admin/annotation/BotAnnotation_.kt b/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/admin/annotation/BotAnnotation_.kt new file mode 100644 index 0000000000..8c26cb0c21 --- /dev/null +++ b/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/admin/annotation/BotAnnotation_.kt @@ -0,0 +1,123 @@ +package ai.tock.bot.admin.annotation + +import java.time.Instant +import kotlin.String +import kotlin.Suppress +import kotlin.collections.Collection +import kotlin.collections.List +import kotlin.collections.Map +import kotlin.reflect.KProperty1 +import org.litote.kmongo.property.KCollectionPropertyPath +import org.litote.kmongo.property.KCollectionSimplePropertyPath +import org.litote.kmongo.property.KMapPropertyPath +import org.litote.kmongo.property.KPropertyPath + +private val __State: KProperty1 + get() = BotAnnotation::state +private val __Reason: KProperty1 + get() = BotAnnotation::reason +private val __Description: KProperty1 + get() = BotAnnotation::description +private val __GroundTruth: KProperty1 + get() = BotAnnotation::groundTruth +private val __Events: KProperty1?> + get() = BotAnnotation::events +private val __CreationDate: KProperty1 + get() = BotAnnotation::creationDate +private val __LastUpdateDate: KProperty1 + get() = BotAnnotation::lastUpdateDate +class BotAnnotation_(previous: KPropertyPath?, property: KProperty1<*, BotAnnotation?>) : + KPropertyPath(previous,property) { + val state: KPropertyPath + get() = KPropertyPath(this,__State) + + val reason: KPropertyPath + get() = KPropertyPath(this,__Reason) + + val description: KPropertyPath + get() = KPropertyPath(this,__Description) + + val groundTruth: KPropertyPath + get() = KPropertyPath(this,__GroundTruth) + + val events: KCollectionSimplePropertyPath + get() = KCollectionSimplePropertyPath(this,BotAnnotation::events) + + val creationDate: KPropertyPath + get() = KPropertyPath(this,__CreationDate) + + val lastUpdateDate: KPropertyPath + get() = KPropertyPath(this,__LastUpdateDate) + + companion object { + val State: KProperty1 + get() = __State + val Reason: KProperty1 + get() = __Reason + val Description: KProperty1 + get() = __Description + val GroundTruth: KProperty1 + get() = __GroundTruth + val Events: KCollectionSimplePropertyPath + get() = KCollectionSimplePropertyPath(null, __Events) + val CreationDate: KProperty1 + get() = __CreationDate + val LastUpdateDate: KProperty1 + get() = __LastUpdateDate} +} + +class BotAnnotation_Col(previous: KPropertyPath?, property: KProperty1<*, + Collection?>) : KCollectionPropertyPath>(previous,property) { + val state: KPropertyPath + get() = KPropertyPath(this,__State) + + val reason: KPropertyPath + get() = KPropertyPath(this,__Reason) + + val description: KPropertyPath + get() = KPropertyPath(this,__Description) + + val groundTruth: KPropertyPath + get() = KPropertyPath(this,__GroundTruth) + + val events: KCollectionSimplePropertyPath + get() = KCollectionSimplePropertyPath(this,BotAnnotation::events) + + val creationDate: KPropertyPath + get() = KPropertyPath(this,__CreationDate) + + val lastUpdateDate: KPropertyPath + get() = KPropertyPath(this,__LastUpdateDate) + + @Suppress("UNCHECKED_CAST") + override fun memberWithAdditionalPath(additionalPath: String): BotAnnotation_ = + BotAnnotation_(this, customProperty(this, additionalPath))} + +class BotAnnotation_Map(previous: KPropertyPath?, property: KProperty1<*, Map?>) : KMapPropertyPath>(previous,property) { + val state: KPropertyPath + get() = KPropertyPath(this,__State) + + val reason: KPropertyPath + get() = KPropertyPath(this,__Reason) + + val description: KPropertyPath + get() = KPropertyPath(this,__Description) + + val groundTruth: KPropertyPath + get() = KPropertyPath(this,__GroundTruth) + + val events: KCollectionSimplePropertyPath + get() = KCollectionSimplePropertyPath(this,BotAnnotation::events) + + val creationDate: KPropertyPath + get() = KPropertyPath(this,__CreationDate) + + val lastUpdateDate: KPropertyPath + get() = KPropertyPath(this,__LastUpdateDate) + + @Suppress("UNCHECKED_CAST") + override fun memberWithAdditionalPath(additionalPath: String): BotAnnotation_ = + BotAnnotation_(this, customProperty(this, additionalPath))} diff --git a/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/mongo/ActionMongoWrapper_.kt b/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/mongo/ActionMongoWrapper_.kt index c013b6ea24..f7702b7785 100644 --- a/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/mongo/ActionMongoWrapper_.kt +++ b/bot/storage-mongo/target/generated-sources/kapt/compile/ai/tock/bot/mongo/ActionMongoWrapper_.kt @@ -1,5 +1,7 @@ package ai.tock.bot.mongo +import ai.tock.bot.admin.annotation.BotAnnotation +import ai.tock.bot.admin.annotation.BotAnnotation_ import ai.tock.bot.engine.action.Action import ai.tock.bot.engine.action.ActionMetadata import ai.tock.bot.engine.action.ActionMetadata_ @@ -32,6 +34,8 @@ private val __RecipientId: KProperty1 get() = DialogCol.ActionMongoWrapper::recipientId private val __ApplicationId: KProperty1 get() = DialogCol.ActionMongoWrapper::applicationId +private val __Annotation: KProperty1 + get() = DialogCol.ActionMongoWrapper::annotation internal open class ActionMongoWrapper_(previous: KPropertyPath?, property: KProperty1<*, DialogCol.ActionMongoWrapper?>) : KPropertyPath(previous,property) { @@ -56,6 +60,9 @@ internal open class ActionMongoWrapper_(previous: KPropertyPath?, prope val applicationId: KPropertyPath get() = KPropertyPath(this,__ApplicationId) + val annotation: BotAnnotation_ + get() = BotAnnotation_(this,DialogCol.ActionMongoWrapper::annotation) + companion object { val Id: KProperty1?> get() = __Id @@ -70,7 +77,9 @@ internal open class ActionMongoWrapper_(previous: KPropertyPath?, prope val RecipientId: PlayerId_ get() = PlayerId_(null,__RecipientId) val ApplicationId: KProperty1 - get() = __ApplicationId} + get() = __ApplicationId + val Annotation: BotAnnotation_ + get() = BotAnnotation_(null,__Annotation)} } internal open class ActionMongoWrapper_Col(previous: KPropertyPath?, property: @@ -97,6 +106,9 @@ internal open class ActionMongoWrapper_Col(previous: KPropertyPath?, pr val applicationId: KPropertyPath get() = KPropertyPath(this,__ApplicationId) + val annotation: BotAnnotation_ + get() = BotAnnotation_(this,DialogCol.ActionMongoWrapper::annotation) + @Suppress("UNCHECKED_CAST") override fun memberWithAdditionalPath(additionalPath: String): ActionMongoWrapper_ = ActionMongoWrapper_(this, customProperty(this, additionalPath))} @@ -125,6 +137,9 @@ internal open class ActionMongoWrapper_Map(previous: KPropertyPath?, val applicationId: KPropertyPath get() = KPropertyPath(this,__ApplicationId) + val annotation: BotAnnotation_ + get() = BotAnnotation_(this,DialogCol.ActionMongoWrapper::annotation) + @Suppress("UNCHECKED_CAST") override fun memberWithAdditionalPath(additionalPath: String): ActionMongoWrapper_ = ActionMongoWrapper_(this, customProperty(this, additionalPath))} diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt deleted file mode 100644 index 937abc9462..0000000000 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt +++ /dev/null @@ -1,131 +0,0 @@ -package ai.tock.nlp.front.shared.config - -import com.fasterxml.jackson.core.JsonParser -import com.fasterxml.jackson.core.JsonToken -import com.fasterxml.jackson.core.type.TypeReference -import com.fasterxml.jackson.databind.DeserializationContext -import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.module.SimpleModule -import java.time.Instant -import kotlin.Boolean -import kotlin.String -import kotlin.collections.Map -import kotlin.reflect.KFunction -import kotlin.reflect.KParameter -import kotlin.reflect.full.findParameterByName -import kotlin.reflect.full.primaryConstructor -import org.litote.jackson.JacksonModuleServiceLoader -import org.litote.kmongo.Id - -internal class FaqSettings_Deserializer : JsonDeserializer(), - JacksonModuleServiceLoader { - override fun module() = SimpleModule().addDeserializer(FaqSettings::class.java, this) - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FaqSettings { - with(p) { - var __id_: Id? = null - var __id_set : Boolean = false - var _applicationId_: Id? = null - var _applicationId_set : Boolean = false - var _satisfactionEnabled_: Boolean? = null - var _satisfactionEnabled_set : Boolean = false - var _satisfactionStoryId_: String? = null - var _satisfactionStoryId_set : Boolean = false - var _creationDate_: Instant? = null - var _creationDate_set : Boolean = false - var _updateDate_: Instant? = null - var _updateDate_set : Boolean = false - var _token_ : JsonToken? = currentToken - while (_token_?.isStructEnd != true) { - if(_token_ != JsonToken.FIELD_NAME) { - _token_ = nextToken() - if (_token_?.isStructEnd == true) break - } - - val _fieldName_ = currentName - _token_ = nextToken() - when (_fieldName_) { - "_id" -> { - __id_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(__id__reference); - __id_set = true - } - "applicationId" -> { - _applicationId_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(_applicationId__reference); - _applicationId_set = true - } - "satisfactionEnabled" -> { - _satisfactionEnabled_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.booleanValue; - _satisfactionEnabled_set = true - } - "satisfactionStoryId" -> { - _satisfactionStoryId_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.text; - _satisfactionStoryId_set = true - } - "creationDate" -> { - _creationDate_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(Instant::class.java); - _creationDate_set = true - } - "updateDate" -> { - _updateDate_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(Instant::class.java); - _updateDate_set = true - } - else -> { - if (_token_?.isStructStart == true) - p.skipChildren() - nextToken() - } - } - _token_ = currentToken - } - return if(__id_set && _applicationId_set && _satisfactionEnabled_set && - _satisfactionStoryId_set && _creationDate_set && _updateDate_set) - FaqSettings(_id = __id_!!, applicationId = _applicationId_!!, - satisfactionEnabled = _satisfactionEnabled_!!, satisfactionStoryId = - _satisfactionStoryId_, creationDate = _creationDate_!!, updateDate = - _updateDate_!!) - else { - val map = mutableMapOf() - if(__id_set) - map[parameters.getValue("_id")] = __id_ - if(_applicationId_set) - map[parameters.getValue("applicationId")] = _applicationId_ - if(_satisfactionEnabled_set) - map[parameters.getValue("satisfactionEnabled")] = _satisfactionEnabled_ - if(_satisfactionStoryId_set) - map[parameters.getValue("satisfactionStoryId")] = _satisfactionStoryId_ - if(_creationDate_set) - map[parameters.getValue("creationDate")] = _creationDate_ - if(_updateDate_set) - map[parameters.getValue("updateDate")] = _updateDate_ - primaryConstructor.callBy(map) - } - } - } - - companion object { - private val primaryConstructor: KFunction by - lazy(LazyThreadSafetyMode.PUBLICATION) { FaqSettings::class.primaryConstructor!! } - - private val parameters: Map by lazy(LazyThreadSafetyMode.PUBLICATION) { - kotlin.collections.mapOf("_id" to primaryConstructor.findParameterByName("_id")!!, - "applicationId" to primaryConstructor.findParameterByName("applicationId")!!, - "satisfactionEnabled" to - primaryConstructor.findParameterByName("satisfactionEnabled")!!, - "satisfactionStoryId" to - primaryConstructor.findParameterByName("satisfactionStoryId")!!, "creationDate" to - primaryConstructor.findParameterByName("creationDate")!!, "updateDate" to - primaryConstructor.findParameterByName("updateDate")!!) } - - private val __id__reference: TypeReference> = object : - TypeReference>() {} - - private val _applicationId__reference: TypeReference> = object : - TypeReference>() {} - } -} diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt deleted file mode 100644 index fa8aecf7af..0000000000 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt +++ /dev/null @@ -1,41 +0,0 @@ -package ai.tock.nlp.front.shared.config - -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.module.SimpleModule -import com.fasterxml.jackson.databind.ser.std.StdSerializer -import org.litote.jackson.JacksonModuleServiceLoader - -internal class FaqSettings_Serializer : StdSerializer(FaqSettings::class.java), - JacksonModuleServiceLoader { - override fun module() = SimpleModule().addSerializer(FaqSettings::class.java, this) - - override fun serialize( - value: FaqSettings, - gen: JsonGenerator, - serializers: SerializerProvider - ) { - gen.writeStartObject() - gen.writeFieldName("_id") - val __id_ = value._id - serializers.defaultSerializeValue(__id_, gen) - gen.writeFieldName("applicationId") - val _applicationId_ = value.applicationId - serializers.defaultSerializeValue(_applicationId_, gen) - gen.writeFieldName("satisfactionEnabled") - val _satisfactionEnabled_ = value.satisfactionEnabled - gen.writeBoolean(_satisfactionEnabled_) - gen.writeFieldName("satisfactionStoryId") - val _satisfactionStoryId_ = value.satisfactionStoryId - if(_satisfactionStoryId_ == null) { gen.writeNull() } else { - gen.writeString(_satisfactionStoryId_) - } - gen.writeFieldName("creationDate") - val _creationDate_ = value.creationDate - serializers.defaultSerializeValue(_creationDate_, gen) - gen.writeFieldName("updateDate") - val _updateDate_ = value.updateDate - serializers.defaultSerializeValue(_updateDate_, gen) - gen.writeEndObject() - } -} From acd9b0999d30763e0a4ad7e68628ee89880be777 Mon Sep 17 00:00:00 2001 From: scezen Date: Tue, 11 Feb 2025 10:22:51 +0100 Subject: [PATCH 03/12] Filter by annotation presence, by cumulative state, by cumulative reason --- .../server/src/main/kotlin/model/DialogsSearchQuery.kt | 6 ++++++ .../src/main/kotlin/admin/dialog/DialogReportQuery.kt | 6 +++++- bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt index bb87c24885..87baaedc96 100644 --- a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt +++ b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt @@ -16,6 +16,8 @@ package ai.tock.bot.admin.model +import ai.tock.bot.admin.annotation.BotAnnotationReasonType +import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.admin.dialog.DialogReportQuery import ai.tock.bot.connector.ConnectorType import ai.tock.bot.engine.user.PlayerId @@ -38,6 +40,8 @@ data class DialogsSearchQuery( val intentsToHide: Set = emptySet(), val isGenAiRagDialog: Boolean?, val withAnnotations: Boolean?, + val annotationStates: Set = emptySet(), + val annotationReasons: Set = emptySet() ) : PaginatedQuery() { fun toDialogReportQuery(): DialogReportQuery { @@ -60,6 +64,8 @@ data class DialogsSearchQuery( intentsToHide = intentsToHide, isGenAiRagDialog = isGenAiRagDialog, withAnnotations = withAnnotations, + annotationStates = annotationStates, + annotationReasons = annotationReasons ) } } diff --git a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt index 1275c4dc84..d8aac04c78 100644 --- a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt +++ b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt @@ -16,6 +16,8 @@ package ai.tock.bot.admin.dialog +import ai.tock.bot.admin.annotation.BotAnnotationReasonType +import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.connector.ConnectorType import ai.tock.bot.engine.user.PlayerId import java.time.ZonedDateTime @@ -62,5 +64,7 @@ data class DialogReportQuery( val isGenAiRagDialog: Boolean? = null, - val withAnnotations: Boolean? = null + val withAnnotations: Boolean? = null, + val annotationStates: Set = emptySet(), + val annotationReasons: Set = emptySet() ) diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index 7089022902..bdeb7f99f0 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -595,7 +595,9 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep if (query.ratings.isNotEmpty()) DialogCol_.Rating `in` query.ratings.toSet() else null, if (query.applicationId.isNullOrBlank()) null else DialogCol_.ApplicationIds `in` setOf( query.applicationId), if (query.isGenAiRagDialog == true) Stories.actions.botMetadata.isGenAiRagAnswer eq true else null, - if (query.withAnnotations == true) Stories.actions.annotation.state `in` BotAnnotationState.entries else null + if (query.withAnnotations == true) Stories.actions.annotation.state `in` BotAnnotationState.entries else null, + if (query.annotationStates.isNotEmpty()) Stories.actions.annotation.state `in` query.annotationStates else null, + if (query.annotationReasons.isNotEmpty()) Stories.actions.annotation.reason `in` query.annotationReasons else null ) logger.debug { "dialog search query: $filter" } val c = dialogCol.withReadPreference(secondaryPreferred()) From 7748fcdb59f6f240c61d7a00d4422a70e136b689 Mon Sep 17 00:00:00 2001 From: scezen Date: Tue, 11 Feb 2025 13:43:02 +0100 Subject: [PATCH 04/12] Sort by annotation lastUpdateDate --- .../src/main/kotlin/model/DialogsSearchQuery.kt | 6 ++++-- .../main/kotlin/admin/dialog/DialogReportQuery.kt | 3 ++- .../src/main/kotlin/UserTimelineMongoDAO.kt | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt index 87baaedc96..8246dd59b8 100644 --- a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt +++ b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt @@ -41,7 +41,8 @@ data class DialogsSearchQuery( val isGenAiRagDialog: Boolean?, val withAnnotations: Boolean?, val annotationStates: Set = emptySet(), - val annotationReasons: Set = emptySet() + val annotationReasons: Set = emptySet(), + val annotationSort: List> = emptyList(), ) : PaginatedQuery() { fun toDialogReportQuery(): DialogReportQuery { @@ -65,7 +66,8 @@ data class DialogsSearchQuery( isGenAiRagDialog = isGenAiRagDialog, withAnnotations = withAnnotations, annotationStates = annotationStates, - annotationReasons = annotationReasons + annotationReasons = annotationReasons, + annotationSort = annotationSort, ) } } diff --git a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt index d8aac04c78..69f04d09a5 100644 --- a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt +++ b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt @@ -66,5 +66,6 @@ data class DialogReportQuery( val withAnnotations: Boolean? = null, val annotationStates: Set = emptySet(), - val annotationReasons: Set = emptySet() + val annotationReasons: Set = emptySet(), + val annotationSort: List> = emptyList(), ) diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index bdeb7f99f0..19413f797c 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -603,10 +603,23 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep val c = dialogCol.withReadPreference(secondaryPreferred()) val count = c.countDocuments(filter, defaultCountOptions) return if (count > start) { + val sortBson = when { + annotationSort.isEmpty() -> descending(LastUpdateDate) + else -> { + val (field, ascending) = annotationSort.first() + when (field) { + "creationDate" -> if (ascending) ascending(LastUpdateDate) else descending(LastUpdateDate) + "annotationDate" -> if (ascending) ascending(Stories.actions.annotation.lastUpdateDate) + else descending(Stories.actions.annotation.lastUpdateDate) + else -> descending(LastUpdateDate) + } + } + } + val list = c.find(filter) .skip(start.toInt()) .limit(size) - .descendingSort(LastUpdateDate) + .sort(sortBson) .run { map { it.toDialogReport() } .toList() From 6704f1b3255f7d095e64ff70a3148da19b569fbe Mon Sep 17 00:00:00 2001 From: scezen Date: Wed, 12 Feb 2025 14:06:48 +0100 Subject: [PATCH 05/12] Filters addition --- .../main/kotlin/model/DialogsSearchQuery.kt | 8 ++++++- .../kotlin/admin/dialog/DialogReportQuery.kt | 5 ++++- .../src/main/kotlin/UserTimelineMongoDAO.kt | 22 ++++++++----------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt index 8246dd59b8..2bac925ba1 100644 --- a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt +++ b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt @@ -17,11 +17,13 @@ package ai.tock.bot.admin.model import ai.tock.bot.admin.annotation.BotAnnotationReasonType +import ai.tock.bot.admin.annotation.BotAnnotationSortDirection import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.admin.dialog.DialogReportQuery import ai.tock.bot.connector.ConnectorType import ai.tock.bot.engine.user.PlayerId import ai.tock.nlp.admin.model.PaginatedQuery +import java.time.ZonedDateTime /** * @@ -42,7 +44,9 @@ data class DialogsSearchQuery( val withAnnotations: Boolean?, val annotationStates: Set = emptySet(), val annotationReasons: Set = emptySet(), - val annotationSort: List> = emptyList(), + val annotationSort: BotAnnotationSortDirection? = null, + val annotationCreationDateFrom: ZonedDateTime? = null, + val annotationCreationDateTo: ZonedDateTime? = null, ) : PaginatedQuery() { fun toDialogReportQuery(): DialogReportQuery { @@ -68,6 +72,8 @@ data class DialogsSearchQuery( annotationStates = annotationStates, annotationReasons = annotationReasons, annotationSort = annotationSort, + annotationCreationDateFrom = annotationCreationDateFrom, + annotationCreationDateTo = annotationCreationDateTo, ) } } diff --git a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt index 69f04d09a5..eaa4a49441 100644 --- a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt +++ b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt @@ -17,6 +17,7 @@ package ai.tock.bot.admin.dialog import ai.tock.bot.admin.annotation.BotAnnotationReasonType +import ai.tock.bot.admin.annotation.BotAnnotationSortDirection import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.connector.ConnectorType import ai.tock.bot.engine.user.PlayerId @@ -67,5 +68,7 @@ data class DialogReportQuery( val withAnnotations: Boolean? = null, val annotationStates: Set = emptySet(), val annotationReasons: Set = emptySet(), - val annotationSort: List> = emptyList(), + val annotationSort: BotAnnotationSortDirection? = null, + val annotationCreationDateFrom: ZonedDateTime? = null, + val annotationCreationDateTo: ZonedDateTime? = null, ) diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index 19413f797c..0b05bcb65a 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -597,25 +597,21 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep if (query.isGenAiRagDialog == true) Stories.actions.botMetadata.isGenAiRagAnswer eq true else null, if (query.withAnnotations == true) Stories.actions.annotation.state `in` BotAnnotationState.entries else null, if (query.annotationStates.isNotEmpty()) Stories.actions.annotation.state `in` query.annotationStates else null, - if (query.annotationReasons.isNotEmpty()) Stories.actions.annotation.reason `in` query.annotationReasons else null + if (query.annotationReasons.isNotEmpty()) Stories.actions.annotation.reason `in` query.annotationReasons else null, + if (annotationCreationDateFrom == null) null + else Stories.actions.annotation.creationDate gt annotationCreationDateFrom?.toInstant(), + if (annotationCreationDateTo == null) null + else Stories.actions.annotation.creationDate lt annotationCreationDateTo?.toInstant(), ) logger.debug { "dialog search query: $filter" } val c = dialogCol.withReadPreference(secondaryPreferred()) val count = c.countDocuments(filter, defaultCountOptions) return if (count > start) { - val sortBson = when { - annotationSort.isEmpty() -> descending(LastUpdateDate) - else -> { - val (field, ascending) = annotationSort.first() - when (field) { - "creationDate" -> if (ascending) ascending(LastUpdateDate) else descending(LastUpdateDate) - "annotationDate" -> if (ascending) ascending(Stories.actions.annotation.lastUpdateDate) - else descending(Stories.actions.annotation.lastUpdateDate) - else -> descending(LastUpdateDate) - } - } + val sortBson = when(annotationSort) { + null -> descending(LastUpdateDate) + BotAnnotationSortDirection.ASC -> ascending(Stories.actions.annotation.lastUpdateDate) + BotAnnotationSortDirection.DESC -> descending(Stories.actions.annotation.lastUpdateDate) } - val list = c.find(filter) .skip(start.toInt()) .limit(size) From 89ee702fe6fa00d04612c86daa5d03f1c2026a81 Mon Sep 17 00:00:00 2001 From: scezen Date: Wed, 12 Feb 2025 16:27:46 +0100 Subject: [PATCH 06/12] Filtering by dialog creationDate & sort by ASC/DESC order --- .../main/kotlin/model/DialogsSearchQuery.kt | 10 ++++-- .../kotlin/admin/dialog/DialogReportQuery.kt | 7 +++-- .../kotlin/engine/dialog/SortDirection.kt | 22 +++++++++++++ .../src/main/kotlin/UserTimelineMongoDAO.kt | 31 ++++++++++++++----- 4 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 bot/engine/src/main/kotlin/engine/dialog/SortDirection.kt diff --git a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt index 2bac925ba1..41d7a868e9 100644 --- a/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt +++ b/bot/admin/server/src/main/kotlin/model/DialogsSearchQuery.kt @@ -17,10 +17,10 @@ package ai.tock.bot.admin.model import ai.tock.bot.admin.annotation.BotAnnotationReasonType -import ai.tock.bot.admin.annotation.BotAnnotationSortDirection import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.admin.dialog.DialogReportQuery import ai.tock.bot.connector.ConnectorType +import ai.tock.bot.engine.dialog.SortDirection import ai.tock.bot.engine.user.PlayerId import ai.tock.nlp.admin.model.PaginatedQuery import java.time.ZonedDateTime @@ -44,9 +44,12 @@ data class DialogsSearchQuery( val withAnnotations: Boolean?, val annotationStates: Set = emptySet(), val annotationReasons: Set = emptySet(), - val annotationSort: BotAnnotationSortDirection? = null, + val annotationSort: SortDirection? = null, + val dialogSort: SortDirection? = null, val annotationCreationDateFrom: ZonedDateTime? = null, val annotationCreationDateTo: ZonedDateTime? = null, + val dialogCreationDateFrom: ZonedDateTime? = null, + val dialogCreationDateTo: ZonedDateTime? = null, ) : PaginatedQuery() { fun toDialogReportQuery(): DialogReportQuery { @@ -72,8 +75,11 @@ data class DialogsSearchQuery( annotationStates = annotationStates, annotationReasons = annotationReasons, annotationSort = annotationSort, + dialogSort = dialogSort, annotationCreationDateFrom = annotationCreationDateFrom, annotationCreationDateTo = annotationCreationDateTo, + dialogCreationDateFrom = dialogCreationDateFrom, + dialogCreationDateTo = dialogCreationDateTo, ) } } diff --git a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt index eaa4a49441..0295d69678 100644 --- a/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt +++ b/bot/engine/src/main/kotlin/admin/dialog/DialogReportQuery.kt @@ -17,9 +17,9 @@ package ai.tock.bot.admin.dialog import ai.tock.bot.admin.annotation.BotAnnotationReasonType -import ai.tock.bot.admin.annotation.BotAnnotationSortDirection import ai.tock.bot.admin.annotation.BotAnnotationState import ai.tock.bot.connector.ConnectorType +import ai.tock.bot.engine.dialog.SortDirection import ai.tock.bot.engine.user.PlayerId import java.time.ZonedDateTime import java.util.Locale @@ -68,7 +68,10 @@ data class DialogReportQuery( val withAnnotations: Boolean? = null, val annotationStates: Set = emptySet(), val annotationReasons: Set = emptySet(), - val annotationSort: BotAnnotationSortDirection? = null, + val annotationSort: SortDirection? = null, + val dialogSort: SortDirection? = null, val annotationCreationDateFrom: ZonedDateTime? = null, val annotationCreationDateTo: ZonedDateTime? = null, + val dialogCreationDateFrom: ZonedDateTime? = null, + val dialogCreationDateTo: ZonedDateTime? = null, ) diff --git a/bot/engine/src/main/kotlin/engine/dialog/SortDirection.kt b/bot/engine/src/main/kotlin/engine/dialog/SortDirection.kt new file mode 100644 index 0000000000..e403530477 --- /dev/null +++ b/bot/engine/src/main/kotlin/engine/dialog/SortDirection.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2017/2021 e-voyageurs technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ai.tock.bot.engine.dialog + +enum class SortDirection { + ASC, + DESC +} \ No newline at end of file diff --git a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt index 0b05bcb65a..638ec9de68 100644 --- a/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt +++ b/bot/storage-mongo/src/main/kotlin/UserTimelineMongoDAO.kt @@ -24,10 +24,7 @@ import ai.tock.bot.definition.BotDefinition import ai.tock.bot.definition.StoryDefinition import ai.tock.bot.engine.action.Action import ai.tock.bot.engine.action.SendSentence -import ai.tock.bot.engine.dialog.ArchivedEntityValue -import ai.tock.bot.engine.dialog.Dialog -import ai.tock.bot.engine.dialog.EntityStateValue -import ai.tock.bot.engine.dialog.Snapshot +import ai.tock.bot.engine.dialog.* import ai.tock.bot.engine.nlp.NlpCallStats import ai.tock.bot.engine.nlp.NlpStats import ai.tock.bot.engine.user.PlayerId @@ -47,6 +44,7 @@ import ai.tock.bot.mongo.DialogTextCol_.Companion.Text import ai.tock.bot.mongo.MongoBotConfiguration.database import ai.tock.bot.mongo.NlpStatsCol_.Companion.AppNamespace import ai.tock.bot.mongo.UserTimelineCol_.Companion.ApplicationIds +import ai.tock.bot.mongo.UserTimelineCol_.Companion.CreationDate import ai.tock.bot.mongo.UserTimelineCol_.Companion.LastUpdateDate import ai.tock.bot.mongo.UserTimelineCol_.Companion.LastUserActionDate import ai.tock.bot.mongo.UserTimelineCol_.Companion.Namespace @@ -602,15 +600,32 @@ internal object UserTimelineMongoDAO : UserTimelineDAO, UserReportDAO, DialogRep else Stories.actions.annotation.creationDate gt annotationCreationDateFrom?.toInstant(), if (annotationCreationDateTo == null) null else Stories.actions.annotation.creationDate lt annotationCreationDateTo?.toInstant(), + if (dialogCreationDateFrom == null) null + else Stories.actions.date gt dialogCreationDateFrom?.toInstant(), + if (dialogCreationDateTo == null) null + else Stories.actions.date lt dialogCreationDateTo?.toInstant(), ) logger.debug { "dialog search query: $filter" } val c = dialogCol.withReadPreference(secondaryPreferred()) val count = c.countDocuments(filter, defaultCountOptions) return if (count > start) { - val sortBson = when(annotationSort) { - null -> descending(LastUpdateDate) - BotAnnotationSortDirection.ASC -> ascending(Stories.actions.annotation.lastUpdateDate) - BotAnnotationSortDirection.DESC -> descending(Stories.actions.annotation.lastUpdateDate) + val sortBson = when { + annotationSort != null -> { + if (annotationSort == SortDirection.ASC) + ascending(Stories.actions.annotation.lastUpdateDate) + else + descending(Stories.actions.annotation.lastUpdateDate) + } + + dialogSort != null -> { + if (dialogSort == SortDirection.ASC) + orderBy(mapOf(Stories.actions.date to true)) + else + orderBy(mapOf(Stories.actions.date to false)) + } + + // If no filter is specified, we keep default filtering + else -> descending(LastUpdateDate) } val list = c.find(filter) .skip(start.toInt()) From 21fb259dd32a09f881d9e4b78a407b552f2de640 Mon Sep 17 00:00:00 2001 From: scezen Date: Mon, 17 Feb 2025 09:15:46 +0100 Subject: [PATCH 07/12] FaqSettings files --- .../shared/config/FaqSettings_Deserializer.kt | 131 ++++++++++++++++++ .../shared/config/FaqSettings_Serializer.kt | 41 ++++++ 2 files changed, 172 insertions(+) create mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt create mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt new file mode 100644 index 0000000000..106afc4f06 --- /dev/null +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt @@ -0,0 +1,131 @@ +package ai.tock.nlp.front.shared.config + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.JsonToken +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.module.SimpleModule +import java.time.Instant +import kotlin.Boolean +import kotlin.String +import kotlin.collections.Map +import kotlin.reflect.KFunction +import kotlin.reflect.KParameter +import kotlin.reflect.full.findParameterByName +import kotlin.reflect.full.primaryConstructor +import org.litote.jackson.JacksonModuleServiceLoader +import org.litote.kmongo.Id + +internal class FaqSettings_Deserializer : JsonDeserializer(), + JacksonModuleServiceLoader { + override fun module() = SimpleModule().addDeserializer(FaqSettings::class.java, this) + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FaqSettings { + with(p) { + var __id_: Id? = null + var __id_set : Boolean = false + var _applicationId_: Id? = null + var _applicationId_set : Boolean = false + var _satisfactionEnabled_: Boolean? = null + var _satisfactionEnabled_set : Boolean = false + var _satisfactionStoryId_: String? = null + var _satisfactionStoryId_set : Boolean = false + var _creationDate_: Instant? = null + var _creationDate_set : Boolean = false + var _updateDate_: Instant? = null + var _updateDate_set : Boolean = false + var _token_ : JsonToken? = currentToken + while (_token_?.isStructEnd != true) { + if(_token_ != JsonToken.FIELD_NAME) { + _token_ = nextToken() + if (_token_?.isStructEnd == true) break + } + + val _fieldName_ = currentName + _token_ = nextToken() + when (_fieldName_) { + "_id" -> { + __id_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(__id__reference); + __id_set = true + } + "applicationId" -> { + _applicationId_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(_applicationId__reference); + _applicationId_set = true + } + "satisfactionEnabled" -> { + _satisfactionEnabled_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.booleanValue; + _satisfactionEnabled_set = true + } + "satisfactionStoryId" -> { + _satisfactionStoryId_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.text; + _satisfactionStoryId_set = true + } + "creationDate" -> { + _creationDate_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(Instant::class.java); + _creationDate_set = true + } + "updateDate" -> { + _updateDate_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(Instant::class.java); + _updateDate_set = true + } + else -> { + if (_token_?.isStructStart == true) + p.skipChildren() + nextToken() + } + } + _token_ = currentToken + } + return if(__id_set && _applicationId_set && _satisfactionEnabled_set && + _satisfactionStoryId_set && _creationDate_set && _updateDate_set) + FaqSettings(_id = __id_!!, applicationId = _applicationId_!!, + satisfactionEnabled = _satisfactionEnabled_!!, satisfactionStoryId = + _satisfactionStoryId_, creationDate = _creationDate_!!, updateDate = + _updateDate_!!) + else { + val map = mutableMapOf() + if(__id_set) + map[parameters.getValue("_id")] = __id_ + if(_applicationId_set) + map[parameters.getValue("applicationId")] = _applicationId_ + if(_satisfactionEnabled_set) + map[parameters.getValue("satisfactionEnabled")] = _satisfactionEnabled_ + if(_satisfactionStoryId_set) + map[parameters.getValue("satisfactionStoryId")] = _satisfactionStoryId_ + if(_creationDate_set) + map[parameters.getValue("creationDate")] = _creationDate_ + if(_updateDate_set) + map[parameters.getValue("updateDate")] = _updateDate_ + primaryConstructor.callBy(map) + } + } + } + + companion object { + private val primaryConstructor: KFunction by + lazy(LazyThreadSafetyMode.PUBLICATION) { FaqSettings::class.primaryConstructor!! } + + private val parameters: Map by lazy(LazyThreadSafetyMode.PUBLICATION) { + kotlin.collections.mapOf("_id" to primaryConstructor.findParameterByName("_id")!!, + "applicationId" to primaryConstructor.findParameterByName("applicationId")!!, + "satisfactionEnabled" to + primaryConstructor.findParameterByName("satisfactionEnabled")!!, + "satisfactionStoryId" to + primaryConstructor.findParameterByName("satisfactionStoryId")!!, "creationDate" to + primaryConstructor.findParameterByName("creationDate")!!, "updateDate" to + primaryConstructor.findParameterByName("updateDate")!!) } + + private val __id__reference: TypeReference> = object : + TypeReference>() {} + + private val _applicationId__reference: TypeReference> = object : + TypeReference>() {} + } +} \ No newline at end of file diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt new file mode 100644 index 0000000000..edb672e9ba --- /dev/null +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt @@ -0,0 +1,41 @@ +package ai.tock.nlp.front.shared.config + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import org.litote.jackson.JacksonModuleServiceLoader + +internal class FaqSettings_Serializer : StdSerializer(FaqSettings::class.java), + JacksonModuleServiceLoader { + override fun module() = SimpleModule().addSerializer(FaqSettings::class.java, this) + + override fun serialize( + value: FaqSettings, + gen: JsonGenerator, + serializers: SerializerProvider + ) { + gen.writeStartObject() + gen.writeFieldName("_id") + val __id_ = value._id + serializers.defaultSerializeValue(__id_, gen) + gen.writeFieldName("applicationId") + val _applicationId_ = value.applicationId + serializers.defaultSerializeValue(_applicationId_, gen) + gen.writeFieldName("satisfactionEnabled") + val _satisfactionEnabled_ = value.satisfactionEnabled + gen.writeBoolean(_satisfactionEnabled_) + gen.writeFieldName("satisfactionStoryId") + val _satisfactionStoryId_ = value.satisfactionStoryId + if(_satisfactionStoryId_ == null) { gen.writeNull() } else { + gen.writeString(_satisfactionStoryId_) + } + gen.writeFieldName("creationDate") + val _creationDate_ = value.creationDate + serializers.defaultSerializeValue(_creationDate_, gen) + gen.writeFieldName("updateDate") + val _updateDate_ = value.updateDate + serializers.defaultSerializeValue(_updateDate_, gen) + gen.writeEndObject() + } +} \ No newline at end of file From f4abeefc90df8267f8da0fba1d5e46f752a44f42 Mon Sep 17 00:00:00 2001 From: scezen Date: Thu, 20 Feb 2025 11:30:14 +0100 Subject: [PATCH 08/12] Single POST endpoint for creation/update of an annotation --- .../server/src/main/kotlin/BotAdminService.kt | 42 +++++++++++++++++++ .../main/kotlin/verticle/DialogVerticle.kt | 4 +- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/BotAdminService.kt b/bot/admin/server/src/main/kotlin/BotAdminService.kt index 2964c051c5..d6523047ae 100644 --- a/bot/admin/server/src/main/kotlin/BotAdminService.kt +++ b/bot/admin/server/src/main/kotlin/BotAdminService.kt @@ -153,6 +153,48 @@ object BotAdminService { } } + fun saveAnnotation( + dialogId: String, + actionId: String, + annotationDTO: BotAnnotationDTO, + user: String + ): BotAnnotation { + return if (dialogReportDAO.annotationExists(dialogId, actionId)) { + updateAnnotation(dialogId, actionId, annotationDTO, user) + } else { + createAnnotationInternal(dialogId, actionId, annotationDTO, user) + } + } + + private fun createAnnotationInternal( + dialogId: String, + actionId: String, + annotationDTO: BotAnnotationDTO, + user: String + ): BotAnnotation { + val annotation = BotAnnotation( + state = annotationDTO.state, + reason = annotationDTO.reason, + description = annotationDTO.description, + groundTruth = annotationDTO.groundTruth, + events = mutableListOf(), + lastUpdateDate = Instant.now() + ) + + val event = BotAnnotationEventState( + eventId = newId(), + creationDate = Instant.now(), + lastUpdateDate = Instant.now(), + user = user, + before = null, + after = annotationDTO.state.name + ) + + annotation.events.add(event) + dialogReportDAO.insertAnnotation(dialogId, actionId, annotation) + return annotation + } + fun addCommentToAnnotation( dialogId: String, actionId: String, diff --git a/bot/admin/server/src/main/kotlin/verticle/DialogVerticle.kt b/bot/admin/server/src/main/kotlin/verticle/DialogVerticle.kt index bee980e1b4..9abb052214 100644 --- a/bot/admin/server/src/main/kotlin/verticle/DialogVerticle.kt +++ b/bot/admin/server/src/main/kotlin/verticle/DialogVerticle.kt @@ -176,11 +176,11 @@ class DialogVerticle { // --------------------------------- Annotation Routes ---------------------------------- - // CREATE ANNOTATION + // CREATE/UPDATE ANNOTATION blockingJsonPost(PATH_ANNOTATION, setOf(TockUserRole.botUser)) { context, annotationDTO: BotAnnotationDTO -> val botId = context.path("botId") context.checkBotId(botId) - BotAdminService.createAnnotation( + BotAdminService.saveAnnotation( context.path("dialogId"), context.path("actionId"), annotationDTO, From f0ecea3e73d782cac4ed8595d9c8f773fc446e68 Mon Sep 17 00:00:00 2001 From: scezen Date: Thu, 20 Mar 2025 17:33:41 +0100 Subject: [PATCH 09/12] pr fix --- .../server/src/main/kotlin/BotAdminService.kt | 58 ++++--------------- .../observability/ObservabilitySettingBase.kt | 2 +- 2 files changed, 13 insertions(+), 47 deletions(-) diff --git a/bot/admin/server/src/main/kotlin/BotAdminService.kt b/bot/admin/server/src/main/kotlin/BotAdminService.kt index d6523047ae..5d18ced97a 100644 --- a/bot/admin/server/src/main/kotlin/BotAdminService.kt +++ b/bot/admin/server/src/main/kotlin/BotAdminService.kt @@ -162,11 +162,11 @@ object BotAdminService { return if (dialogReportDAO.annotationExists(dialogId, actionId)) { updateAnnotation(dialogId, actionId, annotationDTO, user) } else { - createAnnotationInternal(dialogId, actionId, annotationDTO, user) + createAnnotation(dialogId, actionId, annotationDTO, user) } } - private fun createAnnotationInternal( + private fun createAnnotation( dialogId: String, actionId: String, annotationDTO: BotAnnotationDTO, @@ -177,20 +177,19 @@ object BotAdminService { reason = annotationDTO.reason, description = annotationDTO.description, groundTruth = annotationDTO.groundTruth, - events = mutableListOf(), + events = mutableListOf( + BotAnnotationEventState( + eventId = newId(), + creationDate = Instant.now(), + lastUpdateDate = Instant.now(), + user = user, + before = null, + after = annotationDTO.state.name + ) + ), lastUpdateDate = Instant.now() ) - val event = BotAnnotationEventState( - eventId = newId(), - creationDate = Instant.now(), - lastUpdateDate = Instant.now(), - user = user, - before = null, - after = annotationDTO.state.name - ) - - annotation.events.add(event) dialogReportDAO.insertAnnotation(dialogId, actionId, annotation) return annotation } @@ -356,39 +355,6 @@ object BotAdminService { ) } - fun createAnnotation( - dialogId: String, - actionId: String, - annotationDTO: BotAnnotationDTO, - user: String - ): BotAnnotation { - if (dialogReportDAO.annotationExists(dialogId, actionId)) { - throw IllegalStateException("An annotation already exists for this action") - } - - val annotation = BotAnnotation( - state = annotationDTO.state, - reason = annotationDTO.reason, - description = annotationDTO.description, - groundTruth = annotationDTO.groundTruth, - events = mutableListOf(), - lastUpdateDate = Instant.now() - ) - - val event = BotAnnotationEventState( - eventId = newId(), - creationDate = Instant.now(), - lastUpdateDate = Instant.now(), - user = user, - before = null, - after = annotationDTO.state.name - ) - - annotation.events.add(event) - dialogReportDAO.insertAnnotation(dialogId, actionId, annotation) - return annotation - } - fun createOrGetIntent( namespace: String, intentName: String, diff --git a/gen-ai/orchestrator-core/src/main/kotlin/ai/tock/genai/orchestratorcore/models/observability/ObservabilitySettingBase.kt b/gen-ai/orchestrator-core/src/main/kotlin/ai/tock/genai/orchestratorcore/models/observability/ObservabilitySettingBase.kt index e1205d38a7..5018f5e9fc 100644 --- a/gen-ai/orchestrator-core/src/main/kotlin/ai/tock/genai/orchestratorcore/models/observability/ObservabilitySettingBase.kt +++ b/gen-ai/orchestrator-core/src/main/kotlin/ai/tock/genai/orchestratorcore/models/observability/ObservabilitySettingBase.kt @@ -38,5 +38,5 @@ abstract class ObservabilitySettingBase( typealias ObservabilitySettingDTO = ObservabilitySettingBase typealias ObservabilitySetting = ObservabilitySettingBase -// Extension functions for DTO conversion +// Extension functions for DTO conversion' fun ObservabilitySetting.toDTO(): ObservabilitySettingDTO = ObservabilitySettingMapper.toDTO(this) From 3f7316c5241d19b4b078c2f8f28950fbf6233bef Mon Sep 17 00:00:00 2001 From: scezen Date: Thu, 20 Mar 2025 17:35:50 +0100 Subject: [PATCH 10/12] Revert "FaqSettings files" This reverts commit 21fb259dd32a09f881d9e4b78a407b552f2de640. --- .../shared/config/FaqSettings_Deserializer.kt | 131 ------------------ .../shared/config/FaqSettings_Serializer.kt | 41 ------ 2 files changed, 172 deletions(-) delete mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt delete mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt deleted file mode 100644 index 106afc4f06..0000000000 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt +++ /dev/null @@ -1,131 +0,0 @@ -package ai.tock.nlp.front.shared.config - -import com.fasterxml.jackson.core.JsonParser -import com.fasterxml.jackson.core.JsonToken -import com.fasterxml.jackson.core.type.TypeReference -import com.fasterxml.jackson.databind.DeserializationContext -import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.module.SimpleModule -import java.time.Instant -import kotlin.Boolean -import kotlin.String -import kotlin.collections.Map -import kotlin.reflect.KFunction -import kotlin.reflect.KParameter -import kotlin.reflect.full.findParameterByName -import kotlin.reflect.full.primaryConstructor -import org.litote.jackson.JacksonModuleServiceLoader -import org.litote.kmongo.Id - -internal class FaqSettings_Deserializer : JsonDeserializer(), - JacksonModuleServiceLoader { - override fun module() = SimpleModule().addDeserializer(FaqSettings::class.java, this) - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FaqSettings { - with(p) { - var __id_: Id? = null - var __id_set : Boolean = false - var _applicationId_: Id? = null - var _applicationId_set : Boolean = false - var _satisfactionEnabled_: Boolean? = null - var _satisfactionEnabled_set : Boolean = false - var _satisfactionStoryId_: String? = null - var _satisfactionStoryId_set : Boolean = false - var _creationDate_: Instant? = null - var _creationDate_set : Boolean = false - var _updateDate_: Instant? = null - var _updateDate_set : Boolean = false - var _token_ : JsonToken? = currentToken - while (_token_?.isStructEnd != true) { - if(_token_ != JsonToken.FIELD_NAME) { - _token_ = nextToken() - if (_token_?.isStructEnd == true) break - } - - val _fieldName_ = currentName - _token_ = nextToken() - when (_fieldName_) { - "_id" -> { - __id_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(__id__reference); - __id_set = true - } - "applicationId" -> { - _applicationId_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(_applicationId__reference); - _applicationId_set = true - } - "satisfactionEnabled" -> { - _satisfactionEnabled_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.booleanValue; - _satisfactionEnabled_set = true - } - "satisfactionStoryId" -> { - _satisfactionStoryId_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.text; - _satisfactionStoryId_set = true - } - "creationDate" -> { - _creationDate_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(Instant::class.java); - _creationDate_set = true - } - "updateDate" -> { - _updateDate_ = if(_token_ == JsonToken.VALUE_NULL) null - else p.readValueAs(Instant::class.java); - _updateDate_set = true - } - else -> { - if (_token_?.isStructStart == true) - p.skipChildren() - nextToken() - } - } - _token_ = currentToken - } - return if(__id_set && _applicationId_set && _satisfactionEnabled_set && - _satisfactionStoryId_set && _creationDate_set && _updateDate_set) - FaqSettings(_id = __id_!!, applicationId = _applicationId_!!, - satisfactionEnabled = _satisfactionEnabled_!!, satisfactionStoryId = - _satisfactionStoryId_, creationDate = _creationDate_!!, updateDate = - _updateDate_!!) - else { - val map = mutableMapOf() - if(__id_set) - map[parameters.getValue("_id")] = __id_ - if(_applicationId_set) - map[parameters.getValue("applicationId")] = _applicationId_ - if(_satisfactionEnabled_set) - map[parameters.getValue("satisfactionEnabled")] = _satisfactionEnabled_ - if(_satisfactionStoryId_set) - map[parameters.getValue("satisfactionStoryId")] = _satisfactionStoryId_ - if(_creationDate_set) - map[parameters.getValue("creationDate")] = _creationDate_ - if(_updateDate_set) - map[parameters.getValue("updateDate")] = _updateDate_ - primaryConstructor.callBy(map) - } - } - } - - companion object { - private val primaryConstructor: KFunction by - lazy(LazyThreadSafetyMode.PUBLICATION) { FaqSettings::class.primaryConstructor!! } - - private val parameters: Map by lazy(LazyThreadSafetyMode.PUBLICATION) { - kotlin.collections.mapOf("_id" to primaryConstructor.findParameterByName("_id")!!, - "applicationId" to primaryConstructor.findParameterByName("applicationId")!!, - "satisfactionEnabled" to - primaryConstructor.findParameterByName("satisfactionEnabled")!!, - "satisfactionStoryId" to - primaryConstructor.findParameterByName("satisfactionStoryId")!!, "creationDate" to - primaryConstructor.findParameterByName("creationDate")!!, "updateDate" to - primaryConstructor.findParameterByName("updateDate")!!) } - - private val __id__reference: TypeReference> = object : - TypeReference>() {} - - private val _applicationId__reference: TypeReference> = object : - TypeReference>() {} - } -} \ No newline at end of file diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt deleted file mode 100644 index edb672e9ba..0000000000 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt +++ /dev/null @@ -1,41 +0,0 @@ -package ai.tock.nlp.front.shared.config - -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.module.SimpleModule -import com.fasterxml.jackson.databind.ser.std.StdSerializer -import org.litote.jackson.JacksonModuleServiceLoader - -internal class FaqSettings_Serializer : StdSerializer(FaqSettings::class.java), - JacksonModuleServiceLoader { - override fun module() = SimpleModule().addSerializer(FaqSettings::class.java, this) - - override fun serialize( - value: FaqSettings, - gen: JsonGenerator, - serializers: SerializerProvider - ) { - gen.writeStartObject() - gen.writeFieldName("_id") - val __id_ = value._id - serializers.defaultSerializeValue(__id_, gen) - gen.writeFieldName("applicationId") - val _applicationId_ = value.applicationId - serializers.defaultSerializeValue(_applicationId_, gen) - gen.writeFieldName("satisfactionEnabled") - val _satisfactionEnabled_ = value.satisfactionEnabled - gen.writeBoolean(_satisfactionEnabled_) - gen.writeFieldName("satisfactionStoryId") - val _satisfactionStoryId_ = value.satisfactionStoryId - if(_satisfactionStoryId_ == null) { gen.writeNull() } else { - gen.writeString(_satisfactionStoryId_) - } - gen.writeFieldName("creationDate") - val _creationDate_ = value.creationDate - serializers.defaultSerializeValue(_creationDate_, gen) - gen.writeFieldName("updateDate") - val _updateDate_ = value.updateDate - serializers.defaultSerializeValue(_updateDate_, gen) - gen.writeEndObject() - } -} \ No newline at end of file From a1a0184456eef3fe7bee24ea08048dd04648f425 Mon Sep 17 00:00:00 2001 From: scezen Date: Thu, 20 Mar 2025 17:36:41 +0100 Subject: [PATCH 11/12] rollback on FaqSettings --- .../shared/config/FaqSettings_Deserializer.kt | 147 ++++++++++++++++++ .../shared/config/FaqSettings_Serializer.kt | 57 +++++++ 2 files changed, 204 insertions(+) create mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt create mode 100644 nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt new file mode 100644 index 0000000000..d51493bc3c --- /dev/null +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2017/2021 e-voyageurs technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ai.tock.nlp.front.shared.config + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.JsonToken +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.module.SimpleModule +import java.time.Instant +import kotlin.Boolean +import kotlin.String +import kotlin.collections.Map +import kotlin.reflect.KFunction +import kotlin.reflect.KParameter +import kotlin.reflect.full.findParameterByName +import kotlin.reflect.full.primaryConstructor +import org.litote.jackson.JacksonModuleServiceLoader +import org.litote.kmongo.Id + +internal class FaqSettings_Deserializer : JsonDeserializer(), + JacksonModuleServiceLoader { + override fun module() = SimpleModule().addDeserializer(FaqSettings::class.java, this) + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FaqSettings { + with(p) { + var __id_: Id? = null + var __id_set : Boolean = false + var _applicationId_: Id? = null + var _applicationId_set : Boolean = false + var _satisfactionEnabled_: Boolean? = null + var _satisfactionEnabled_set : Boolean = false + var _satisfactionStoryId_: String? = null + var _satisfactionStoryId_set : Boolean = false + var _creationDate_: Instant? = null + var _creationDate_set : Boolean = false + var _updateDate_: Instant? = null + var _updateDate_set : Boolean = false + var _token_ : JsonToken? = currentToken + while (_token_?.isStructEnd != true) { + if(_token_ != JsonToken.FIELD_NAME) { + _token_ = nextToken() + if (_token_?.isStructEnd == true) break + } + + val _fieldName_ = currentName + _token_ = nextToken() + when (_fieldName_) { + "_id" -> { + __id_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(__id__reference); + __id_set = true + } + "applicationId" -> { + _applicationId_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(_applicationId__reference); + _applicationId_set = true + } + "satisfactionEnabled" -> { + _satisfactionEnabled_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.booleanValue; + _satisfactionEnabled_set = true + } + "satisfactionStoryId" -> { + _satisfactionStoryId_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.text; + _satisfactionStoryId_set = true + } + "creationDate" -> { + _creationDate_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(Instant::class.java); + _creationDate_set = true + } + "updateDate" -> { + _updateDate_ = if(_token_ == JsonToken.VALUE_NULL) null + else p.readValueAs(Instant::class.java); + _updateDate_set = true + } + else -> { + if (_token_?.isStructStart == true) + p.skipChildren() + nextToken() + } + } + _token_ = currentToken + } + return if(__id_set && _applicationId_set && _satisfactionEnabled_set && + _satisfactionStoryId_set && _creationDate_set && _updateDate_set) + FaqSettings(_id = __id_!!, applicationId = _applicationId_!!, + satisfactionEnabled = _satisfactionEnabled_!!, satisfactionStoryId = + _satisfactionStoryId_, creationDate = _creationDate_!!, updateDate = + _updateDate_!!) + else { + val map = mutableMapOf() + if(__id_set) + map[parameters.getValue("_id")] = __id_ + if(_applicationId_set) + map[parameters.getValue("applicationId")] = _applicationId_ + if(_satisfactionEnabled_set) + map[parameters.getValue("satisfactionEnabled")] = _satisfactionEnabled_ + if(_satisfactionStoryId_set) + map[parameters.getValue("satisfactionStoryId")] = _satisfactionStoryId_ + if(_creationDate_set) + map[parameters.getValue("creationDate")] = _creationDate_ + if(_updateDate_set) + map[parameters.getValue("updateDate")] = _updateDate_ + primaryConstructor.callBy(map) + } + } + } + + companion object { + private val primaryConstructor: KFunction by + lazy(LazyThreadSafetyMode.PUBLICATION) { FaqSettings::class.primaryConstructor!! } + + private val parameters: Map by lazy(LazyThreadSafetyMode.PUBLICATION) { + kotlin.collections.mapOf("_id" to primaryConstructor.findParameterByName("_id")!!, + "applicationId" to primaryConstructor.findParameterByName("applicationId")!!, + "satisfactionEnabled" to + primaryConstructor.findParameterByName("satisfactionEnabled")!!, + "satisfactionStoryId" to + primaryConstructor.findParameterByName("satisfactionStoryId")!!, "creationDate" to + primaryConstructor.findParameterByName("creationDate")!!, "updateDate" to + primaryConstructor.findParameterByName("updateDate")!!) } + + private val __id__reference: TypeReference> = object : + TypeReference>() {} + + private val _applicationId__reference: TypeReference> = object : + TypeReference>() {} + } +} diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt new file mode 100644 index 0000000000..dce6742cf3 --- /dev/null +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017/2021 e-voyageurs technologies + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ai.tock.nlp.front.shared.config + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import org.litote.jackson.JacksonModuleServiceLoader + +internal class FaqSettings_Serializer : StdSerializer(FaqSettings::class.java), + JacksonModuleServiceLoader { + override fun module() = SimpleModule().addSerializer(FaqSettings::class.java, this) + + override fun serialize( + value: FaqSettings, + gen: JsonGenerator, + serializers: SerializerProvider + ) { + gen.writeStartObject() + gen.writeFieldName("_id") + val __id_ = value._id + serializers.defaultSerializeValue(__id_, gen) + gen.writeFieldName("applicationId") + val _applicationId_ = value.applicationId + serializers.defaultSerializeValue(_applicationId_, gen) + gen.writeFieldName("satisfactionEnabled") + val _satisfactionEnabled_ = value.satisfactionEnabled + gen.writeBoolean(_satisfactionEnabled_) + gen.writeFieldName("satisfactionStoryId") + val _satisfactionStoryId_ = value.satisfactionStoryId + if(_satisfactionStoryId_ == null) { gen.writeNull() } else { + gen.writeString(_satisfactionStoryId_) + } + gen.writeFieldName("creationDate") + val _creationDate_ = value.creationDate + serializers.defaultSerializeValue(_creationDate_, gen) + gen.writeFieldName("updateDate") + val _updateDate_ = value.updateDate + serializers.defaultSerializeValue(_updateDate_, gen) + gen.writeEndObject() + } +} From 8c3cae1ad598f3ac09c3e0b3e15fb1dbb2bb8e34 Mon Sep 17 00:00:00 2001 From: scezen Date: Thu, 20 Mar 2025 17:39:50 +0100 Subject: [PATCH 12/12] rollback on FaqSettings V2 --- .../shared/config/FaqSettings_Deserializer.kt | 16 ---------------- .../shared/config/FaqSettings_Serializer.kt | 16 ---------------- 2 files changed, 32 deletions(-) diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt index d51493bc3c..937abc9462 100644 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Deserializer.kt @@ -1,19 +1,3 @@ -/* - * Copyright (C) 2017/2021 e-voyageurs technologies - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package ai.tock.nlp.front.shared.config import com.fasterxml.jackson.core.JsonParser diff --git a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt index dce6742cf3..fa8aecf7af 100644 --- a/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt +++ b/nlp/front/storage-mongo/target/generated-sources/kapt/compile/ai/tock/nlp/front/shared/config/FaqSettings_Serializer.kt @@ -1,19 +1,3 @@ -/* - * Copyright (C) 2017/2021 e-voyageurs technologies - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package ai.tock.nlp.front.shared.config import com.fasterxml.jackson.core.JsonGenerator