Could someone explain the servers, actions, and model loading please?

Could someone who has already created a bot that can perform custom actions please explain to me step by step what needs to be done to get to that point? The documentation only talks about sections at a time and I can’t wrap my head around the entire process that needs to be done.

I can get to the point where the bot can do utterances but I can’t make it do custom actions, it always says sanic.exceptions.NotFound: Requested URL /webhook not found and Encountered an exception while running action 'action_joke'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information. but I can’t find the logs.

I also can’t make the model loading happen - at least I didn’t add my model to the bot, so I’m not even sure if it uses my model (which would be bad because my model is Hungarian and the default language is English). I found that the model loading should be added to rasa run but that only opens another server which uses the same port as rasa shell so I can’t run the shell after that.

Whoever can explain this to me, I’d greatly appreciate it. Thanks.

Hey @ggabor, just check out this video hope it helps :slight_smile:

1 Like

Thank god for this video, and thank you too for showing me! Finally I understand how it works, and I could find the error of my actions code in the action server’s output, fixed it, now my custom action works properly! :smiley: I’m so happy! Thank you.

Now what I’m not sure about is whether my bot is trained on my Hungarian model or not. How can I check that?

Can you tell me how you have prepared your training data i.e nlu.md file, what lanugage you are using for preparing the training data?

The nlu.md file contains Hungarian sample sentences for every intent. But there is a language model I got form FastText what I converted to SpaCy compatible format with 2 million vectors, I just don’t think that the bot gets trained based on that model - rather it is most likely trained in English.

Nothing in config.yml says that my model file (called cc.hu.300.vec.gz) is being used for anything.

In the endpoints.yml file there is a segment to load models from server - but my model is on my computer, I’m just not sure if it gets used. Where should it be placed and how should it be added to the bot?

Once you have trained your model, it is stored in models folder within your project directory and you can load your models which are stored on your local system by running the below command:

rasa run -m models --enable-api --log-file out.log

The different parameters are:

  • -m : the path to the folder containing your Rasa model,
  • --enable-api : enable this additional API, and
  • --log-file : the path to the log file.

Well, this doesn’t look good. I placed my model file into the models folder and ran rasa run -m models --enable-api --log-file out.log, this is the result:

2019-10-05 16:14:57 INFO     numexpr.utils  - NumExpr defaulting to 4 threads.
2019-10-05 16:15:08 INFO     root  - Starting Rasa server on http://localhost:5005
[2019-10-05 16:15:39 +0200] [11132] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\site-packages\sanic\app.py", line 1096, in run
    serve(**server_settings)
  File "c:\programdata\anaconda3\lib\site-packages\sanic\server.py", line 742, in serve
    trigger_events(before_start, loop)
  File "c:\programdata\anaconda3\lib\site-packages\sanic\server.py", line 604, in trigger_events
    loop.run_until_complete(result)
  File "c:\programdata\anaconda3\lib\asyncio\base_events.py", line 579, in run_until_complete
    return future.result()
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\run.py", line 227, in load_agent_on_start
    None, endpoints.tracker_store, _broker
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 46, in find_tracker_store
    domain=domain, host=store.url, event_broker=event_broker, **store.kwargs
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 229, in __init__
    self._ensure_indices()
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 236, in _ensure_indices
    self.conversations.create_index("sender_id")
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 1995, in create_index
    self.__create_index(keys, kwargs, session, **cmd_options)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 1881, in __create_index
    with self._socket_for_writes(session) as sock_info:
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 195, in _socket_for_writes
    return self.__database.client._socket_for_writes(session)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1267, in _socket_for_writes
    server = self._select_server(writable_server_selector, session)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1254, in _select_server
    server = topology.select_server(server_selector)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 231, in select_server
    address))
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 189, in select_servers
    selector, server_timeout, address)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 205, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\rasa.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\rasa\__main__.py", line 76, in main
    cmdline_arguments.func(cmdline_arguments)
  File "c:\programdata\anaconda3\lib\site-packages\rasa\cli\run.py", line 88, in run
    rasa.run(**vars(args))
  File "c:\programdata\anaconda3\lib\site-packages\rasa\run.py", line 56, in run
    **kwargs
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\run.py", line 199, in serve_application
    backlog=int(os.environ.get("SANIC_BACKLOG", "100")),
  File "c:\programdata\anaconda3\lib\site-packages\sanic\app.py", line 1096, in run
    serve(**server_settings)
  File "c:\programdata\anaconda3\lib\site-packages\sanic\server.py", line 742, in serve
    trigger_events(before_start, loop)
  File "c:\programdata\anaconda3\lib\site-packages\sanic\server.py", line 604, in trigger_events
    loop.run_until_complete(result)
  File "c:\programdata\anaconda3\lib\asyncio\base_events.py", line 579, in run_until_complete
    return future.result()
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\run.py", line 227, in load_agent_on_start
    None, endpoints.tracker_store, _broker
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 46, in find_tracker_store
    domain=domain, host=store.url, event_broker=event_broker, **store.kwargs
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 229, in __init__
    self._ensure_indices()
  File "c:\programdata\anaconda3\lib\site-packages\rasa\core\tracker_store.py", line 236, in _ensure_indices
    self.conversations.create_index("sender_id")
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 1995, in create_index
    self.__create_index(keys, kwargs, session, **cmd_options)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 1881, in __create_index
    with self._socket_for_writes(session) as sock_info:
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\collection.py", line 195, in _socket_for_writes
    return self.__database.client._socket_for_writes(session)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1267, in _socket_for_writes
    server = self._select_server(writable_server_selector, session)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1254, in _select_server
    server = topology.select_server(server_selector)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 231, in select_server
    address))
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 189, in select_servers
    selector, server_timeout, address)
  File "c:\programdata\anaconda3\lib\site-packages\pymongo\topology.py", line 205, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it
