Rasa CALM is rephrasing all the utterances instead of rephrasing particular utterance

endpoints.yml

nlg: type: rephrase llm: type: “cohere” rephrase_all: true temperature: 0.1

domain.yml

utter_ask_user_pincode: - text: “Kindly give your pincode.” metadata: rephrase: True

utter_appointment_booked: - text: "Your appointment has been booked! We look forward to seeing you at {user_place}, {user_pincode}. "

even when I did not set “metadata: rephrase: True” for utter_appointment_booked, its rephrasing .

Please help me how to rephrase only particular utterances.

I think the issue is that you have set rephrase_all: True in the config for the rephraser in the endpoints.yml.

According to the docs, to only rephrase certain responses, you should set it like this:

endpoints.yml

nlg:
  type: rephrase
  rephrase_all: false

then it should only rephrase the utterances where you set rephrase: true like this:

utter_ask_user_pincode: 
  - text: “Kindly give your pincode.” 
    metadata: 
      rephrase: True

I tried the suggestion which was suggested.

but, am facing an error like below:

Batches: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 22.08it/s] unknown field: parameter model is not a valid field 2024-07-16 11:31:14 ERROR rasa.core.processor - Encountered an exception while running action ‘utter_flow_continue_interrupted’.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information. Traceback (most recent call last): File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/core/processor.py”, line 1243, in _run_action events = await action.run( File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/core/actions/action.py”, line 336, in run message = await nlg.generate( File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/core/nlg/contextual_response_rephraser.py”, line 265, in generate return await self.rephrase( File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/core/nlg/contextual_response_rephraser.py”, line 191, in rephrase history=await self._create_history(tracker), File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/core/nlg/contextual_response_rephraser.py”, line 164, in _create_history llm = llm_factory(self.nlg_endpoint.kwargs.get(“llm”), DEFAULT_LLM_CONFIG) File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/rasa/shared/utils/llm.py”, line 301, in llm_factory return load_llm_from_config(config.copy()) File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/langchain/llms/loading.py”, line 24, in load_llm_from_config return llm_cls(**config) File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/langchain/load/serializable.py”, line 97, in init super().init(**kwargs) File “/Users/sivasegu/Desktop/rasa_calm/venv/lib/python3.10/site-packages/pydantic/v1/main.py”, line 341, in init raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for Cohere rephrase_all extra fields not permitted (type=value_error.extra)

endpoints,yml

nlg: type: rephrase llm: type: “cohere” rephrase_all: False

domain.yml

utter_husqrana: - text: “ENGINE: Single Cylinder, 4-stroke, 4 V DOHC Engine Displacement - 248.76 cc Price: Rs. 291,119” metadata: rephrase: True

When I try to utter - utter_husqrana. its doesn’t display the message and throws error.

Can anyone help me how to resolve this?

Looking at the error. rephrase_all key should not be under the llm section. It should look like below:

nlg: 
    type: rephrase 
    rephrase_all: False
    llm: 
        type: “cohere” 

I have tried what you had shared in the endpoints.yml and now it is rephrasing too much into paras of content which I don’t need.

How to restrict the rephrasing content to minimum?

@sk1382 I would recommend customizing the prompt for the rephraser to instruct the LLM to be more brief:

here’s some tips for prompt engineering if you’re not so familiar with it. it’s better to give the LLM succinct instructions about what you want.