Hey guys I just upgraded my rasa from 1.12 to 1.9.6.
Earlier it was all good but after upgrading I’m getting this error while running the action server
Traceback (most recent call last):
File "C:\Users\91973\Anaconda3\envs\chatbot\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\91973\Anaconda3\envs\chatbot\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\91973\Anaconda3\envs\chatbot\lib\site-packages\rasa_core_sdk\endpoint.py", line 14, in <module>
from rasa_core_sdk.executor import ActionExecutor
File "C:\Users\91973\Anaconda3\envs\chatbot\lib\site-packages\rasa_core_sdk\executor.py", line 14, in <module>
from rasa_core_sdk import utils, Action, Tracker
ImportError: cannot import name 'Action'
from typing import Any, Text, Dict, List
from rasa_core_sdk import Action
from rasa_core_sdk import Tracker
from rasa_core_sdk.events import SlotSet
from rasa_sdk.executor import CollectingDispatcher
class MedicalNecessity(Action):
def name(self) -> Text:
return "action_necessity"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
incident_no = tracker.get_slot('incident_no')
# from database medical necessity reason is fetched and stored in 'reason' variable
reason = 'xyz'
bot_response = " For {} incident number the medical necessity reason is {}".format(incident_no, reason)
dispatcher.utter_message(text=bot_response)
return [SlotSet('incident_no', incident_no)]
class ServiceLevel(Action):
def name(self) -> Text:
return "action_service"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
incident_no = tracker.get_slot('incident_no')
# from database service level is fetched and stored in 'level' variable
level = 123
bot_response = " For {} incident number the level of service is {}".format(incident_no, level)
dispatcher.utter_message(text=bot_response)
return [SlotSet('incident_no', incident_no)]
class NecessityAndService(Action):
def name(self) -> Text:
return "action_necessity_service"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
incident_no = tracker.get_slot('incident_no')
# from database medical necessity reason is fetched and stored in 'reason' variable
# service level is fetched and stored in 'level' variable
reason = 'abc'
level = 123
bot_response = " For {} incident number the medical necessity reason is {} and level of service is {}".format(
incident_no, reason, level)
dispatcher.utter_message(text=bot_response)
return [SlotSet('incident_no', incident_no)]