Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
feat: log rich edit (#337)
Browse files Browse the repository at this point in the history
Update UI version for rich log editing
Add new replay error type to capture unfilled entities
  • Loading branch information
LarsLiden committed Sep 17, 2018
1 parent ee4dd44 commit fb2da4e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -40,8 +40,8 @@
"author": "Microsoft Conversation Learner Team",
"license": "MIT",
"dependencies": {
"@conversationlearner/models": "0.172.7",
"@conversationlearner/ui": "0.298.1",
"@conversationlearner/models": "0.173.0",
"@conversationlearner/ui": "0.299.0",
"@types/supertest": "2.0.4",
"async-file": "^2.0.2",
"body-parser": "1.18.3",
Expand Down
45 changes: 32 additions & 13 deletions src/CLRunner.ts
Expand Up @@ -1191,8 +1191,12 @@ export class CLRunner {
/**
* Provide dummy data for any missing entities so they can still be rendered
*/
private PopulateMissingFilledEntities(action: CLM.ActionBase, filledEntityMap: CLM.FilledEntityMap, allEntities: CLM.EntityBase[]): void {
action.requiredEntitiesFromPayload.forEach((entityId: string) => {
private PopulateMissingFilledEntities(action: CLM.ActionBase, filledEntityMap: CLM.FilledEntityMap, allEntities: CLM.EntityBase[]): string[] {
// For backwards compatibiliity need to check requieredEntities too. In new version all in requiredEntitiesFromPayload
const allRequiredEntities = [...action.requiredEntities, ...action.requiredEntitiesFromPayload]
let missingEntities: string[] = []

allRequiredEntities.forEach((entityId: string) => {
let entity = allEntities.find(e => e.entityId === entityId)
if (entity) {
if (!filledEntityMap.map[entity.entityName]) {
Expand All @@ -1205,11 +1209,19 @@ export class CLRunner {
} as CLM.FilledEntity
filledEntityMap.map[entity.entityName] = filledEntity
filledEntityMap.map[entity.entityId] = filledEntity
missingEntities.push(entity.entityName)
}
else {
const value = filledEntityMap.ValueAsString(entity.entityName)
if (value && value.startsWith(`["$`)) {
missingEntities.push(entity.entityName)
}
}
} else {
throw new Error(`ENTITY ${entityId} DOES NOT EXIST`)
}
})
return missingEntities
}

/**
Expand Down Expand Up @@ -1355,7 +1367,7 @@ export class CLRunner {
for (let filledEntity of filledEntities) {
if (!entities.find(e => e.entityId == filledEntity.entityId)) {
highlight = "warning"
replayError = new CLM.ReplayErrorMissingEntity(CLM.filledEntityValueAsString(filledEntity))
replayError = new CLM.ReplayErrorEntityUndefined(CLM.filledEntityValueAsString(filledEntity))
replayErrors.push()
}
}
Expand Down Expand Up @@ -1411,7 +1423,7 @@ export class CLRunner {
if (!selectedAction)
{
highlight = "error";
replayError = new CLM.ReplayErrorMissingAction(userText)
replayError = new CLM.ReplayErrorActionUndefined(userText)
replayErrors.push(replayError);
}
else {
Expand All @@ -1433,14 +1445,6 @@ export class CLRunner {
}
}

let channelData = {
senderType: CLM.SenderType.Bot,
roundIndex: roundNum,
scoreIndex,
highlight,
replayError
}

// Generate bot response
curAction = actions.filter((a: CLM.ActionBase) => a.actionId === labelAction)[0]
let botResponse: IActionResult
Expand All @@ -1456,7 +1460,14 @@ export class CLRunner {
let filledEntityMap = this.CreateFilledEntityMap(scoreFilledEntities, entityList)

// Fill in missing entities with a warning
this.PopulateMissingFilledEntities(curAction, filledEntityMap, entities)
const missingEntities = this.PopulateMissingFilledEntities(curAction, filledEntityMap, entities)

// Entity required for Action isn't filled in
if (missingEntities.length > 0) {
highlight = "error";
replayError = new CLM.ReplayErrorEntityEmpty(missingEntities)
replayErrors.push(replayError);
}

// Set memory from map with names only (since not calling APIs)
let memoryMap = CLM.FilledEntityMap.FromFilledEntities(scoreFilledEntities, entities)
Expand Down Expand Up @@ -1496,6 +1507,14 @@ export class CLRunner {
}
}

let channelData = {
senderType: CLM.SenderType.Bot,
roundIndex: roundNum,
scoreIndex,
highlight,
replayError
}

let botActivity: Partial<BB.Activity> | null = null
let botId = `BOT-${userId}`
if (typeof botResponse.response == 'string') {
Expand Down

0 comments on commit fb2da4e

Please sign in to comment.