Rasa Core version: 0.11.7
Python version: 3.6.5
Operating system : ubuntu 16.04
Issue: Custom action not working
Content of actions.py :
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionCheckRestaurants(Action):
def name(self):
return "action_check_restaurants"
def run(self, dispatcher, tracker, domain):
dispatcher.utter_message("nothing ")
if tracker.get_slot('city'):
dispatcher.utter_message("check restaurant action being called ..")
else:
dispatcher.utter_message("no restaurant being called")
return [ ]
Content of endpoints.yml file :
action_endpoint:
url: "http://localhost:5055/webhook"
Output of debug mode
I am looking for restaurants in new york city
2018-10-04 15:58:58 DEBUG rasa_core.tracker_store - Recreating tracker for id 'default'
2018-10-04 15:58:58 DEBUG rasa_core.processor - Received user message 'I am looking for restaurants in new york city' with intent '{'name': 'findRestaurantsByCity', 'confidence': 0.8807270526885986}' and entities '[{'start': 32, 'end': 40, 'value': 'new york', 'entity': 'city', 'confidence': 0.895800285339971, 'extractor': 'ner_crf'}]'
2018-10-04 15:58:58 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 7 events
2018-10-04 15:58:58 DEBUG rasa_core.processor - Current slot values:
city: new york
2018-10-04 15:58:58 DEBUG rasa_core.policies.memoization - Current tracker state [None, {}, {'slot_city_0': 1.0, 'intent_findRestaurantsByCity': 1.0, 'prev_action_listen': 1.0, 'entity_city': 1.0}, {'slot_city_0': 1.0, 'prev_action_check_restaurants': 1.0, 'intent_findRestaurantsByCity': 1.0, 'entity_city': 1.0}, {'slot_city_0': 1.0, 'intent_findRestaurantsByCity': 1.0, 'prev_action_listen': 1.0, 'entity_city': 1.0}]
2018-10-04 15:58:58 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-04 15:58:58 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2018-10-04 15:58:58 DEBUG rasa_core.processor - Predicted next action 'action_check_restaurants' with prob 0.61.
2018-10-04 15:58:58 ERROR rasa_core.processor - Encountered an exception while running action 'action_check_restaurants'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2018-10-04 15:58:58 ERROR rasa_core.processor - The model predicted the custom action 'action_check_restaurants' but you didn't configure an endpoint to run this custom action. Please take a look at the docs and set an endpoint configuration. https://rasa.com/docs/core/customactions/
Traceback (most recent call last):
File "/home/ramesh/anaconda3/lib/python3.6/site-packages/rasa_core/processor.py", line 324, in _run_action
events = action.run(dispatcher, tracker, self.domain)
File "/home/ramesh/anaconda3/lib/python3.6/site-packages/rasa_core/actions/action.py", line 305, in run
"".format(self.name(), DOCS_BASE_URL))
Exception: The model predicted the custom action 'action_check_restaurants' but you didn't configure an endpoint to run this custom action. Please take a look at the docs and set an endpoint configuration. https://rasa.com/docs/core/customactions/
2018-10-04 15:58:58 DEBUG rasa_core.processor - Action 'action_check_restaurants' ended with events '[]'
2018-10-04 15:58:58 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {'slot_city_0': 1.0, 'intent_findRestaurantsByCity': 1.0, 'prev_action_listen': 1.0, 'entity_city': 1.0}, {'slot_city_0': 1.0, 'prev_action_check_restaurants': 1.0, 'intent_findRestaurantsByCity': 1.0, 'entity_city': 1.0}, {'slot_city_0': 1.0, 'intent_findRestaurantsByCity': 1.0, 'prev_action_listen': 1.0, 'entity_city': 1.0}, {'slot_city_0': 1.0, 'prev_action_check_restaurants': 1.0, 'intent_findRestaurantsByCity': 1.0, 'entity_city': 1.0}]
2018-10-04 15:58:58 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-04 15:58:58 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_KerasPolicy
2018-10-04 15:58:58 DEBUG rasa_core.processor - Predicted next action 'action_listen' with prob 0.99.
2018-10-04 15:58:58 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2018-10-04 15:58:58] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 122 0.023412
I tried all the existing solutions, but nothing is working in my case. Can anyone please help with this?
are you passing the endpoints.yml file to rasa core when starting it?
I am doing following steps:
I am using trained model with the help of this code (use_core_model.py):
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import logging
import json
from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.interpreter import RasaNLUInterpreter
import sys
import argparse
import warnings
import ruamel.yaml as yaml
warnings.simplefilter('ignore', yaml.error.UnsafeLoaderWarning)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='start chattting with bot')
parser.add_argument('message')
message = parser.parse_args().message
# print ("message ", message)
# message = sys.argv[1]
# print ("message ", message)
model_path = './models/dialogue'
nlu_interpreter = RasaNLUInterpreter('./projects/default/default/Neo4jNlu')
parsed_nlu_msg = nlu_interpreter.interpreter.parse(message)
print(json.dumps(parsed_nlu_msg, indent=2))
# print ("NLU response ", nlu_interpreter.parse(msg))
print ("---------------------- chat bot response ------------------------------")
agent = Agent.load(model_path, interpreter = nlu_interpreter)
print (agent.handle_text(message))
In one terminal, I am executing
python use_core_model.py "I am looking for restaurants in new york city"
In second terminal, I am running action server
python -m rasa_core_sdk.endpoint --actions actions
I am not sure about to how to pass endpoints.yml to rasa core?
@akelad custom action is working when I am running in one terminal:
python -m rasa_core.run \
--enable_api \
-d models/dialogue \
-u models/nlu/current \
--endpoints my_endpoints.yaml \
-o out.log
second terminal running action server:
python -m rasa_core_sdk.endpoint --actions actions
But I have another doubt, when I execute python use_core_model.py "I am looking for restaurants in new york city" why core response does not return anything. This is my updated actions.py
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionCheckRestaurants(Action):
def name(self):
return "action_check_restaurants"
def run(self, dispatcher, tracker, domain):
dispatcher.utter_message("notthing ")
if tracker.get_slot('city'):
result = "It got executed"
dispatcher.utter_message("check restaurant action being called ..")
else:
failure = "slot does not detected"
dispatcher.utter_message("no restaurant being called")
return [SlotSet("city", result if result is not None else failure)]
Thanks for your time :)
what do you mean it doesn't return anything? what happens?
when I execute python use_core_model.py "I am looking for restaurants in new york city",
(agent.handle_text(message)) returns [ ] even intent detected by NLU is correct.
My guess is because you haven't configured any endpoints for custom actions there in your python script. Is there any reason you would want to use this instead of starting core on the commandline?
I have the same problem. I guess it's endpoint problems. so how can I configure endpoints for action?
Please read the documentation here https://rasa.com/docs/core/customactions/#custom-actions
@rameshjesswani has your original issue been solved or do you need more help?
thanks very much. its resolved.
thanks very much. its resolved.
how did u resolve this issue?
thanks very much. its resolved.
how did u resolve this issue?
I had the same issue.
i solved configuring the endpoint URL in the python script like that:
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
core_endpoint_config = EndpointConfig(url='http://localhost:5055/webhook')
interpreter = RasaNLUInterpreter('models/current/nlu')
agent = Agent.load('models/current/dialogue', interpreter=interpreter,
action_endpoint = core_endpoint_config)
while True:
a = input("Eu: ")
messages.append(a)
if a == 'stop':
break
responses = agent.handle_message(a)
for r in responses:
answer = r.get("text")
messages.append(answer)
print("Bot: " + answer)
i hope that helps
thanks very much. its resolved.
how did u resolve this issue?
I had the same issue.
i solved configuring the endpoint URL in the python script like that:from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter from rasa_core.utils import EndpointConfig core_endpoint_config = EndpointConfig(url='http://localhost:5055/webhook') interpreter = RasaNLUInterpreter('models/current/nlu') agent = Agent.load('models/current/dialogue', interpreter=interpreter, action_endpoint = core_endpoint_config) while True: a = input("Eu: ") messages.append(a) if a == 'stop': break responses = agent.handle_message(a) for r in responses: answer = r.get("text") messages.append(answer) print("Bot: " + answer)i hope that helps
Saved my day 馃憤
Most helpful comment
I had the same issue.
i solved configuring the endpoint URL in the python script like that:
i hope that helps