I configured the framework on GCP AI. While running action server, it runs without any issue. I used Rachel Tatman code for connecting to database. When I try to get answers from bot, I am getting below error.
2022-02-02 17:00:52 ERROR rasa.core.processor - Encountered an exception while running action 'query_resource'.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 "/opt/conda/lib/python3.7/site-packages/rasa/core/actions/action.py", line 723, in run
json=json_body, method="post", timeout=DEFAULT_REQUEST_TIMEOUT
File "/opt/conda/lib/python3.7/site-packages/rasa/utils/endpoints.py", line 174, in request
response.status, response.reason, await response.content.read()
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'<!DOCTYPE html><html lang=en><meta charset=UTF-8><title>\xe2\x9a\xa0\xef\xb8\x8f 404 \xe2\x80\x94 Not Found</title>\n<style>\n html { font-family: sans-serif }\n h2 { color: #888; }\n .tb-wrapper p { margin: 0 }\n .frame-border { margin: 1rem }\n .frame-line > * { padding: 0.3rem 0.6rem }\n .frame-line { margin-bottom: 0.3rem }\n .frame-code { font-size: 16px; padding-left: 4ch }\n .tb-wrapper { border: 1px solid #eee }\n .tb-header { background: #eee; padding: 0.3rem; font-weight: bold }\n .frame-descriptor { background: #e2eafb; font-size: 14px }\n </style>\n<h1>\xe2\x9a\xa0\xef\xb8\x8f 404 \xe2\x80\x94 Not Found</h1><p>Requested URL not found\n''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/rasa/core/processor.py", line 869, in _run_action
output_channel, nlg, temporary_tracker, self.domain
File "/opt/conda/lib/python3.7/site-packages/rasa/core/actions/action.py", line 746, in run
raise RasaException("Failed to execute custom action.") from e
rasa.shared.exceptions.RasaException: Failed to execute custom action.
@gayatrikandula for query_resource are you using .csv file or in custom action what code you have written for fetching the data, can you share the code, please?
@gayatrikandula can you also share rasa --version and your use case example?
Rasa Version : 3.0.6
Minimum Compatible Version: 3.0.0
Rasa SDK Version : 3.0.4
Rasa X Version : None
Python Version : 3.7.10
Operating System : Linux-4.19.0-18-cloud-amd64-x86_64-with-debian-10.11
Python Path : /opt/conda/bin/python3.7
This is my Queryresource from actions.py:
class QueryResource(Action):
def name(self) -> Text:
return "query_resource"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
"""
Runs a query using both the topic & type columns (fuzzy matching against the
relevent slots). Finds a match for both if possible, otherwise a match for the
type only, topic only in that order. Output is an utterance directly to the
user with a randomly selected matching row.
"""
conn = DbQueryingMethods.create_connection(db_file="resourcesDB")
# get matching entries for resource type
resource_type_value = tracker.get_slot("resource_type")
# make sure we don't pass None to our fuzzy matcher
if resource_type_value == None:
resource_type_value = " "
resource_type_name = "Type"
resource_type_value = DbQueryingMethods.get_closest_value(conn=conn,
slot_name=resource_type_name,slot_value=resource_type_value)[0]
query_results_type = DbQueryingMethods.select_by_slot(conn=conn,
slot_name=resource_type_name,slot_value=resource_type_value)
# get matching for resource topic
resource_topic_value = tracker.get_slot("resource_topic")
# make sure we don't pass None to our fuzzy matcher
if resource_topic_value == None:
resource_topic_value = " "
resource_topic_name = "Topic"
resource_topic_value = DbQueryingMethods.get_closest_value(conn=conn,
slot_name=resource_topic_name,slot_value=resource_topic_value)[0]
query_results_topic = DbQueryingMethods.select_by_slot(conn=conn,
slot_name=resource_topic_name,slot_value=resource_topic_value)
# intersection of two queries
topic_set = collections.Counter(query_results_topic)
type_set = collections.Counter(query_results_type)
query_results_overlap = list((topic_set & type_set).elements())
# apology for not having the right info
apology = "I couldn't find exactly what you wanted, but you might like this."
# return info for both, or topic match or type match or nothing
if len(query_results_overlap)>0:
return_text = DbQueryingMethods.rows_info_as_text(query_results_overlap)
elif len(list(query_results_topic))>0:
return_text = apology + DbQueryingMethods.rows_info_as_text(query_results_topic)
elif len(list(query_results_type))>0:
return_text = apology + DbQueryingMethods.rows_info_as_text(query_results_type)
else:
return_text = DbQueryingMethods.rows_info_as_text(query_results_overlap)
# print results for user
dispatcher.utter_message(text=str(return_text))
return
I imported .csv file to sqlite resourcesDB database as Rachel was explaining in her videos