Skip to content

Instantly share code, notes, and snippets.

@samrudh
Last active January 13, 2023 07:46
Show Gist options
  • Save samrudh/c2ed7c4920425c82e92ed845d63f6811 to your computer and use it in GitHub Desktop.
Save samrudh/c2ed7c4920425c82e92ed845d63f6811 to your computer and use it in GitHub Desktop.
integration of rasa model function
from rasa.nlu.model import Interpreter
# path of your model
rasa_model_path = "<path-to-you-model-untar-directory>/nlu"
# create an interpreter object
interpreter = Interpreter.load(rasa_model_path)
"""
Function to get model output
Args:
text (string) -- input text string to be passed)
For example: if you are interested in entities, you can just write result['entities']
Returns:
json -- json output to used for accessing model output
"""
def rasa_output(text):
message = str(text).strip()
result = interpreter.parse(message)
return result
rasa_output("<my-text-input-content-for-the-model>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment