Skip to content

Commit

Permalink
Merged the 4.0.0 changes to the webapp (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jastier authored Jan 10, 2022
1 parent 0fcb617 commit cd830a2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 103 deletions.
34 changes: 15 additions & 19 deletions src/main/scala/org/clulab/asist/messages/DialogAgentMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,15 @@ case class DialogAgentMessage (
object DialogAgentMessage {
// remember config settings
private val config: Config = ConfigFactory.load()
private val base:DialogAgentMessage = DialogAgentMessage(
CommonHeader(
message_type = config.getString("DialogAgent.header.message_type"),
version = config.getString("CommonHeader.version")
),
CommonMsg(
source = config.getString("DialogAgent.msg.source"),
sub_type = config.getString("DialogAgent.msg.sub_type"),
version = BuildInfo.version
),
DialogAgentMessageData(
utterance_source = DialogAgentMessageUtteranceSource()
)

val header: CommonHeader = CommonHeader(
message_type = config.getString("DialogAgent.header.message_type"),
version = config.getString("CommonHeader.version")
)
val msg: CommonMsg = CommonMsg(
source = config.getString("DialogAgent.msg.source"),
sub_type = config.getString("DialogAgent.msg.sub_type"),
version = BuildInfo.version
)

/** build from Minecraft chat object
Expand All @@ -85,11 +81,11 @@ object DialogAgentMessage {
):DialogAgentMessage = {
val timestamp = Clock.systemUTC.instant.toString
DialogAgentMessage(
base.header.copy(
header.copy(
timestamp = timestamp,
version = chat.header.version
),
base.msg.copy(
msg.copy(
experiment_id = chat.msg.experiment_id,
trial_id = chat.msg.trial_id,
timestamp = timestamp,
Expand Down Expand Up @@ -122,11 +118,11 @@ object DialogAgentMessage {
):DialogAgentMessage = {
val timestamp = Clock.systemUTC.instant.toString
DialogAgentMessage(
base.header.copy(
header.copy(
timestamp = timestamp,
version = asr.header.version
),
base.msg.copy(
msg.copy(
experiment_id = asr.msg.experiment_id,
trial_id = asr.msg.trial_id,
timestamp = timestamp,
Expand Down Expand Up @@ -162,10 +158,10 @@ object DialogAgentMessage {
):DialogAgentMessage = {
val timestamp = Clock.systemUTC.instant.toString
DialogAgentMessage(
base.header.copy(
header.copy(
timestamp = timestamp,
),
base.msg.copy(
msg.copy(
timestamp = timestamp,
),
DialogAgentMessageData(
Expand Down
33 changes: 16 additions & 17 deletions src/main/scala/org/clulab/asist/messages/HeartbeatMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@ case class HeartbeatMessage (
object HeartbeatMessage {
// remember config settings
private val config: Config = ConfigFactory.load()
private val base: HeartbeatMessage = HeartbeatMessage(
CommonHeader(
message_type = config.getString("Heartbeat.header.message_type"),
),
CommonMsg(
source = config.getString("Heartbeat.msg.source"),
sub_type = config.getString("Heartbeat.msg.sub_type"),
version = BuildInfo.version,
),
HeartbeatMessageData(
state = config.getString("Heartbeat.data.state"),
active = config.getBoolean("Heartbeat.data.active"),
status = config.getString("Heartbeat.data.status")
)

val header: CommonHeader = CommonHeader(
message_type = config.getString("Heartbeat.header.message_type"),
)
val msg: CommonMsg = CommonMsg(
source = config.getString("Heartbeat.msg.source"),
sub_type = config.getString("Heartbeat.msg.sub_type"),
version = BuildInfo.version,
)
val data: HeartbeatMessageData = HeartbeatMessageData(
state = config.getString("Heartbeat.data.state"),
active = config.getBoolean("Heartbeat.data.active"),
status = config.getString("Heartbeat.data.status")
)

/** Build from a trial message
Expand All @@ -54,14 +53,14 @@ object HeartbeatMessage {
def apply(
trial: TrialMessage
): HeartbeatMessage = HeartbeatMessage(
base.header.copy(
header.copy(
version = trial.header.version
),
base.msg.copy(
msg.copy(
trial_id = trial.msg.trial_id,
experiment_id = trial.msg.experiment_id
),
base.data.copy()
data.copy()
)

/** Set the timing on an existing HeartbeatMessage
Expand Down
114 changes: 56 additions & 58 deletions src/main/scala/org/clulab/asist/messages/VersionInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,81 +56,79 @@ object VersionInfo
private val config: Config = ConfigFactory.load()
private val testbed = config.getString("VersionInfo.testbed")
private val dataSource = s"${testbed}:${BuildInfo.version}"
private val base: VersionInfo =
VersionInfo(
CommonHeader(
message_type = config.getString("VersionInfo.header.message_type"),

val header: CommonHeader = CommonHeader(
message_type = config.getString("VersionInfo.header.message_type"),
)
val msg: CommonMsg = CommonMsg(
source = config.getString("VersionInfo.msg.source"),
sub_type = config.getString("VersionInfo.msg.sub_type"),
version = BuildInfo.version,
)
val data: VersionInfoData = VersionInfoData(
agent_name = config.getString("VersionInfo.data.agent_name"),
owner = config.getString("VersionInfo.data.owner"),
version = BuildInfo.version,
source = List(dataSource),
dependencies = List(),
config = List(),
publishes = List(
VersionInfoDataMessageChannel(
config.getString("DialogAgent.topic"),
config.getString("DialogAgent.header.message_type"),
config.getString("DialogAgent.msg.sub_type")
),
CommonMsg(
source = config.getString("VersionInfo.msg.source"),
sub_type = config.getString("VersionInfo.msg.sub_type"),
version = BuildInfo.version,
VersionInfoDataMessageChannel(
config.getString("VersionInfo.topic"),
config.getString("VersionInfo.header.message_type"),
config.getString("VersionInfo.msg.sub_type")
),
VersionInfoData(
agent_name = config.getString("VersionInfo.data.agent_name"),
owner = config.getString("VersionInfo.data.owner"),
version = BuildInfo.version,
source = List(dataSource),
dependencies = List(),
config = List(),
publishes = List(
VersionInfoDataMessageChannel(
config.getString("DialogAgent.topic"),
config.getString("DialogAgent.header.message_type"),
config.getString("DialogAgent.msg.sub_type")
),
VersionInfoDataMessageChannel(
config.getString("VersionInfo.topic"),
config.getString("VersionInfo.header.message_type"),
config.getString("VersionInfo.msg.sub_type")
),
VersionInfoDataMessageChannel(
config.getString("Heartbeat.topic"),
config.getString("Heartbeat.header.message_type"),
config.getString("Heartbeat.msg.sub_type")
)
),
subscribes = List(
VersionInfoDataMessageChannel(
config.getString("Trial.topic"),
config.getString("Trial.header.message_type"),
config.getString("Trial.msg.sub_type.trial_start")
),
VersionInfoDataMessageChannel(
config.getString("Trial.topic"),
config.getString("Trial.header.message_type"),
config.getString("Trial.msg.sub_type.trial_stop")
),
VersionInfoDataMessageChannel(
config.getString("Asr.topic"),
config.getString("Asr.header.message_type"),
config.getString("Asr.msg.sub_type")
),
VersionInfoDataMessageChannel(
config.getString("Chat.topic"),
config.getString("Chat.header.message_type"),
config.getString("Chat.msg.sub_type")
)
)
VersionInfoDataMessageChannel(
config.getString("Heartbeat.topic"),
config.getString("Heartbeat.header.message_type"),
config.getString("Heartbeat.msg.sub_type")
)
),
subscribes = List(
VersionInfoDataMessageChannel(
config.getString("Trial.topic"),
config.getString("Trial.header.message_type"),
config.getString("Trial.msg.sub_type.trial_start")
),
VersionInfoDataMessageChannel(
config.getString("Trial.topic"),
config.getString("Trial.header.message_type"),
config.getString("Trial.msg.sub_type.trial_stop")
),
VersionInfoDataMessageChannel(
config.getString("Asr.topic"),
config.getString("Asr.header.message_type"),
config.getString("Asr.msg.sub_type")
),
VersionInfoDataMessageChannel(
config.getString("Chat.topic"),
config.getString("Chat.header.message_type"),
config.getString("Chat.msg.sub_type")
)
)

)

/** Build from Trial Message
* @param trial A testbed Trial object
*/
def apply(trialMessage: TrialMessage): VersionInfo = {
val timestamp = Clock.systemUTC.instant.toString
VersionInfo(
base.header.copy(
header.copy(
timestamp = timestamp,
version = trialMessage.header.version
),
base.msg.copy(
msg.copy(
timestamp = timestamp,
trial_id = trialMessage.msg.trial_id,
experiment_id = trialMessage.msg.experiment_id
),
base.data.copy()
data.copy()
)
}
}
20 changes: 11 additions & 9 deletions webapp/app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,20 @@ class HomeController @Inject() (cc: ControllerComponents)
println(s"DOC : ${doc}")
// Extract mentions from annotated document
val mentions = agent.extractMentions(doc)
val extractions = agent.getExtractions(mentions)
val messageData = agent.dialogAgentMessageData(
"P00012",
"bc36d1aa-25e6-11ec-ab58-7831c1b845fe",
"message_bus",
"agent/asr/final",
text,
extractions
val messageData = DialogAgentMessageData(
participant_id = "P00012",
asr_msg_id = "bc36d1aa-25e6-11ec-ab58-7831c1b845fe",
text = text,
dialog_act_label = "N/A",
utterance_source = DialogAgentMessageUtteranceSource(
source_type = "message_bus",
source_name = "agent/asr/final"
),
extractions = agent.getExtractions(mentions)
)
val timestamp = Clock.systemUTC.instant.toString
val message = DialogAgentMessage(
CommonHeader(timestamp, agent.templateMessage.header.message_type),
CommonHeader(timestamp, DialogAgentMessage.header.message_type),
CommonMsg(
experiment_id = "367624f8-81cd-4661-a03f-b61908c39581",
trial_id = "78822ceb-448a-436e-a1f1-f154f2066261",
Expand Down

0 comments on commit cd830a2

Please sign in to comment.