-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Train endpoint for domain, and added retraining of domain after updat…
…es in agent, domain and entitites
- Loading branch information
Showing
22 changed files
with
216 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
'use strict'; | ||
const Async = require('async'); | ||
const Boom = require('boom'); | ||
const DomainTools = require('../tools'); | ||
|
||
module.exports = (request, reply) => { | ||
|
||
let agentId = null; | ||
let domain = null; | ||
const domainId = request.params.id; | ||
const server = request.server; | ||
const redis = server.app.redis; | ||
const rasa = server.app.rasa; | ||
|
||
Async.waterfall([ | ||
(callback) => { | ||
|
||
server.inject(`/domain/${domainId}`, (res) => { | ||
|
||
if (res.statusCode !== 200){ | ||
const error = Boom.create(res.statusCode, 'An error ocurred getting the domain'); | ||
return callback(error, null); | ||
} | ||
domain = res.result; | ||
return callback(null); | ||
}); | ||
}, | ||
(callback) => { | ||
|
||
redis.zscore('agents', domain.agent, (err, id) => { | ||
|
||
if (err){ | ||
const error = Boom.badImplementation('An error ocurred checking if the agent exists.'); | ||
return callback(error); | ||
} | ||
if (id){ | ||
agentId = id; | ||
return callback(null); | ||
} | ||
const error = Boom.badRequest(`The agent ${domain.agent} of the specified domain doesn't exist`); | ||
return callback(error); | ||
}); | ||
}, | ||
(callback) => { | ||
|
||
redis.zscore('agents', domain.agent, (err, id) => { | ||
|
||
if (err){ | ||
const error = Boom.badImplementation('An error ocurred checking if the agent exists.'); | ||
return callback(error); | ||
} | ||
if (id){ | ||
agentId = id; | ||
return callback(null); | ||
} | ||
const error = Boom.badRequest(`The agent ${domain.agent} of the specified domain doesn't exist`); | ||
return callback(error); | ||
}); | ||
}, | ||
(callback) => { | ||
|
||
DomainTools.retrainModelTool(server, rasa, domain.agent, domain.domainName, domainId, (err) => { | ||
|
||
if (err){ | ||
return callback(err); | ||
} | ||
return callback(null); | ||
}); | ||
}, | ||
(callback) => { | ||
|
||
DomainTools.retrainDomainRecognizerTool(server, redis, rasa, domain.agent, agentId, (err) => { | ||
|
||
if (err){ | ||
return callback(err); | ||
} | ||
return callback(null); | ||
}); | ||
} | ||
], (err) => { | ||
|
||
if (err){ | ||
return reply(err); | ||
} | ||
server.inject(`/domain/${domainId}`, (res) => { | ||
|
||
if (res.statusCode !== 200){ | ||
const error = Boom.create(res.statusCode, 'An error ocurred getting the domain after training'); | ||
return callback(error, null); | ||
} | ||
return reply(res.result); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ainRecognitionTrainingData.intent.tool.js → ...ainRecognitionTrainingData.domain.tool.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nt/tools/buildTrainingData.intent.tool.js → ...in/tools/buildTrainingData.domain.tool.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
const RetrainModelTool = require('./retrainModel.domain.tool'); | ||
const RetrainDomainRecognizerTool = require('./retrainDomainRecognizer.domain.tool'); | ||
|
||
const DomainTools = { | ||
|
||
retrainModelTool: RetrainModelTool, | ||
|
||
retrainDomainRecognizerTool: RetrainDomainRecognizerTool | ||
}; | ||
|
||
module.exports = DomainTools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.