@bavard/agent-config
Advanced tools
Comparing version 0.0.32 to 0.0.33
import { BaseAgentAction } from './actions/base-action'; | ||
import { IIntent, IAgentConfig, ISlot } from './types'; | ||
import { IIntent, IAgentConfig, ISlot, IAgentAction } from './types'; | ||
import { GraphPolicy } from './graph-policy'; | ||
@@ -30,3 +30,3 @@ export declare enum EPolicyType { | ||
getTagTypes(): Set<string>; | ||
addAction(action: BaseAgentAction): AgentConfig; | ||
addAction(action: IAgentAction): AgentConfig; | ||
deleteAction(name: string): AgentConfig; | ||
@@ -33,0 +33,0 @@ getActions(): BaseAgentAction[]; |
@@ -7,5 +7,7 @@ "use strict"; | ||
exports.AgentConfig = exports.EPolicyType = void 0; | ||
const utils_1 = require("./utils"); | ||
const types_1 = require("./types"); | ||
const graph_policy_1 = require("./graph-policy"); | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const email_action_1 = require("./actions/email-action"); | ||
const utterance_action_1 = require("./actions/utterance-action"); | ||
const packageJson = require('../package.json'); | ||
@@ -80,3 +82,11 @@ var EPolicyType; | ||
addAction(action) { | ||
this.actions.set(action.name, action); | ||
switch (action.type) { | ||
case types_1.EAgentActionTypes.UTTERANCE_ACTION: | ||
this.actions.set(action.name, new utterance_action_1.UtteranceAction(action.name, action.utterance)); | ||
break; | ||
case types_1.EAgentActionTypes.EMAIL_ACTION: | ||
this.actions.set(action.name, new email_action_1.EmailAction(action.name, action.to, action.from, action.prompt)); | ||
break; | ||
default: throw new Error('Invalid action type.'); | ||
} | ||
return this; | ||
@@ -158,3 +168,3 @@ } | ||
for (const action of jsonObj.actions) { | ||
config.addAction(utils_1.actionfromJson(action)); | ||
config.addAction(action); | ||
} | ||
@@ -161,0 +171,0 @@ for (const policy of jsonObj.graphPolicies) { |
{ | ||
"policyName": "Life Apps Bot", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"rootNode": { | ||
@@ -5,0 +5,0 @@ "nodeId": 1, |
{ | ||
"name": "@bavard/agent-config", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
{ | ||
"policyName": "Car Bot", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"rootNode": { | ||
@@ -5,0 +5,0 @@ "nodeId": 1, |
import { BaseAgentAction } from './actions/base-action'; | ||
import { IIntent, IAgentConfig, ISlot } from './types'; | ||
import { actionfromJson } from './utils'; | ||
import { IIntent, IAgentConfig, ISlot, IAgentAction, EAgentActionTypes } from './types'; | ||
import { GraphPolicy } from './graph-policy'; | ||
import _ from 'lodash'; | ||
import { EmailAction } from './actions/email-action'; | ||
import { UtteranceAction } from './actions/utterance-action'; | ||
const packageJson = require('../package.json'); | ||
@@ -92,4 +93,16 @@ | ||
// actions | ||
addAction(action: BaseAgentAction): AgentConfig { | ||
this.actions.set(action.name, action); | ||
addAction(action: IAgentAction): AgentConfig { | ||
switch (action.type) { | ||
case EAgentActionTypes.UTTERANCE_ACTION: | ||
this.actions.set( | ||
action.name, | ||
new UtteranceAction(action.name, action.utterance)); | ||
break; | ||
case EAgentActionTypes.EMAIL_ACTION: | ||
this.actions.set( | ||
action.name, | ||
new EmailAction(action.name, action.to, action.from, action.prompt)); | ||
break; | ||
default: throw new Error('Invalid action type.'); | ||
} | ||
return this; | ||
@@ -190,3 +203,3 @@ } | ||
for (const action of jsonObj.actions) { | ||
config.addAction(actionfromJson(action)); | ||
config.addAction(action); | ||
} | ||
@@ -193,0 +206,0 @@ |
136225
4141