Use Rasa as a thirdparty module

Hi. Is there any way that I can use rasa nlu like a thirdparty module and using it like “from rasa.nlu import parse”, instead of running a sanic web server?

Hi @QuantumCoder ,

If you do not want to run Rasa and just want to use the NLU part of the model as third party, You can do that simply like this using FastAPI framework ( You can choose any framework )

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}

Great! That’s exactly I want. Meanwhile, I almost got through all the rasa docs and found another way yesterday: use RasaNLUInterpreter Objects in rasa.core.interpreter(rasa.core.interpreter). But sadly I found it seems being removed in the latest version. So is this still available or it is really removed?

Hi @QuantumCoder ,

You can use the Agent class and its method and it will work the same.