Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass message metadata to interpreter when parsing #6275

Merged
merged 10 commits into from
Sep 22, 2020
1 change: 1 addition & 0 deletions changelog/6275.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add optional metadata argument to NaturalLanguageInterpreter's parse method.
pheel marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions rasa/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def parse(
text: Text,
message_id: Optional[Text] = None,
tracker: Optional[DialogueStateTracker] = None,
metadata: Optional[Dict] = None,
) -> Dict[Text, Any]:
raise NotImplementedError(
"Interpreter needs to be able to parse messages into structured output."
Expand Down Expand Up @@ -157,6 +158,7 @@ async def parse(
text: Text,
message_id: Optional[Text] = None,
tracker: Optional[DialogueStateTracker] = None,
metadata: Optional[Dict] = None,
) -> Dict[Text, Any]:
"""Parse a text message."""

Expand Down Expand Up @@ -192,6 +194,7 @@ async def parse(
text: Text,
message_id: Optional[Text] = None,
tracker: Optional[DialogueStateTracker] = None,
metadata: Optional[Dict] = None,
) -> Dict[Text, Any]:
"""Parse a text message.

Expand Down Expand Up @@ -271,6 +274,7 @@ async def parse(
text: Text,
message_id: Optional[Text] = None,
tracker: Optional[DialogueStateTracker] = None,
metadata: Optional[Dict] = None,
) -> Dict[Text, Any]:
"""Parse a text message.

Expand Down
4 changes: 3 additions & 1 deletion rasa/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ async def parse_message(
text, message.message_id, tracker
)
else:
parse_data = await self.interpreter.parse(text, message.message_id, tracker)
parse_data = await self.interpreter.parse(
text, message.message_id, tracker, metadata=message.metadata
)

logger.debug(
"Received user message '{}' with intent '{}' "
Expand Down