Hello, I’m trying to change incoming message of the user in custom component added to pipeline. Component works when returning unchanged message, so it’s working properly, but I don’t know how to set message parameter. I want to totally override incoming message with different string. My component looks like this:
# TODO: Correctly register your component with its type
@DefaultV1Recipe.register(
[DefaultV1Recipe.ComponentType.INTENT_CLASSIFIER], is_trainable=True
)
class Translate(GraphComponent):
@classmethod
def create(
cls,
config: Dict[Text, Any],
model_storage: ModelStorage,
resource: Resource,
execution_context: ExecutionContext,
) -> GraphComponent:
# TODO: Implement this
...
def train(self, training_data: TrainingData) -> Resource:
# TODO: Implement this if your component requires training
...
def process_training_data(self, training_data: TrainingData) -> TrainingData:
# TODO: Implement this if your component augments the training data with
# tokens or message features which are used by other components
# during training.
return training_data
def process(self, messages: List[Message]) -> List[Message]:
# TODO: This is the method which Rasa Open Source will call during inference.
messages.text = translator.translate(messages, src="es", dest="en").text
return messages
But seems like this solution doesn’t work. Neither does this one:
changed = translator.translate("custom message, dosnt matter", src="es", dest="en").text
messages.set('text', changed, add_to_output = True)
Throwed error:
rasa.engine.exceptions.GraphComponentException: Error running graph component for node run_translation.Translate0.