Using RASA NLU with python code and without API

Hello folks, I have rcently upgraded my RASA to version 3.4. The previous version was 2.X, and I had no problem with that. The newst version of RASA, unfortunately does not match the code in python. I used RASA NLU by importing RASA libraries, but for the newer version some of them are not working. Here is the following import:

from rasa.nlu.model import Interpreter

But module Interpreter is not found anymore. Anyone knows how to fix it? Actually, I want to run RASA NLU using python code, but not using the HTTP API. Please share your ideas if it’s still possible to do in python.

1 Like


Which version of Python are you using? can you update to the latest and check

Hi, I am using Rasa and Python version: Rasa Version : 3.4.0 Minimum Compatible Version: 3.0.0 Rasa SDK Version : 3.4.0 Python Version : 3.9.13

I think it is the latest one.

Hi @Omid

Yes interpreter module is deprecated in Rasa 3.x as Both NLU and CORE have been combined in 3.x version

To use only the NLU portion, Use this

from fastapi import FastAPI
from rasa.core.agent import Agent
app = FastAPI()

async def read_item(modelId: str, query: str):
    modelName = f'{modelId}_nlu.tar.gz'
    agent_nlu = Agent.load(modelName)
    message = await agent_nlu.parse_message(query)
    # print(message)

    return {"prediction_info": message}