Facing syntax error with custom action in rasa open source

Hello, I’m facing some issues with syntax error with custom actions in rasa open source , please help me out . I have attached files related to this issue

## this is the actions.py file
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class area_options(Action):
    def name (self) -> Text:
        return "action_area_buttons"

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text,Any]) -> List[Dict[Text, Any]]:
        value = tracker.get_slot("area_travel")
        if value == 'Domestic': 
            dispatcher.utter_message(response= "utter_domestic_packages")
        elif value == 'International':                     
            dispatcher.utter_message(response= "utter_international_packages")


Hi @Venkat

Class always will be capital

class AreaOptions(Action):

Use template rather then response, if new update is enforce you to use response then fine

dispatcher.utter_message(template= "utter_domestic_packages")
dispatcher.utter_message(template= "utter_international_packages")


return [ ] at the end

ok , let me try that

Actually I got this error while training a model , so I don’t think it does include actions .py file in the training process

@Venkat you not shared the error Venkat ? please share the error screenshot also @Venkat update in first post with error also

really sorry about that

## this is the error log

Traceback (most recent call last):
  File "/home/venkat/Desktop/Rasa/Rasaproject/bin/rasa", line 5, in <module>
    from rasa.__main__ import main
  File "/home/venkat/Desktop/Rasa/Rasaproject/lib/python3.8/site-packages/rasa/__main__.py", line 10, in <module>
    import rasa.telemetry
  File "/home/venkat/Desktop/Rasa/Rasaproject/lib/python3.8/site-packages/rasa/telemetry.py", line 18, in <module>
    import requests
  File "/home/venkat/Desktop/Rasa/Rasaproject/lib/python3.8/site-packages/requests/__init__.py", line 116
    from .__version__ import __- title__, __description__, __url__, __version__
SyntaxError: invalid syntax

@Venkat Please share rasa version rasa --version

@Venkat I hope you activated the conda environment ? and then running the command?

yeah , I’m sure it is an error with installation of rasa because im getting the same error whenever I invoke rasa

yes , venv is activated

@Venkat install pip install rasa==2.8.2 and then run rasa --version and share me output please.


I guess my virtual env is corrupted

@Venkat type python --version share output?

my python version is 3.8

(Rasaproject) venkat@venkat:~/Desktop/Rasa$ python --version
Python 3.8.10

@Venkat where strange :thinking:

@Venkat can you quickly create new condo environment please

  1. conda create -n “Your_Environment_Name” python=3.7 or 3.8
  2. conda activate Your_Environment_Name
  3. pip install rasa==2.8.1

Share me output please.

can I use python environment

Yes you can use a regular Python virtual environment or even no virtual environment at all (not recommended if you want to have multiple Python projects).

Just try to create a fresh venv and do:

pip install rasa rasa-x -i https://pypi.rasa.com/simple

If you get any error (in red) that you cannot solve, please get back to us.

Sure , Thank you very much for the reply

1 Like

@Venkat Please close this one also please as a solution for others Venkat.

sure , I have marked it as a solution and thanks once again for the help