Skip to content

Commit

Permalink
add collection and map params to setAsrProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
r.kulbaev authored and CptBronzebeard committed Oct 21, 2024
1 parent 10009f7 commit 156a5a9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class TelephonyReactions(private val bargeInDefaultProps: BargeInProperties) : J
* }
* }
* ```
* @param properties map of properties names with its assigned values (String or List).
* @param properties map of properties names with its assigned values (String/Collection/Map).
* */
fun setAsrProperties(properties: Map<String, Any>) {
asrConfig = setAsrPropertiesHandler.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class SetAsrPropertiesHandler(
fun handle(properties: Map<String, Any>, asrConfig: AsrConfig): AsrConfig {
val propertiesJson = JsonObject(properties.mapValues { entry ->
when (val value = entry.value) {
is List<*> -> JsonArray(value.map { JsonPrimitive(it.toString()) })
is Collection<*> -> JsonArray(value.map { JsonPrimitive(it.toString()) })
is String -> JsonPrimitive(value)
is Map<*,*> -> JsonObject(value.mapKeys { it.key.toString() }.mapValues { JsonPrimitive(it.value.toString()) })
else -> throw IllegalArgumentException("Unsupported property type: ${value::class.simpleName}")
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ internal class ProviderConfigTest : JaicpBaseTest() {
val scenario = echoWithAction {
reactions.telephony?.setAsrProperties(mapOf(
"hints.eou_timeout" to "4s",
"insight_models" to listOf("call_features")
"insight_models" to listOf("call_features"),
"time" to mapOf(("now" to "21:00"))
))
}
val channel = JaicpTestChannel(scenario, TelephonyChannel)
Expand Down
6 changes: 4 additions & 2 deletions channels/jaicp/src/test/resources/config/003/resp.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
"model": "callcenter",
"asrProperties": {
"hints.eou_timeout": "4s",
"insight_models": ["call_features"]
"insight_models": ["call_features"],
"time":{"now":"21:00"}
}
},
"asrProperties": {
"hints.eou_timeout": "4s",
"insight_models": ["call_features"]
"insight_models": ["call_features"],
"time":{"now":"21:00"}
}
}
},
Expand Down

0 comments on commit 156a5a9

Please sign in to comment.