Hi,
I’m trying to extract the sub-intent from a retrieval intent in an action using Rasa v3 but seems to error. There are no logs or errors on my action server only from the core.
I expect the logger to output the sub-intents ‘test’ or ‘test2’ from intents ‘faq/test2’ and ‘faq/test’.
Error below:
2022-11-22 19:09:55 ERROR rasa.core.processor - Encountered an exception while running action 'action_faq'.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/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 874, in _run_action
events = await action.run(
File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 741, in run
response: Any = await self.action_endpoint.request(
File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 164, in request
async with session.request(
File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 390, in _request
data = payload.JsonPayload(json, dumps=self._json_serialize)
File "/opt/venv/lib/python3.8/site-packages/aiohttp/payload.py", line 381, in __init__
dumps(value).encode(encoding),
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ndarray is not JSON serializable
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/rasa/core/tracker_store.py", line 1283, in save
await self._tracker_store.save(tracker)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/tracker_store.py", line 1186, in save
data=json.dumps(data),
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ndarray is not JSON serializable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/rasa/core/channels/rest.py", line 158, in receive
await on_new_message(
File "/opt/venv/lib/python3.8/site-packages/rasa/core/channels/channel.py", line 89, in handler
await app.ctx.agent.handle_message(message)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/agent.py", line 420, in handle_message
return await self.processor.handle_message( # type: ignore[union-attr]
File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 151, in handle_message
await self.save_tracker(tracker)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 980, in save_tracker
await self.tracker_store.save(tracker)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/tracker_store.py", line 1286, in save
await self.fallback_tracker_store.save(tracker)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/tracker_store.py", line 368, in save
serialised = InMemoryTrackerStore.serialise_tracker(tracker)
File "/opt/venv/lib/python3.8/site-packages/rasa/core/tracker_store.py", line 115, in serialise_tracker
return json.dumps(dialogue.as_dict())
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ndarray is not JSON serializable
I’ve looked through GitHub and there are no examples of this being done in v3. What is the correct way of accessing the sub-intent from within an action using v3?
Below is my setup. The action class is as follows:
class ActionFaq(Action):
def name(self):
return "action_faq"
def run(self, dispatcher, tracker, domain):
response_selector = tracker.latest_message.get("response_selector", {}).get("default", {}).get("response", {}).get("intent_response_key","/")
category, intent = response_selector.split("/")
logger.info(f"[{tracker.sender_id}] {__file__} : Inside action_faq : category = {category} ")
logger.info(f"[{tracker.sender_id}] {__file__} : Inside action_faq : intent = {intent} ")
return []
The domain is as follows:
version: '3.1'
intents:
- faq
actions:
- action_faq
The config is as follows:
recipe: default.v1
language: en
pipeline:
- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
analyzer: char_wb
min_ngram: 1
max_ngram: 4
- name: CountVectorsFeaturizer
analyzer: char
min_ngram: 3
max_ngram: 5
- name: DIETClassifier
epochs: 100
constrain_similarities: true
- name: EntitySynonymMapper
- name: FallbackClassifier
threshold: 0.4
- name: ResponseSelector
retrieval_intent: faq
scale_loss: false
epochs: 100
policies:
- name: MemoizationPolicy
- name: TEDPolicy
max_history: 5
epochs: 100
constrain_similarities: true
- name: RulePolicy
The NLU is as follows:
version: "3.1"
nlu:
- intent: faq/test
examples: |
- i want to test the response selector
- lets test the response selector
- i need to test the response selector
- intent: faq/test2
examples: |
- This should test 2 response selectors
- i SHOULD test response 2 selectors
The rules is as follows:
version: "3.1"
rules:
- rule: Rule for FAQ
steps:
- intent: faq
- action: action_faq