I want to create a custom component for a Multilingual bot but I get the error
‘No module named rasa.nlu.components’
when I try
from rasa.nlu.components import Components
I got the same error and I don’t see any solution for it. @minju?
I think mostly it is a version mismatch error…
But I don’t know which version would be most suitable. I am not even getting any help from the github developer community.
Please let me know as soon as you get the solution…
I know it worked when I downgraded rasa to 2.8.3 or 2.6 ! But I need to work with the latest release of rasa so I just don’t know how to find an alternative to that problem… Finally, for the moment, I just gave up with the custom component
@minji - please migrate your custom components to graph component in Rasa 3.x
same issue in 3.5.1
Lets say you wanted to make a component, that would lower_case an incoming query.
\middleware\lower_case.py
from typing import List
from rasa.engine.graph import GraphComponent
from rasa.shared.nlu.constants import TEXT
from rasa.shared.nlu.training_data.message import Message
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
@DefaultV1Recipe.register(
component_types=[DefaultV1Recipe.ComponentType.INTENT_CLASSIFIER],
is_trainable=False,
)
class TextCorrectionMiddleware(GraphComponent):
def __init__(self, component_config=None):
super().__init__(component_config)
def process(self, messages: List[Message], **kwargs) -> List[Message]:
for message in messages:
text = message.get(TEXT)
if text:
print(f"Original Text: {text}") # Print original text
message.set(TEXT, text.lower())
print(f"Lowercased Text: {message.get(TEXT)}")
return messages
in config.yml:
pipeline:
- name: middleware.lower_case.TextCorrectionMiddleware
- name: WhitespaceTokenizer
- name: RegexFeaturizer
***** REST OF THE CODE ******