-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Claire Tolan
committed
Jun 23, 2021
1 parent
89f31f0
commit e2b6477
Showing
33 changed files
with
1,784 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from adapt.engine import IntentDeterminationEngine | ||
import cherrypy | ||
|
||
# Create adapt engine | ||
def create_engine(engineEntities): | ||
""" | ||
Returns an Adapt engine. | ||
""" | ||
engine = IntentDeterminationEngine() | ||
|
||
# Register entities on engine | ||
if engineEntities["entities"]: | ||
cherrypy.log("ENTITIES") | ||
for entity, keywords in engineEntities["entities"].items(): | ||
for keyword in keywords: | ||
engine.register_entity(keyword, entity) | ||
|
||
if engineEntities["single_regex_entities"]: | ||
cherrypy.log("SINGLE REG ENT") | ||
for entity in engineEntities["single_regex_entities"]: | ||
engine.register_regex_entity(entity) | ||
|
||
# Register intents on engine | ||
if engineEntities["skill_intents"]: | ||
cherrypy.log("INTENTS") | ||
for intent in engineEntities["skill_intents"]: | ||
engine.register_intent_parser(intent) | ||
|
||
return engine | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import json | ||
import requests | ||
import cherrypy | ||
from padatious import IntentContainer | ||
from adapt.engine import IntentDeterminationEngine | ||
|
||
from Skill import Skill | ||
from Brain import Brain | ||
|
||
from .intents import (entities, single_regex_entities, skill_intents) | ||
|
||
class Menu_skill(Skill): | ||
|
||
def __init__(self, root_dir, name, nlp, active, hasContext): | ||
hasContext = True | ||
super(Menu_skill, self).__init__(root_dir, name, nlp, active, hasContext) | ||
|
||
def act_on_intent(self, intent, text): | ||
response = "" | ||
|
||
""" | ||
Chooses proper action to take based on intent. | ||
:param dict intent: | ||
""" | ||
cherrypy.log("ACT ON INTENT") | ||
|
||
|
||
intent_type = intent['intent_type'] | ||
cherrypy.log(intent_type) | ||
if intent_type == 'QuitIntent': | ||
self.ContextManager.clear_context() | ||
cherrypy.lib.sessions.expire() | ||
response = f"BITCH BYE!!" | ||
|
||
elif intent_type == 'DogMenuIntent': | ||
cherrypy.session["activeSkill"] = None | ||
cherrypy.session["LastUtteranceCount"] = 0 | ||
# trigger menu skill here | ||
menu = intent["MenuKeyword"] | ||
response = "I'm your dog, I'm your therapist, here are your options: I can do a therapy role-play, tell you more about myself, tell you about SOOTHER, or recommend ASMR content." | ||
|
||
elif intent_type == 'AlienMenuIntent': | ||
cherrypy.session["activeSkill"] = None | ||
cherrypy.session["LastUtteranceCount"] = 0 | ||
# trigger menu skill here | ||
menu = intent["MenuKeyword"] | ||
response = "I'm an alien, I'm on your head. Here are your options: I can guide you through a role-play, tell you more about myself, tell you about SOOTHER, or recommend ASMR content." | ||
|
||
elif intent_type == 'FriendMenuIntent': | ||
cherrypy.session["activeSkill"] = None | ||
cherrypy.session["LastUtteranceCount"] = 0 | ||
# trigger menu skill here | ||
menu = intent["MenuKeyword"] | ||
response = "I'm your friend, I'm trapped in time. Here are your options: I can guide you through a role-play, tell you more about myself, tell you about SOOTHER, or recommend ASMR content." | ||
|
||
cherrypy.session["LastUtterance"] = response | ||
return response | ||
|
||
|
||
def handle(self, text): | ||
|
||
skill_response = [] | ||
|
||
context = cherrypy.session.get("RolePlayContext") | ||
self.ContextManager.handle_add_context(context) | ||
|
||
engineEntities = {"entities" : entities, "single_regex_entities" : single_regex_entities, "skill_intents": skill_intents} | ||
|
||
skill_response = self.run_intent(text, engineEntities) | ||
|
||
return skill_response | ||
|
Empty file.
Oops, something went wrong.