KeyError: "text"

Hello Guys,

I am facing this error after the latest update, If anyone could find out what it is?

ERROR
rasa.core.nlg.template - Failed to fill utterance template ‘{‘custom’: {‘messages’: [{‘suggestions’: [{‘payload’: ‘/business_function{“business_function_name”: “sales”}’, ‘title’: ‘sales’}, {‘payload’: ‘/business_function{“business_function_name”: “finance”}’, ‘title’: ‘finance’}], ‘type’: ‘suggestion_chips’}]}}’. Tried to replace ‘text’ but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template.
Traceback (most recent call last):
File “/home/krunal/.local/lib/python3.6/site-packages/rasa/core/nlg/template.py”, line 114, in _fill_template_text
text = re.sub(r"{([^\n]+?)}", r"{0[\1]}", template[“text”])
KeyError: 'text’

Thanks,
Krunal

Hello, jainkrunal

Do you have any utterance template with variable {text} in it ? Such as:

utter_something:
- text: I need to fix this {text}

It seems to me that you didn’t pass any value or there wasn’t any slot with the same name, so the variable {text} never get filled.

Hey @fuih,\ Thank you for getting back to me…

It’s not the case. I think the problem is with the slot that I am firing. But, I am not sure how to get solved it…

The way you set slots with payloads seems fine to me. And even if the slots didn’t get set, shouldn’t they still have None (or null) value ? I tried utter empty slot before and it still worked fine (it printed out None value but the program didn’t crash)

Hey there @jainkrunal, can you post how this custom template is defined, i.e. do you define it in your action server or in the domain? If in the action server, which dispatcher method are you using to utter it?

Here it is!!
image

Here ‘sample_intent’ is same as mentioned!! Also this error occurred after the update…

Thanks,
Krunal

Hmmm this is a good point. This would happen after the most recent update because we allowed interpolation of slots into everything including everything in custom. This is actually exactly what I had reservations about with this :sweat_smile: can you create a github issue please?

Hey @erohmensing,\

I had setup the new Virtual Environment to test and Now, it’s gone! I don’t know why but there is no error in Console.

But, had faced a warning about the library numpy deprecating the usage. It is appearing after installing pandas which, I think updated numpy. Snapshot for the same:

Same warning is thrown while running: rasa train, run, test, also for command while running action server.

Thanks,
Krunal

That’s strange that it’s disappeared :thinking:

The tensorflow issues should be okay, its just deprecated usage by some libraries that we use that need to update their usage. We would surpress the warnings but unfortunately they use print instead of log. Let me know if that creates some unexpected behavior though.

Yeah, It’s good for me that it disappeared :slightly_smiling_face:

No, It’s not and thanks for your kind help!!

Thanks,
Krunal

I permit myself to reopen that.

I used that:

  - text: "Foo"
    custom:
      data:
        attachment:
          type: template
          payload:
            template_type: generic
            elements:
            - title: "Bar"
              subtitle: ""
              image_url: 'img/myimage.jpg'
              default_action: 
                type: 'postback'
                payload: '/inform{"myentity": "bla"}'
              buttons:
              - title: "foo"
                type: postback
                payload: '/inform{"myentity": "bla"}'

And I got the error:

ERROR    rasa.core.nlg.interpolator  - Failed to fill utterance template '/inform{"myentity": "bla"}'. Tried to replace '"myentity": "bla"' but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template. 
Traceback (most recent call last):
  File "rasa/rasaenv02/lib/python3.7/site-packages/rasa/core/nlg/interpolator.py", line 18, in interpolate_text
    text = text.format(values)
KeyError: '"myentity": "bla"'

Using a syntax like “{{ }}” could be an idea for slot values replacement? (But I guess that would need a lot of changes)

Oh but actually {{ }} prevents interpolation, does it? At least it fixed my issue.

I don’t know if it’s a feature or using a bug but that works, so I use:

payload: '/inform{{"myentity": "bla"}}'
2 Likes

@n2718281 With rasa 2.0 I had the same problem. But the double curly brackets solved the problem for me. :+1:

1 Like