Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MannavaVivek committed Jan 22, 2024
1 parent 06c17db commit f89487d
Show file tree
Hide file tree
Showing 11 changed files with 855 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.rasa/
.rasa/cache/
.vscode/
*.dot
*.pyc
models/
*.db
.rasa/cache/cache.db
actions/__pycache__/
Empty file added actions/__init__.py
Empty file.
79 changes: 79 additions & 0 deletions actions/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker, FormValidationAction
from rasa_sdk.types import DomainDict
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import SlotSet, Restarted


class ValidateSimpleOrderForm(FormValidationAction):

def name(self) -> Text:
return "validate_simple_order_form"

def __init__(self) -> None:
self.valid_locations = ["living_shelf", "dining_room","reading_room"]
self.valid_objects = ["pringles","windex_bottle","soup","tshirt","spatula"]

def validate_places(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
if value.lower() not in self.valid_locations:
# dispatcher.utter_message("Sorry, I don't recognize that location.")

dispatcher.utter_message(template="utter_ask_places_again")
return {"places": None}
return {"places": value}

def validate_order(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
if value.lower() not in self.valid_objects:
# dispatcher.utter_message("Sorry, I don't recognize that object.")
dispatcher.utter_message(template="utter_ask_order_again")
return {"order": None}
return {"order": value}

class ActionCustomFallback(Action):
def name(self) -> Text:
return "action_fallback_response"

def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# Send a message to the user
dispatcher.utter_message(template="utter_fallback")

# Return an empty list
return[]

class ActionClearSlot(Action):
def name(self) -> Text:
return "action_clear_slots"

def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
# add all the slots you wish to clear, here:
# TODO: can also use return [AllSlotsReset()] if always clearing all slots.
return [SlotSet("order", None), SlotSet("places",None), SlotSet("confirmation", None)]

55 changes: 55 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# The config recipe.
# https://rasa.com/docs/rasa/model-configuration/

recipe: default.v1

# The assistant project unique identifier
# This default value must be replaced with a unique assistant name within your deployment
assistant_id: 20230424-150104-jovial-pan

# 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: 300
constrain_similarities: True
- name: EntitySynonymMapper
- name: ResponseSelector
epochs: 100
constrain_similarities: True
- name: FallbackClassifier
threshold: 0.7
ambiguity_threshold: 0.1



# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
# # 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: AugmentedMemoizationPolicy
- name: RulePolicy
core_fallback_action_name: "action_fallback_response"
- name: UnexpecTEDIntentPolicy
max_history: 5
epochs: 100
- name: TEDPolicy
max_history: 5
epochs: 100
constrain_similarities: true
33 changes: 33 additions & 0 deletions credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/messaging-and-voice-channels

rest:
# # you don't need to provide anything here - this channel doesn't
# # require any credentials


#facebook:
# verify: "<verify>"
# secret: "<your secret>"
# page-access-token: "<your page access token>"

#slack:
# slack_token: "<your slack token>"
# slack_channel: "<the slack channel>"
# slack_signing_secret: "<your slack signing secret>"

#socketio:
# user_message_evt: <event name for user message>
# bot_message_evt: <event name for bot messages>
# session_persistence: <true/false>

#mattermost:
# url: "https://<mattermost instance>/api/v4"
# token: "<bot token>"
# webhook_url: "<callback URL>"

# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
url: "http://localhost:5002/api"
Loading

0 comments on commit f89487d

Please sign in to comment.