sys:1: RuntimeWarning: coroutine 'BaseEventLoop.create_server' was never awaited

Strange I never faced this issue :sweat_smile:, have you placed the tar file?

I noticed a lot of pymongo-related things in the error message so I checked my mongod, it turns out it wasn’t running. I restarted it, now the same command results in this:

2019-10-05 16:23:36 INFO     numexpr.utils  - NumExpr defaulting to 4 threads.
2019-10-05 16:23:40 INFO     root  - Starting Rasa server on http://localhost:5005
2019-10-05 16:23:41 WARNING  rasa.core.agent  - Could not load local model in 'models'

and then it seemingly stops, does nothing - doesn’t quit either, just… does nothing observable.

So, my models folder now contains cc.hu.300.vec.gz which is a spacy-compatible model. What’s the issue?

I think so the model which you have placed is not rasa compatible model

Have you trained the models using rasa commands?

Okay, I think we have to clarify something.
What I’m talking about is not the model what the rasa train command generates. I’m talking about the core language corpus what bots generally use to learn more deeply about how to communicate in a given language. At the very least in earlier versions Rasa had such a thing too, I saw it on older introduction videos. And right now Rasa has a config.yml file where the default values are these:

language: en
pipeline: supervised_embeddings_spacy

I imagine this refers to an English language spacy corpus (or model, or whatever it should be called) what the bot loads to integrate it into its learning process. This is what I want to change to Hungarian, this is for which I have downloaded a file from FastText and converted it into the same format the SpaCy files are in. The question is how can I add it to the bot so it learns from Hungarian sentences and not English - or possibly the question is what am I misunderstanding.

Ok so I think so this doc can help you out:

https://rasa.com/docs/rasa/nlu/language-support/#spacy

Yes, I saw this page. It says " With the pretrained_embeddings_spacy pipeline, you can use spaCy’s pre-trained language models or load fastText vectors, which are available for hundreds of languages."

What it doesn’t say is how to do that. I mean, sure, it has 1 sentence about the overall general concept of doing it, but who knows the details?

Spacy had no Hungarian language models, so I downloaded one from FastText and converted it to Spacy format. But I found no information whatsoever about what to do with this file after that.

I give you an illustration for this problem what my bot just produced, so you see why this matters.
I test my bot functions with a simple custom action that returns the day of the week of a given day.

The following is a valid Hungarian sentence that means “what day will be 10 days from now”:

milyen nap lesz 10 nap múlva

Hungarians, especially younger generation and when typing on phones, tend to omit the accent of characters, which would result in a sentence like this:

milyen nap lesz 10 nap mulva

The first sentence is in my nlu.md file and properly returns Kedd lesz. (it’ll be Tuesday). The second sentence is not in the nlu file and instead of finding the similarity between the two sentences based on a Hungarian corpus, the program decides not to return squat.

A single accent means the difference between a capable and an incapable bot, which I believe is because the bot learns communication based on a language other than what the inputs come in. So please help me fix this.

Why don’t you try supervsied embeddings,

Why don’t I try… primarily because there’s a single paragraph about the entire thing in the docs, which is painfully inadequate to explain how it works. There’s a link there to the details - to the 1.5 years old article you also linked (and we know how much Rasa can change in that time) - which also doesn’t give details on the how-to, it only explains the principles, the theory, and its benefits.

When you add an external file to a software there is at the very least one of two things you need to know:

  1. Where do you have to place the file so the code can pick it up automatically, or
  2. Where and how to reference the file in the code

I haven’t found info on either.