Skip to content

Instantly share code, notes, and snippets.

View JustinaPetr's full-sized avatar

Justina Petraityte JustinaPetr

View GitHub Profile
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from custom import GoogleConnector
from rasa_core.utils import EndpointConfig
action_endpoint = EndpointConfig(url="http://localhost:5055/webhook")
nlu_interpreter = RasaNLUInterpreter('./models/current/nlu_model')
agent = Agent.load('./models/current/dialogue', interpreter = nlu_interpreter, action_endpoint=action_endpoint)
input_channel = GoogleConnector()
class RestaurantForm(FormAction):
"""Example of a custom form action"""
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self):
"""Unique identifier of the form"""
return "restaurant_form"
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self):
"""Unique identifier of the form"""
return "restaurant_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
def required_slots(tracker):
# type: () -> List[Text]
"""A list of required slots that the form has to fill"""
if tracker.get_slot('cuisine') == 'greek':
return ["cuisine", "num_people", "outdoor_seating",
"preferences", "feedback"]
else:
return ["cuisine", "num_people",
"preferences", "feedback"]
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self):
"""Unique identifier of the form"""
return "restaurant_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message or a list of them, where a first
match will be picked"""
return { "outdoor_seating": [self.from_entity(entity="seating"),
self.from_intent(intent='affirm',
import nltk
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import twitter_samples
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
from nltk.stem.wordnet import WordNetLemmatizer
class SentimentClassifier(object):
from rasa_nlu.components import Component
from rasa_nlu import utils
from rasa_nlu.model import Metadata
from sentiment_classifier import SentimentClassifier
import nltk
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import twitter_samples
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, AllSlotsReset
import requests
import json
from random import randint
import datetime
import os
import yaml
class ActionPlaceSearch(Action):