manthanhd / talkify

Talkify is an open source framework with an aim to standardize and model conversational AI enabling development of personal assistants and chat bots. The mission of this framework is to make developing chat bots and personal assistants as easy as spinning up a simple website in html.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable single-sentence query mode

manthanhd opened this issue · comments

Currently all queries are treated as multi-sentence and hence it expects multiple queries to be passed in. Sometimes to avoid the complexity of writing skills that can handle multi-sentence queries, it makes sense to turn this feature off. I expect this to be a flag in configuration object for the Bot, something like:

var options = {
    query: {mode: 'single'}
};

or something more flat and simpler:

var options = {
    singleQueryMode: true
};

Could we replace how queries are processed altogether? Instead of sentences array being composed of strings, it could contain actual NLPQuery objects. These objects could be processed using a QueryProcessor.

There could be two built in QueryProcessor classes; SingleSentenceQueryProcessor and MultiSentenceQueryProcessor. The latter becomes the default.

Each QueryProcessor class should have a process method that is asynchronous and calls back using (err, processedQueries). The processedQueries parameter contains list of NLPQuery objects.

The NLPQuery object could have a getSentence (and getValue) methods that return the raw sentence. This way the query processors can provide extra attributes that can then be used by the skills when they get request.sentences in metadata.

After all this, options could look like:

const options = {
  query: {
    processor: new MyAwesomeQueryProcessor()
  }
};
ezoic increase your site revenue