Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Commit

Permalink
chore: fixed http_logger to forward modelId
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Cote-Boucher committed Jun 20, 2019
1 parent 196b67c commit 9d6f9a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rasa_addons/nlu/components/http_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from rasa.nlu.training_data import Message

from requests_futures.sessions import FuturesSession
import json
import logging

logger = logging.getLogger(__name__)

class HttpLogger(Component):
name = 'HttpLogger'
Expand All @@ -16,19 +19,24 @@ class HttpLogger(Component):
def __init__(self, component_config=None):
super(HttpLogger, self).__init__(component_config)
assert 'url' in component_config, 'You must specify the url to use the HttpLogger component'
assert 'model_id' in component_config, 'You must specify the model_id to use the HttpLogger component'

def process(self, message, **kwargs):
# type: (Message, **Any) -> None

session = FuturesSession()
if not message.params or message.params.get('nolog', 'false') not in ['true', '1']:
if not message.params or message.params.get('nolog', 'false') in ['true', '1']:
return

output = self._message_dict(message)
for k, v in self.component_config.get('params').items():
output[k] = v
output['modelId'] = self.component_config.get('model_id')

session.post(self.component_config.get('url'), json=output)
future = session.post(self.component_config.get('url'), json=output)
response = future.result()
if response.status_code != 200:
logger.error('{} Error from API: {}'.format(str(response.status_code), json.loads(response.content)['error']))

@staticmethod
def _message_dict(message):
Expand Down

0 comments on commit 9d6f9a3

Please sign in to comment.