From 5d151112b3762518205200dd547fa6f29f99272e Mon Sep 17 00:00:00 2001 From: Philippe Cote-Boucher Date: Thu, 23 Jul 2020 15:17:39 -0400 Subject: [PATCH 1/4] pass message metadata to interpreter when parsing --- rasa/core/interpreter.py | 7 ++++++- rasa/core/processor.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rasa/core/interpreter.py b/rasa/core/interpreter.py index 3b889708f875..817b0adff815 100644 --- a/rasa/core/interpreter.py +++ b/rasa/core/interpreter.py @@ -23,6 +23,7 @@ async def parse( text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, + metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: raise NotImplementedError( "Interpreter needs to be able to parse messages into structured output." @@ -149,16 +150,18 @@ async def parse( text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, + metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: """Parse a text message.""" - return self.synchronous_parse(text, message_id, tracker) + return self.synchronous_parse(text, message_id, tracker, metadata) def synchronous_parse( self, text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, + metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: """Parse a text message.""" @@ -189,6 +192,7 @@ async def parse( text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, + metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: """Parse a text message. @@ -266,6 +270,7 @@ async def parse( text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, + metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: """Parse a text message. diff --git a/rasa/core/processor.py b/rasa/core/processor.py index 7dc842b44b33..40c28a987d2e 100644 --- a/rasa/core/processor.py +++ b/rasa/core/processor.py @@ -471,7 +471,7 @@ async def _parse_message(self, message, tracker: DialogueStateTracker = None): ) else: parse_data = await self.interpreter.parse( - message.text, message.message_id, tracker + message.text, message.message_id, tracker, metadata=message.metadata, ) logger.debug( From 796948916549049b85685f2aac1ec3e3c3327530 Mon Sep 17 00:00:00 2001 From: Philippe Cote-Boucher Date: Fri, 24 Jul 2020 11:41:02 -0400 Subject: [PATCH 2/4] changelog entry --- changelog/6275.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/6275.feature.rst diff --git a/changelog/6275.feature.rst b/changelog/6275.feature.rst new file mode 100644 index 000000000000..9dc02fed0dcf --- /dev/null +++ b/changelog/6275.feature.rst @@ -0,0 +1 @@ +Add optional metadata argument to NaturalLanguageInterpreter's parse method. From 5c62507f7e21e5ff6c30890fde13fb5133c8f584 Mon Sep 17 00:00:00 2001 From: Philippe Cote-Boucher Date: Fri, 24 Jul 2020 11:42:26 -0400 Subject: [PATCH 3/4] remove unused argument --- rasa/core/interpreter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rasa/core/interpreter.py b/rasa/core/interpreter.py index 817b0adff815..76234b05eb04 100644 --- a/rasa/core/interpreter.py +++ b/rasa/core/interpreter.py @@ -154,14 +154,13 @@ async def parse( ) -> Dict[Text, Any]: """Parse a text message.""" - return self.synchronous_parse(text, message_id, tracker, metadata) + return self.synchronous_parse(text, message_id, tracker) def synchronous_parse( self, text: Text, message_id: Optional[Text] = None, tracker: DialogueStateTracker = None, - metadata: Optional[Dict] = None, ) -> Dict[Text, Any]: """Parse a text message.""" From dfd625013544615d7c9de1f839cd0d9334f6de03 Mon Sep 17 00:00:00 2001 From: Philippe Cote-Boucher Date: Fri, 11 Sep 2020 08:18:46 -0400 Subject: [PATCH 4/4] changelog --- changelog/6275.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/6275.feature.rst b/changelog/6275.feature.rst index 9dc02fed0dcf..5977d594e4b3 100644 --- a/changelog/6275.feature.rst +++ b/changelog/6275.feature.rst @@ -1 +1 @@ -Add optional metadata argument to NaturalLanguageInterpreter's parse method. +Add optional metadata argument to ``NaturalLanguageInterpreter``'s parse method.