예제 #1
0
    def __init__(self):
        self.context = {}
        self.option_dict = {}
        self.intents = []
        self.entities = []
        self.recipe_options = []
        self.database_cursor = None


        # Reset enviroment variables

        self.context['search_recipe'] = False
        self.context['image_recipe'] = False
        self.context['suggest_dish'] = False
        self.context['yum_sugest'] = False
        self.context['summary'] = False
        self.context['option'] = None
        self.context['cuisine_type'] = None
        self.context['ingredients'] = None
        self.context['intolerances'] = None
        self.context['dish'] = None
        self.context['counter'] = 0
        self.context['insult_counter'] = 0


        # Services initialization

        #  Slack client instance
        self.slack_client = SlackClient(SLACK_BOT_TOKEN)

        # Watson Conversation sevice instance
        self.conversation = Conversation(version = CONVERSATION_VERSION,
                                         username = CONVERSATION_USERNAME,
                                         password = CONVERSATION_PASSWORD,
                                         url = CONVERSATION_URL)

        #  Watson Visual Recognition service instance
        self.visual_recognition = VisualRecognition(version=VISUAL_RECOGNITION_VERSION,
                                                    url=VISUAL_RECOGNITION_URL,
                                                    api_key=VISUAL_RECOGNITION_KEY)
        # Database connection
        self.database_connection(DB_STRING_CONNECTION)
예제 #2
0
    def __init__(self):
        # Loads all the required data from the AppSettings.json file.
        app_setting_directory = '../../Data/AppSettings/AppSettings.json'
        csv_directory = '../../Data/CSVFiles/MainCSV.csv'
        self.readTheCSV = theCSV.ReaderCSV(csv_directory).final_csv_data
        self.readTheJSON = theJSON.ReaderJSON(app_setting_directory).final_json_data
        self.theUserName = self.readTheJSON['username']
        self.thePassword = self.readTheJSON['password']
        self.theVersion = self.readTheJSON['version']
        self.theWorkspaceID = self.readTheJSON['workspace_id']

        # Creates a new instance of the Conversation V1 object.
        self.theConversation = Conversation(username=self.theUserName, password=self.thePassword,
                                            version=self.theVersion)

        # We initialize all necessary objects to be able to assemble the initial workspace.
        self.workspace_id = self.theWorkspaceID
        self.workspaces = Workspace.Workspace(self.theUserName, self.thePassword, self.theVersion)
        self.dialog_nodes = Dialog.Dialog(self.theUserName, self.thePassword, self.theVersion)
        self.entities = Entity.Entity(self.theUserName, self.thePassword, self.theVersion)
        self.synonyms = Synonym.Synonym(self.theUserName, self.thePassword, self.theVersion)
        self.values = Value.Value(self.theUserName, self.thePassword, self.theVersion)
        self.intents = Intent.Intent(self.theUserName, self.thePassword, self.theVersion)
        self.examples = Example.Example(self.theUserName, self.thePassword, self.theVersion)
예제 #3
0
 def __init__(self, username=None, password=None, version=None):
     self.conversation = Conversation(username=username,
                                      password=password,
                                      version=version)
예제 #4
0
import re
import json
import logging
from channels import Group
from channels.sessions import channel_session
from .models import Room
from watson_developer_cloud import ConversationV1 as Conversation
from .watson import send_message_to_watson

log = logging.getLogger(__name__)

conversation = Conversation(
    version='2017-04-21',
    username='******',
    password='******'
)


@channel_session
def ws_connect(message):
    # Extract the room from the message. This expects message.path to be of the
    # form /chat/{label}/, and finds a Room if the message path is applicable,
    # and if the Room exists. Otherwise, bails (meaning this is a some othersort
    # of websocket). So, this is effectively a version of _get_object_or_404.
    try:
        prefix, label = message['path'].decode('ascii').strip('/').split('/')
        if prefix != 'chat':
            log.debug('invalid ws path=%s', message['path'])
            return
        room = Room.objects.get(label=label)
    except ValueError: