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

use empty domain in case Domain is None (e.g. if it's a NLU only model) #4989

Merged
merged 4 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/4989.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use an empty domain in case a model is loaded which has no domain
(avoids errors when accessing ``agent.doman.<some attribute>``).
4 changes: 2 additions & 2 deletions rasa/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def update_model(
interpreter: Optional[NaturalLanguageInterpreter] = None,
model_directory: Optional[Text] = None,
) -> None:
self.domain = domain
self.domain = self._create_domain(domain)
wochinge marked this conversation as resolved.
Show resolved Hide resolved
self.policy_ensemble = policy_ensemble

if interpreter:
Expand Down Expand Up @@ -858,7 +858,7 @@ def create_processor(
)

@staticmethod
def _create_domain(domain: Union[Domain, Text]) -> Domain:
def _create_domain(domain: Union[Domain, Text, None]) -> Domain:

if isinstance(domain, str):
domain = Domain.load(domain)
Expand Down
7 changes: 2 additions & 5 deletions tests/core/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,10 @@ def test_two_stage_fallback_without_deny_suggestion(domain, policy_config):
async def test_agent_update_model_none_domain(trained_model: Text):
agent = await load_agent(model_path=trained_model)
agent.update_model(
Domain.empty(),
None,
agent.fingerprint,
agent.interpreter,
agent.model_directory,
None, None, agent.fingerprint, agent.interpreter, agent.model_directory
)

assert agent.domain is not None
sender_id = "test_sender_id"
message = UserMessage("hello", sender_id=sender_id)
await agent.handle_message(message)
Expand Down