Esempio n. 1
0
 def parse(self, data):
     alias = data.get("model") or self.DEFAULT_MODEL_NAME
     if alias not in self.model_store:
         raise InvalidModelError("No model found with alias '{}'".format(alias))
     else:
         model = self.model_store[alias]
         response = model.parse(data['text'])
         if self.responses:
             self.responses.info(json.dumps(response, sort_keys=True))
         return self.format_response(response)
Esempio n. 2
0
    def parse(self, data):
        alias = data.get("model") or self.DEFAULT_MODEL_NAME
        if alias not in self.model_store:
            try:
                self.model_store[alias] = self.__interpreter_for_model(model_path=alias)
            except Exception as e:
                raise InvalidModelError("No model found with alias '{}'. Error: {}".format(alias, e))

        model = self.model_store[alias]
        response = model.parse(data['text'], data.get('time', None))
        if self.responses:
            self.responses.info(user_input=response, model=alias)
        return self.format_response(response)
Esempio n. 3
0
    def parse(self, data):
        alias = data.get("model") or self.DEFAULT_MODEL_NAME
        if alias not in self.model_store:
            try:
                self.model_store[alias] = self.__interpreter_for_model(model_path=alias)
            except Exception as e:
                raise InvalidModelError("No model found with alias '{}'. Error: {}".format(alias, e))

        model = self.model_store[alias]
        response = model.parse(data['text'])       
        if self.responses:
            log={"user_input": response, "model": alias, "time": datetime.datetime.now().isoformat()}
            self.responses.info(json.dumps(log, sort_keys=True))
        return self.format_response(response)