so i wanna make rasabot but rasabot take answer from file format json. my json
[
{
"id" : "1",
"nama" : "Aiyub Heriyanto",
"jurusan" : "Rekayasa Perangkat Lunak",
"intent" : "siswa_1"
},
{
"id" : "2",
"nama" : "Afand Fathur Rozi",
"jurusan" : "MultiMedia",
"intent" : "siswa_2"
},
{
"id" : "3",
"nama" : "Dhony Fajriansyah",
"jurusan" : "Manajamen Perkantoran",
"intent" : "siswa_3"
}
]
my action.py
import json
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionGetStudentInfo1(Action):
def name(self) -> Text:
return "action_siswa_1"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# Baca file JSON
with open('data/json/answer.json', 'r') as f:
data = json.load(f)
# Temukan data yang sesuai dengan intent
for student in data:
if student['jurusan'] == 'Rekayasa Perangkat Lunak':
# Kirim respons ke pengguna
dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
break
return []
class ActionGetStudentInfo2(Action):
def name(self) -> Text:
return "action_siswa_2"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# Baca file JSON
with open('data/json/answer.json', 'r') as f:
data = json.load(f)
# Temukan data yang sesuai dengan intent
for student in data:
if student['jurusan'] == 'MultiMedia':
# Kirim respons ke pengguna
dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
break
return []
class ActionGetStudentInfo3(Action):
def name(self) -> Text:
return "action_siswa_3"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# Baca file JSON
with open('data/json/answer.json', 'r') as f:
data = json.load(f)
# Temukan data yang sesuai dengan intent
for student in data:
if student['jurusan'] == 'Manajemen Perkantoran':
# Kirim respons ke pengguna
dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
break
return []
my nlu.yml
version: "3.1"
nlu:
- intent: greet
examples: |
- hey
- hello
- hi
- hello there
- good morning
- good evening
- moin
- hey there
- let's go
- hey dude
- goodmorning
- goodevening
- good afternoon
- intent: goodbye
examples: |
- cu
- good by
- cee you later
- good night
- bye
- goodbye
- have a nice day
- see you around
- bye bye
- see you later
- intent: affirm
examples: |
- yes
- y
- indeed
- of course
- that sounds good
- correct
- intent: deny
examples: |
- no
- n
- never
- I don't think so
- don't like that
- no way
- not really
- intent: mood_great
examples: |
- perfect
- great
- amazing
- feeling like a king
- wonderful
- I am feeling very good
- I am great
- I am amazing
- I am going to save the world
- super stoked
- extremely good
- so so perfect
- so good
- so perfect
- intent: mood_unhappy
examples: |
- my day was horrible
- I am sad
- I don't feel very well
- I am disappointed
- super sad
- I'm so sad
- sad
- very sad
- unhappy
- not good
- not very good
- extremly sad
- so saad
- so sad
- intent: bot_challenge
examples: |
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
- intent: siswa_1
examples: |
- siswa jurusan rpl
- siswa jurusan rekayasa perangkat lunak
- aiyub
- aiyub heriyanto
- siswa 1
- intent: siswa_2
examples: |
- siswa jurusan mm
- siswa jurusan multimedia
- afand
- afand fathur rozi
- fathur
- rozi
- siswa 2
- intent: siswa_3
examples: |
- siswa jurusan mp
- siswa jurusan manajemen perkantoran
- dhony
- dhony fajriansyah
- fajriansyah
- siswa 3
my domain.yml
version: "3.1"
intents:
- greet
- goodbye
- ask_question
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- siswa_1
- siswa_2
- siswa_3
responses:
utter_products:
- text: "Berikut adalah produk yang tersedia: "
utter_greet:
- text: "{greetings}"
utter_goodbye:
- text: "{goodbyes}"
utter_thanks:
- text: "{thanks}"
actions:
- action_siswa_1
- action_siswa_2
- action_siswa_3
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
and my rule.yml
version: "3.1"
rules:
- rule: Respond to a greeting
steps:
- intent: greet
- action: utter_greet
- rule: Respond to a goodbye
steps:
- intent: goodbye
- action: utter_goodbye
- rule: Kirim nama siswa aiyub
steps:
- intent: siswa_1
- action: action_siswa_1
- rule: Kirim nama siswa afand
steps:
- intent: siswa_2
- action: action_siswa_2
- rule: Kirim nama siswa dhony
steps:
- intent: siswa_3
- action: action_siswa_3
when I run the command rasa shell
I get an error like this :
Your input -> siswa jurusan rpl
2023-03-03 11:44:10 ERROR rasa.core.processor - Encountered an exception while running action 'action_siswa_1'.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 "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 741, in run
response: Any = await self.action_endpoint.request(
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\utils\endpoints.py", line 173, in request
raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"description":"Not Found","status":404,"message":"Requested URL /webhook not found"}''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\processor.py", line 874, in _run_action
events = await action.run(
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 765, in run
raise RasaException(
rasa.shared.exceptions.RasaException: Failed to execute custom action 'action_siswa_1'
but when I run command rasa shell -vv
I get logs like this :
Your input -> siswa jurusan rpl
2023-03-03 13:09:46 DEBUG rasa.core.lock_store - Issuing ticket for conversation 'd0a6d6f39e9c481ca18c8260408716c3'.
2023-03-03 13:09:46 DEBUG rasa.core.lock_store - Acquiring lock for conversation 'd0a6d6f39e9c481ca18c8260408716c3'.
2023-03-03 13:09:46 DEBUG rasa.core.lock_store - Acquired lock for conversation 'd0a6d6f39e9c481ca18c8260408716c3'.
2023-03-03 13:09:46 DEBUG rasa.core.tracker_store - Could not find tracker for conversation ID 'd0a6d6f39e9c481ca18c8260408716c3'.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Starting a new session for conversation ID 'd0a6d6f39e9c481ca18c8260408716c3'.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Policy prediction ended with events '[]'.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Action 'action_session_start' ended with events '[<rasa.shared.core.events.SessionStarted object at 0x00000271FDB18490>, ActionExecuted(action: action_listen, policy: None, confidence: None)]'.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Current slot values:
session_started_metadata: None
2023-03-03 13:09:46 DEBUG rasa.engine.runner.dask - Running graph with inputs: {'__message__': [<rasa.core.channels.channel.UserMessage object at 0x00000271FDB18220>]}, targets: ['run_RegexMessageHandler'] and ExecutionContext(model_id='6c1efe557cef4f7a83afd79c97bd6cee', should_add_diagnostic_data=False, is_finetuning=False, node_name=None).
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'nlu_message_converter' running 'NLUMessageConverter.convert_user_message'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_WhitespaceTokenizer0' running 'WhitespaceTokenizer.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_RegexFeaturizer1' running 'RegexFeaturizer.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_LexicalSyntacticFeaturizer2' running 'LexicalSyntacticFeaturizer.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_CountVectorsFeaturizer3' running 'CountVectorsFeaturizer.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_CountVectorsFeaturizer4' running 'CountVectorsFeaturizer.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_DIETClassifier5' running 'DIETClassifier.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_EntitySynonymMapper6' running 'EntitySynonymMapper.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_ResponseSelector7' running 'ResponseSelector.process'.
2023-03-03 13:09:46 DEBUG rasa.nlu.classifiers.diet_classifier - There is no trained model for 'ResponseSelector': The component is either not trained or didn't receive enough training data.
2023-03-03 13:09:46 DEBUG rasa.nlu.selectors.response_selector - Adding following selector key to message property: default
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_FallbackClassifier8' running 'FallbackClassifier.process'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'domain_provider' running 'DomainProvider.provide_inference'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_RegexMessageHandler' running 'RegexMessageHandler.process'.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Received user message 'siswa jurusan rpl' with intent '{'name': 'siswa_1', 'confidence': 0.9958667755126953}' and entities '[]'
2023-03-03 13:09:46 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 4 events.
2023-03-03 13:09:46 DEBUG rasa.core.actions.action - Validating extracted slots:
2023-03-03 13:09:46 DEBUG rasa.core.processor - Default action 'action_extract_slots' was executed, resulting in 0 events:
2023-03-03 13:09:46 DEBUG rasa.engine.runner.dask - Running graph with inputs: {'__tracker__': <rasa.shared.core.trackers.DialogueStateTracker object at 0x00000271FDB18370>}, targets: ['select_prediction'] and ExecutionContext(model_id='6c1efe557cef4f7a83afd79c97bd6cee', should_add_diagnostic_data=False, is_finetuning=False, node_name=None).
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'rule_only_data_provider' running 'RuleOnlyDataProvider.provide'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'domain_provider' running 'DomainProvider.provide_inference'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_MemoizationPolicy0' running 'MemoizationPolicy.predict_action_probabilities'.
2023-03-03 13:09:46 DEBUG rasa.core.policies.memoization - Current tracker state:
[state 1] user intent: siswa_1 | previous action name: action_listen
2023-03-03 13:09:46 DEBUG rasa.core.policies.memoization - There is no memorised next action
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_RulePolicy1' running 'RulePolicy.predict_action_probabilities'.
2023-03-03 13:09:46 DEBUG rasa.core.policies.rule_policy - Current tracker state:
[state 1] user text: siswa jurusan rpl | previous action name: action_listen
2023-03-03 13:09:46 DEBUG rasa.core.policies.rule_policy - There is no applicable rule.
2023-03-03 13:09:46 DEBUG rasa.core.policies.rule_policy - Current tracker state:
[state 1] user intent: siswa_1 | previous action name: action_listen
2023-03-03 13:09:46 DEBUG rasa.core.policies.rule_policy - There is a rule for the next action 'action_siswa_1'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_TEDPolicy3' running 'TEDPolicy.predict_action_probabilities'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'run_UnexpecTEDIntentPolicy2' running 'UnexpecTEDIntentPolicy.predict_action_probabilities'.
2023-03-03 13:09:46 DEBUG rasa.engine.graph - Node 'select_prediction' running 'DefaultPolicyPredictionEnsemble.combine_predictions_from_kwargs'.
2023-03-03 13:09:46 DEBUG rasa.core.policies.ensemble - Made prediction using user intent.
2023-03-03 13:09:46 DEBUG rasa.core.policies.ensemble - Added `DefinePrevUserUtteredFeaturization(False)` event.
2023-03-03 13:09:46 DEBUG rasa.core.policies.ensemble - Predicted next action using RulePolicy.
2023-03-03 13:09:46 DEBUG rasa.core.processor - Predicted next action 'action_siswa_1' with confidence 1.00.
2023-03-03 13:09:46 DEBUG rasa.core.actions.action - Calling action endpoint to run action 'action_siswa_1'.
2023-03-03 13:09:48 ERROR rasa.core.processor - Encountered an exception while running action 'action_siswa_1'.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 "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 741, in run
response: Any = await self.action_endpoint.request(
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\utils\endpoints.py", line 173, in request
raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"description":"Not Found","status":404,"message":"Requested URL /webhook not found"}''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\processor.py", line 874, in _run_action
events = await action.run(
File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 765, in run
raise RasaException(
rasa.shared.exceptions.RasaException: Failed to execute custom action 'action_siswa_1'
2023-03-03 13:09:48 DEBUG rasa.core.processor - Policy prediction ended with events '[<rasa.shared.core.events.DefinePrevUserUtteredFeaturization object at 0x00000271FDB973A0>]'.
2023-03-03 13:09:48 DEBUG rasa.core.processor - Action 'action_siswa_1' ended with events '[]'.
2023-03-03 13:09:48 DEBUG rasa.core.processor - Current slot values:
session_started_metadata: None
2023-03-03 13:09:48 DEBUG rasa.engine.runner.dask - Running graph with inputs: {'__tracker__': <rasa.shared.core.trackers.DialogueStateTracker object at 0x00000271FDB18370>}, targets: ['select_prediction'] and ExecutionContext(model_id='6c1efe557cef4f7a83afd79c97bd6cee', should_add_diagnostic_data=False, is_finetuning=False, node_name=None).
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'rule_only_data_provider' running 'RuleOnlyDataProvider.provide'.
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'domain_provider' running 'DomainProvider.provide_inference'.
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'run_MemoizationPolicy0' running 'MemoizationPolicy.predict_action_probabilities'.
2023-03-03 13:09:48 DEBUG rasa.core.policies.memoization - Current tracker state:
[state 1] previous action name: action_listen
2023-03-03 13:09:48 DEBUG rasa.core.policies.memoization - There is no memorised next action
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'run_RulePolicy1' running 'RulePolicy.predict_action_probabilities'.
2023-03-03 13:09:48 DEBUG rasa.core.policies.rule_policy - Current tracker state:
[state 1] user intent: siswa_1 | previous action name: action_listen
[state 2] user intent: siswa_1 | previous action name: action_siswa_1
2023-03-03 13:09:48 DEBUG rasa.core.policies.rule_policy - There is a rule for the next action 'action_listen'.
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'run_TEDPolicy3' running 'TEDPolicy.predict_action_probabilities'.
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'run_UnexpecTEDIntentPolicy2' running 'UnexpecTEDIntentPolicy.predict_action_probabilities'.
2023-03-03 13:09:48 DEBUG rasa.engine.graph - Node 'select_prediction' running 'DefaultPolicyPredictionEnsemble.combine_predictions_from_kwargs'.
2023-03-03 13:09:48 DEBUG rasa.core.policies.ensemble - Predicted next action using RulePolicy.
2023-03-03 13:09:48 DEBUG rasa.core.processor - Predicted next action 'action_listen' with confidence 1.00.
2023-03-03 13:09:48 DEBUG rasa.core.processor - Policy prediction ended with events '[]'.
2023-03-03 13:09:48 DEBUG rasa.core.processor - Action 'action_listen' ended with events '[]'.
2023-03-03 13:09:48 DEBUG rasa.core.lock_store - Deleted lock for conversation 'd0a6d6f39e9c481ca18c8260408716c3'.
how to solve this problem, is there a way to solve this problem or is there a special script for this kind of problem?