aice.js
v0.3.6
Published
Artificial Intelligence Conversational Engine
Downloads
18
Readme
Artificial Intelligence Conversational Engine (AICE)
AIce is an opensource Javascript natural language processing (NLP) and conversational framework without any dependencies.
Vision
We want to build a sustainable solution able to guess several languages, to understand the intention of the user, to give the best response in order to satisfy the user's intent. Also, we hope for providing both text-based conversational interface as well as form-based conversational interface. We desire to give a flexible NLP API to better fit various use case.
Features
- NLX syntax based
- Streams transformers Tokens based architecture, so it can handle input streams
- Intents resolvers For the moment, we only have kind of ExactScoring methods to detect the intent match.
- Outputs renderers For the moment, we only have SimpleRenderer that handle callables, conditions and the rendering/generation of the answer.
- Many comparators with a varieties of strategies (hamming, levenshtein, damerau-levenshtein...)
- Named Entity Recognition, accepting similar strings for Enum Entities.
- Rule based Named Entities. Conception WIP
- And more !
How to install
It can be installed directly from NPM to be integrated in node.js application.
npm install aice.js
Usages example
How to import
import { AICE } from 'aice.js';
const { AICE } = require('aice.js');
Simple use case
const aice = new AICE();
aice.addInput('en', 'hello', 'Hello');
aice.addOutput('en', 'hello', "Hello. What's up ?");
aice.train();
// now you can use process to get the answer
const response = await aice.process('Hello', {}, 'en');
{
"answer":"Hello. What's up ?",
"score":1,
"intent":"hello",
"context":{}
}
Conditions use case
const nlp = new AICE();
nlp.addInput('en', 'test.conditions', 'Test conditions');
nlp.addOutput(
'en',
'test.conditions',
"This is a test of the conditions",
undefined,
[{
type: 'LeftRightExpression',
operande: 'eq',
Lvalue: { type: 'VARIABLE', value: 'state' },
Rvalue: 'STATE_0',
}]);
nlp.train();
// now you can use process to get the answer
const response = await aice.process('Test condition', { state: 'STATE_0'}, 'en');
{
"answer":"This is a test of the conditions",
"score":1,
"intent":"test.conditions",
"context":{"state":"STATE_0"}
}
Callable use case
const nlp = new AICE();
// Add an input to the intent 'match.email'
nlp.addInput('en', 'match.email', '{{userEmail=@email}}');
// Add an output to the intent 'match.email'
nlp.addOutput('en', 'match.email', "Thanks for your email. I'll send you some thing", undefined, undefined,
async context => {
const { userEmail } = context;
const text = 'Example of email body';
const mail = {
to: userEmail,
subject: 'Example of send mail',
text,
html: text,
};
await emailSender.sendMessage(mail);
return {};
});
nlp.train();
This will send a mail to userEmail catched by the entity @email. In this example the service emailSender as been created using node-mailer.
NLX syntax
INPUT
TEXT I'm a text
INLINE_CODE {{ }} // Expression syntax
SET namevar=@entityName
SET namevar=*
SET namevar=^
ANY *
ANYORNOTHING ^
ENTITY @name // modify currentContext as entityName=@entityName
OUTPUT
INLINE_CODE {{ }} // rendered
CODE << >> // not rendered
SET namevar='value'
SET namevar=varName
GET namevar
Contributing
Please, see the CONTRIBUTING.md file.
Contributor Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See CODE_OF_CONDUCT.md file.
More
This project is developed by Opla.
It is still a WIP, but you could contribute, test, report bugs.
How to pronounce it ? "A-Ice" /eɪ/ /ʌɪs/