diff --git a/.gitignore b/.gitignore index 92a2579c7058c322e0f50d4ced93dd1d753a39a7..84ca75ba3f2dcf83e91e6f186e1afb483a9f83c2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ notes.txt .rasa */models +/data __pycache__/ \ No newline at end of file diff --git a/rasa/actions/actions.py b/rasa/actions/actions.py index 8bf1f757f851343b4bb1c56e40bf7cf9bde717ae..23dbb5461dfaa4b890fb30a9c84520236f0ed7e0 100644 --- a/rasa/actions/actions.py +++ b/rasa/actions/actions.py @@ -1,27 +1,35 @@ -# This files contains your custom actions which can be used to run -# custom Python code. -# -# See this guide on how to implement these action: -# https://rasa.com/docs/rasa/custom-actions - - -# This is a simple example for a custom action which utters "Hello World!" - -# from typing import Any, Text, Dict, List -# -# from rasa_sdk import Action, Tracker -# from rasa_sdk.executor import CollectingDispatcher -# -# -# class ActionHelloWorld(Action): -# -# def name(self) -> Text: -# return "action_hello_world" -# -# def run(self, dispatcher: CollectingDispatcher, -# tracker: Tracker, -# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: -# -# dispatcher.utter_message(text="Hello World!") -# -# return [] +from typing import Any, Text, Dict, List + +from rasa_sdk import Action, Tracker +from rasa_sdk.executor import CollectingDispatcher + + +class ActionCurrentIssLocation(Action): + + def name(self) -> Text: + return "action_current_iss_location" + + def run(self, dispatcher: CollectingDispatcher, + tracker: Tracker, + domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: + + dispatcher.utter_message(text="[Placeholder for the current ISS location]") + + return [] + +class ActionFutureIssLocation(Action): + + def name(self) -> Text: + return "action_future_iss_location" + + def run(self, dispatcher: CollectingDispatcher, + tracker: Tracker, + domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: + + if(len(tracker.latest_message['entities']) == 0): + dispatcher.utter_message(text="I'm sorry, but I didn't understand your formatting. Please try again.") + else: + dispatcher.utter_message(text="[Placeholder for the ISS location at: " + tracker.latest_message['entities'][0]['value'] + " ]") + + return [] + diff --git a/rasa/config.yml b/rasa/config.yml index eb54e60a86ce4726c1ebf000ed6ce90124d2af32..107a70da5b4e9665e23050e59dadf188c09c2826 100644 --- a/rasa/config.yml +++ b/rasa/config.yml @@ -4,41 +4,53 @@ recipe: default.v1 # The assistant project unique identifier # This default value must be replaced with a unique assistant name within your deployment -assistant_id: placeholder_default +assistant_id: 20240620-112810-best-tarragon # Configuration for Rasa NLU. # https://rasa.com/docs/rasa/nlu/components/ language: en pipeline: -# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model. -# # If you'd like to customize it, uncomment and adjust the pipeline. -# # See https://rasa.com/docs/rasa/tuning-your-model for more information. -# - name: WhitespaceTokenizer -# - name: RegexFeaturizer -# - name: LexicalSyntacticFeaturizer -# - name: CountVectorsFeaturizer -# - name: CountVectorsFeaturizer -# analyzer: char_wb -# min_ngram: 1 -# max_ngram: 4 -# - name: DIETClassifier -# epochs: 100 -# - name: EntitySynonymMapper -# - name: ResponseSelector -# epochs: 100 -# - name: FallbackClassifier -# threshold: 0.3 -# ambiguity_threshold: 0.1 + - name: WhitespaceTokenizer + - name: RegexFeaturizer + - name: LexicalSyntacticFeaturizer + - name: CountVectorsFeaturizer + - name: CountVectorsFeaturizer + analyzer: char_wb + min_ngram: 1 + max_ngram: 4 + - name: DIETClassifier + epochs: 100 + constrain_similarities: true + - name: RegexEntityExtractor + case_sensitive: False + use_lookup_tables: False + use_regexes: True + use_word_boundaries: True + validation: True + regexes: + - name: date + pattern: '\b\d{4}-\d{2}-\d{2}:\d{2}:\d{2}\b' + - name: EntitySynonymMapper + - name: ResponseSelector + epochs: 100 + constrain_similarities: true + - name: FallbackClassifier + threshold: 0.3 + ambiguity_threshold: 0.1 # Configuration for Rasa Core. # https://rasa.com/docs/rasa/core/policies/ -policies: +policies: null # # No configuration for policies was provided. The following default policies were used to train your model. # # If you'd like to customize them, uncomment and adjust the policies. # # See https://rasa.com/docs/rasa/policies for more information. # - name: MemoizationPolicy +# - name: RulePolicy +# - name: UnexpecTEDIntentPolicy +# max_history: 5 +# epochs: 100 # - name: TEDPolicy # max_history: 5 # epochs: 100 -# - name: RulePolicy +# constrain_similarities: true diff --git a/rasa/data/nlu/nlu_nasa_api.yml b/rasa/data/nlu/nlu_nasa_api.yml new file mode 100644 index 0000000000000000000000000000000000000000..0ae5ea2ed6032238ac91b15ee8e0453cc960a95b --- /dev/null +++ b/rasa/data/nlu/nlu_nasa_api.yml @@ -0,0 +1,75 @@ +version: "3.1" + +nlu: +- intent: get_location + examples: | + - where is the iss + - location of the iss + - do you know the location of the iss + - what's the position of the ISS? + - can you tell me where the ISS is located? + - locate the international space station + - where's the ISS + - general location of the ISS + - space station location + - find the ISS in orbit + - geographical location of the ISS + - ISS orbit location + +- intent: current_iss_location + examples: | + - where is the iss in this moment + - the current location + - current + - where it currently is + - where is the ISS right now? + - current ISS position please + - show me where the ISS is currently + - exact location of the ISS at this moment + - find the current location of the ISS + - ISS location at this second + - where's the ISS at this instant? + - can you find the current ISS coordinates? + - live update on the ISS position + - track the ISS's current location + - currently + - right now + - in this moment + +- intent: future_iss_location + examples: | + - where will the iss be in the future + - tell me where the iss will be + - where will the ISS be tomorrow? + - predict the ISS's location for next week + - future trajectory of the ISS + - where is the ISS going to be in an hour? + - can you forecast the ISS's position in 30 minutes? + - ISS location in the future + - upcoming location of the ISS + - what will be the location of the ISS next month? + - future positions of the ISS + - track ISS's path for the next days + - in the future + - tomorrow + - next week + - next month + - next year + - in the future + - future + - in the next time + +- intent: future_location_call + examples: | + - iss location at:[2024-02-04:12:00](date) + - iss location at:[2024-02-04:12:00](date) + - iss location at:[2020-11-01:09:12](date) + - iss location at:[2025-02-03:01:00](date) + - iss location at:[2029-03-05:08:54](date) + +- regex: date + examples: | + - \b\d{4}-\d{2}-\d{2}:\d{2}:\d{2}\b + +entities: +- date diff --git a/rasa/data/rules.yml b/rasa/data/rules.yml deleted file mode 100644 index a6ecc69c83f85d2c68e132117e0f9c1618046193..0000000000000000000000000000000000000000 --- a/rasa/data/rules.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: "3.1" - -rules: - -- rule: respond to a thankful user - steps: - - intent: thank_you - - action: utter_your_welcome - -- rule: say goodbye to the user - steps: - - intent: goodbye - - action: utter_goodbye - -- rule: demand a respectful tone during conversations - steps: - - intent: insult - - action: utter_respectful_conversation - -- rule: easter egg - steps: - - intent: hello_there - - action: utter_easter_egg - -- rule: joke - steps: - - intent: ask_for_joke - - action: utter_joke - -- rule: entrypoint 1 - steps: - - intent: ask_what_else - - action: utter_entry_point - -- rule: entrypoint 2 - steps: - - intent: ask_recommendations - - action: utter_entry_point - -- rule: entrypoint 3 - steps: - - intent: ask_topics - - action: utter_entry_point - -- rule: fun fact - steps: - - intent: fun_fact - - action: utter_fun_fact - \ No newline at end of file diff --git a/rasa/data/rules/rules_nasa_api.yml b/rasa/data/rules/rules_nasa_api.yml new file mode 100644 index 0000000000000000000000000000000000000000..3b7184f0145ee3e4ef9906ab57de3cb563f1a0de --- /dev/null +++ b/rasa/data/rules/rules_nasa_api.yml @@ -0,0 +1,12 @@ +version: "3.1" + +rules: +- rule: current iss location call + steps: + - intent: current_iss_location + - action: action_current_iss_location + +- rule: future iss location call + steps: + - intent: future_location_call + - action: action_future_iss_location diff --git a/rasa/data/stories.yml b/rasa/data/stories.yml deleted file mode 100644 index f8e321e54fa7819c748c3c1e31f0b9c3e0041759..0000000000000000000000000000000000000000 --- a/rasa/data/stories.yml +++ /dev/null @@ -1,240 +0,0 @@ -version: "3.1" - -stories: -- story: happy path - steps: - - intent: greet - - action: utter_greet - - intent: happy - - action: utter_great - - intent: ask_mood - - action: utter_mood - - intent: ask_what_else - - action: utter_entry_point - -- story: sad path with joke - steps: - - intent: greet - - action: utter_greet - - intent: unhappy - - action: utter_worried - - intent: affirm - - action: utter_joke - - intent: ask_mood - - action: utter_mood - - intent: ask_what_else - - action: utter_entry_point - -- story: good feedback - steps: - - intent: youre_good - - action: utter_good_feedback - - intent: affirm - - action: utter_feedback - -- story: bad feedback - steps: - - intent: ask_real_time - - action: utter_no_real_time - - intent: youre_bad - - action: utter_bad_feedback - - intent: affirm - - action: utter_feedback - -- story: denied - steps: - - intent: deny - - action: utter_denied - - intent: affirm - - action: utter_feedback - -- story: bug reported 1 - steps: - - intent: ask_help - - action: utter_help - - intent: report_bug - - action: utter_bug_reported - - intent: ask_contact_info - - action: utter_contact - -- story: bug reported 2 - steps: - - intent: ask_help - - action: utter_help - - intent: report_bug - - action: utter_bug_reported - - intent: feedback - - action: utter_feedback - -- story: faq - steps: - - intent: ask_help - - action: utter_help - - intent: ask_faq - - action: utter_faq - -- story: ask name 1 - steps: - - intent: ask_name - - action: utter_name - - intent: ask_creation - - action: utter_creation - - intent: ask_creator - - action: utter_creator - -- story: ask name 2 - steps: - - intent: ask_name - - action: utter_name - - intent: ask_creation - - action: utter_creation - - intent: ask_technology - - action: utter_technology - -- story: ask name 3 - steps: - - intent: ask_name - - action: utter_name - - intent: ask_capabilities - - action: utter_capabilities - - intent: ask_topics - - action: utter_entry_point - -- story: ask name 4 - steps: - - intent: ask_name - - action: utter_name - - intent: ask_purpose - - action: utter_purpose - - intent: ask_topics - - action: utter_entry_point - -- story: what are you 1 - steps: - - intent: what_are_you - - action: utter_what_i_am - - intent: ask_creation - - action: utter_creation - - intent: ask_creator - - action: utter_creator - -- story: what are you 2 - steps: - - intent: what_are_you - - action: utter_what_i_am - - intent: ask_creation - - action: utter_creation - - intent: ask_technology - - action: utter_technology - -- story: what are you 3 - steps: - - intent: what_are_you - - action: utter_what_i_am - - intent: ask_capabilities - - action: utter_capabilities - - intent: ask_topics - - action: utter_entry_point - -- story: what are you 4 - steps: - - intent: what_are_you - - action: utter_what_i_am - - intent: ask_purpose - - action: utter_purpose - - intent: ask_topics - - action: utter_entry_point - - ####################################################### - ####################################################### - ####################################################### - -- story: everyday life 1 - steps: - - intent: everyday_life - - action: utter_everyday_life - - intent: food - - action: utter_food - -- story: everyday life 2 - steps: - - intent: everyday_life - - action: utter_everyday_life - - intent: sleep - - action: utter_sleep - -- story: get started 1 - steps: - - intent: get_started - - action: utter_starting_point - - intent: skills - - action: utter_skills - - intent: challenges - - action: utter_astronaut_challenges - -- story: get started 2 - steps: - - intent: get_started - - action: utter_starting_point - - intent: skills - - action: utter_skills - - intent: training_duration - - action: utter_training_duration - - intent: preparation - - action: utter_preparation - - intent: challenges - - action: utter_astronaut_challenges - -- story: challenges 1 - steps: - - intent: challenges - - action: utter_astronaut_challenges - - intent: isolation - - action: utter_isolation - -- story: challenges 2 - steps: - - intent: challenges - - action: utter_astronaut_challenges - - intent: psychological_effects - - action: utter_psychology - -- story: purpose 1 - steps: - - intent: space_station_purpose - - action: utter_space_station_purpose - - intent: space_station_goals - - action: utter_goals - - intent: experiment_benefits_for_earth - - action: utter_benefits - -- story: purpose 2 - steps: - - intent: space_station_purpose - - action: utter_space_station_purpose - - intent: space_station_and_science - - action: utter_science - - intent: experiment_kinds - - action: utter_experiment_kinds - - intent: experiment_benefits_for_earth - - action: utter_benefits - -- story: purpose 3 - steps: - - intent: space_station_purpose - - action: utter_space_station_purpose - - intent: space_station_and_science - - action: utter_science - - intent: experiment_kinds - - action: utter_experiment_kinds - - intent: experiment_most_relevant - - action: utter_most_relevant - -- story: stations - steps: - - intent: space_station_stations - - action: utter_stations - - intent: space_station_planned - - action: utter_planned_stations - - intent: space_station_nations - - action: utter_station_nations diff --git a/rasa/data/stories/stories_nasa_api.yml b/rasa/data/stories/stories_nasa_api.yml new file mode 100644 index 0000000000000000000000000000000000000000..f7f7e99da5ec4816a1b0aacc7aa3d229ec1becb1 --- /dev/null +++ b/rasa/data/stories/stories_nasa_api.yml @@ -0,0 +1,18 @@ +version: "3.1" + +stories: +- story: nasa api 1 + steps: + - intent: get_location + - action: utter_iss_location + - intent: current_iss_location + - action: action_current_iss_location + +- story: nasa api 2 + steps: + - intent: get_location + - action: utter_iss_location + - intent: future_iss_location + - action: utter_future_location + - intent: future_location_call + - action: action_future_iss_location diff --git a/rasa/domain.yml b/rasa/domain.yml index 4d0558d8d77f7f441dd82ce4cbdf318666408c31..9d03497bb52061033838e1ecb3944d881957892b 100644 --- a/rasa/domain.yml +++ b/rasa/domain.yml @@ -52,6 +52,17 @@ intents: - challenges - isolation - psychological_effects + - get_location + - current_iss_location + - future_iss_location + - future_location_call + +entities: + - date + +actions: + - action_current_iss_location + - action_future_iss_location responses: utter_your_welcome: @@ -152,8 +163,6 @@ responses: - what challenges astronauts fear\n - why we even have space stations\n - ... and much more" - # - text: "Entry Point (Placeholder)" - # - text: "Entry Point (Placeholder)" utter_name: - text: "I am Spacemate, your AI-powered chatbot. That's the name my lovely creator gave me." @@ -290,6 +299,17 @@ responses: - text: "China operates its own space station, Tiangong, independently." - text: "Other countries, such as India and the United Arab Emirates, have expressed interest in developing their own space station capabilities in the future." + ####################################################### + ####################################################### + ####################################################### + + utter_iss_location: + - text: "Sure, I can tell you that. Do you want to know the current location or it's location in the future?" + + utter_future_location: + - text: "To get a future location you will need to type your request in the following format:\n + 'iss location at:year-month-day:hour:minutes'" + session_config: session_expiration_time: 60 carry_over_slots_to_new_session: true