I am trying to run rasa run actions but receiving errors:
ModuleNotFoundError: No module named ‘myfunc’
Background:
I have created a new py file as myfunc.py with a simple program to return string.
I have imported myfunc.py in actions.py
but when I trigger the action server it fails with the error ModuleNotFoundError: No module named ‘myfunc’.
Actions.PY code:
from myfunc import *
from typing import Any, Text, Dict, List
#
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
a = my_function()
class ActionHelloWorld(Action):
def name(self) -> Text:
return "action_hello_test"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(a)
return []
@mayank2288 That’s quite strange whilst moving file outside from the actions folder which have action.py and __init__.py working fine with you. Normally all related files should be in the actions project folder in which the file is called.
Thank you . Yes, I can close the topic.
But just to check, if I am doing things correctly?
Is it the correct rasa way to call other py files from actions?
@mayank2288 for me and honest answer is “No” as a developer we normally put all the files in the actions.py folder (calling functions) its safe and easy to find and maintained. But as Chris says if this give your result and satisfied your use case or project its good to go. Good Luck!