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

Hi,

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()

 
 
@app.get("/predictText")
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}

Hi, this doesn’t work as expected.

So I used rasa form for my bot. so here is the scenario

  • user - I need have issue with XYZ system
  • bot - Could you please describe your issue?
  • user - describe issue
  • bot - provide help using my backend.

This flow works fine in Rasa Shell but not with the code you have provide. I have a slot which I am feeling based on what user types. In the rasa shell it keep asking until user describe the issue. Using the code above, if I pass my text I need have issue with XYZ system it just get me the intent name and confidence doesn’t return me the next step.

Any help would be appreciated.

Hi, @hirakpatel05

The above code is just for finding out the nlu details for each query

As mentioned above. NLU is not responsible for telling the next response. It only tells what is the intent that has been detected for the user query and the confidence of that detected intent.