Trying to change the locale in the Duckling Pipeline so the program can automatically change the locale based on the location that appears in an API. I don’t think I can dynamically change the config file, since I will have to run the rasa train all over again which takes time. Can’t reveal anything else due to the NDA I signed with the company I’m at.
When I check the documentation it seems like you can change the locale via config.yml
. Per docs:
pipeline:
- name: "DucklingEntityExtractor"
# url of the running duckling server
url: "http://localhost:8000"
# dimensions to extract
dimensions: ["time", "number", "amount-of-money", "distance"]
# allows you to configure the locale, by default the language is
# used
locale: "de_DE"
# if not set the default timezone of Duckling is going to be used
# needed to calculate dates from relative expressions like "tomorrow"
timezone: "Europe/Berlin"
# Timeout for receiving response from http url of the running duckling server
# if not set the default timeout of duckling http url is set to 3 seconds.
timeout : 3
You’re right to observe that this is static though.
Looking at the Docker container that hosts Duckling I see a small hint of something that could theoretically help. You could use the same container for different languages via;
$ curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&text=tomorrow at eight'
This suggests that you might be able to make a custom action, or a custom NLU component, that hooks into the container via this HTTP route.
I think the easiest is to use a custom action to connect to duckling and pass metadata to the rasa API where you can pass the locale you want.
I actually tried creating a custom NLU component, but Rasa’s current API don’t pass the metadata to Rasa NLU’s custom component (see the discussion here)
There is actually an open PR for this ISSUE-2801: Added support for passing dynamic timezone to Duckling component by shaswat-indian · Pull Request #8047 · RasaHQ/rasa · GitHub (or leat tackles some parts of the problem)