Hello together. I am currently working on a small smart home assistant project using Python3.8. So far I had used the Snips project for my NLU. Now I would like to switch to a more recent project, like Rasa. Hence my question, which I haven’t really found a good answer to yet: Is it possible to use only the Rasa NLU in a Python3.8 script and if so, how? After installing the Python package rasa, I can’t import this into Python: “can’t open file ‘rasa’”. I guess this is only for command line/local server use? Thanks for your help!
I got it working with the following example code:
#!/bin/bash
rasa train nlu --config config.yml --nlu nlu.yml --out ./ --fixed-model-name rasaModel
and
#python3
from rasa.core.agent import Agent
import asyncio
import json
model_path = "rasaModel.tar.gz"
agent = Agent.load(model_path)
print("NLU model loaded. Type a message and press enter to parse it.")
while True:
print("Next message:")
try:
message = input().strip()
except (EOFError, KeyboardInterrupt):
print("Wrapping up command line chat...")
break
result = asyncio.run(agent.parse_message(message))
print(json.dumps(result, indent=2))