Hello,
I was following the instruction from rasa website and had an error saying"TypeError: Parameters to generic types must be types. Got slice(<class ‘str’>, typing.Union[typing.Dict, typing.List[typing.Dict]], None).". It seems there is an error in slot_mappings function and no idea how to fix it. This has bothered me for a long time and really appreciate your help.
This is from actions.py:
from typing import Dict, Text, Any, List, Union, Optional, Tuple from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.forms import FormAction from rasa_sdk import Action from rasa_sdk.events import UserUtteranceReverted import typing
class SalesForm(FormAction): “”“Collects sales information and adds it to the spreadsheet”“”
def name(self) -> Text:
return "sales_form"
@staticmethod
def required_slots(tracker) -> List[Text]:
return [
"job_function",
"use_case",
"budget",
"person_name",
"company",
"business_email",
]
def slot_mappings(self) -> Dict[Text: Union[Dict, List[Dict]]]:
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {"use_case": self.from_text(intent="inform")}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
dispatcher.utter_message("Thanks for getting in touch, we’ll contact you soon")
return []
The error message after “rasa run actions”:
(rasa) C:\rasa-assistant_1>rasa run actions
TypeError: Parameters to generic types must be types. Got slice(<class ‘str’>, typing.Union[typing.Dict, typing.List[typing.Dict]], None).
The website of rasa instruction: