├── Covid-Chatbot ├── .gitignore ├── ToDo ├── actions │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ └── actions.cpython-36.pyc │ └── actions.py ├── config.yml ├── credentials.yml ├── data │ ├── nlu.yml │ ├── rules.yml │ └── stories.yml ├── domain.yml ├── endpoints.yml ├── requirements.txt ├── server.sh ├── story_graph.dot └── tests │ └── test_stories.yml ├── README.md ├── rasaconnector ├── .gitignore ├── Samples │ ├── Edges.png │ ├── NLU.csv │ ├── nlu.png │ ├── nlu.yml │ ├── stories.csv │ ├── stories.png │ └── stories.yml ├── requirements.txt └── test.py ├── web-rasa-tigergraph.gif ├── web-rasa-tigergraph.mp4 └── web ├── .gitignore ├── app.py ├── requirements.txt ├── static ├── Screen Shot 2020-12-09 at 1.07.47 PM.png ├── bot.png └── rasa_image.png └── templates └── index.html /Covid-Chatbot/.gitignore: -------------------------------------------------------------------------------- 1 | # created by virtualenv automatically 2 | * 3 | -------------------------------------------------------------------------------- /Covid-Chatbot/ToDo: -------------------------------------------------------------------------------- 1 | 2 | **** Coding Steps 3 | 1. endpoints.yml : enable web action hooks ? ==> Action.py communicate action_endpoint 4 | 2. domain add reference for the action line 46 5 | 3. for multi turn conversation use rules instead of Stories : Example/Template ==> Line 15 of rules.yml 6 | 4. define the actions in the actions.py 7 | a. make sure that the retun name is the same as in domain 8 | b. recover entities from latest message 9 | c. do the call or process [ asking for a weather ? call the API weather /// call the API for the ERP ] 10 | d. dispatcher.utter_message ==> Domain/Responses 11 | 12 | 13 | **** Running Steps 14 | 1. rasa train 15 | 2. two terminals 16 | a. rasa run actions 17 | b. rasa shell -------------------------------------------------------------------------------- /Covid-Chatbot/actions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/Covid-Chatbot/actions/__init__.py -------------------------------------------------------------------------------- /Covid-Chatbot/actions/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/Covid-Chatbot/actions/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /Covid-Chatbot/actions/__pycache__/actions.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/Covid-Chatbot/actions/__pycache__/actions.cpython-36.pyc -------------------------------------------------------------------------------- /Covid-Chatbot/actions/actions.py: -------------------------------------------------------------------------------- 1 | # This files contains your custom actions which can be used to run 2 | # custom Python code. 3 | # 4 | # See this guide on how to implement these action: 5 | # https://rasa.com/docs/rasa/custom-actions 6 | 7 | 8 | # This is a simple example for a custom action which utters "Hello World!" 9 | 10 | from typing import Any, Text, Dict, List 11 | 12 | from rasa_sdk import Action, Tracker 13 | from rasa_sdk.executor import CollectingDispatcher 14 | 15 | import pyTigerGraph as tg 16 | 17 | ################# TigerGraph Credentials ######################"" 18 | configs = { 19 | "host": "https://.i.tgcloud.io", 20 | "password": "", 21 | "graphname": "", 22 | "secret" : "" 23 | } 24 | #######################################" 25 | 26 | 27 | 28 | 29 | ################# TigerGraph Initialization ######################"" 30 | conn = tg.TigerGraphConnection(host=configs['host'], password=configs['password'], gsqlVersion="3.0.5", useCert=True, graphname=configs['graphname']) 31 | conn.apiToken = conn.getToken(configs['secret']) 32 | conn.gsql("USE graph {}".format(configs['graphname'])) 33 | #######################################" 34 | 35 | class ActionSearchPatients(Action): 36 | 37 | def name(self) -> Text: 38 | return "action_search_patients" # !!!! this return value must match line 55 of domain.yml [ Step 4.a ] 39 | 40 | def run(self, dispatcher: CollectingDispatcher, 41 | tracker: Tracker, 42 | domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: 43 | 44 | 45 | print(tracker.latest_message) 46 | prediction = tracker.latest_message['entities'][0]['value'] 47 | print("======================") 48 | print(prediction) 49 | print("======================") 50 | if prediction: 51 | query_response = conn.runInstalledQuery("listPatients_Infected_By",{"p": prediction}) 52 | print(query_response) 53 | vals = query_response[0]["Infected_Patients"] 54 | value = ",".join(vals) 55 | 56 | counts = len(vals) 57 | if counts > 0: 58 | dispatcher.utter_message(template="utter_infection_source_filled",count=counts,patientid=value) 59 | else: 60 | dispatcher.utter_message(template="utter_infection_source_empty") 61 | 62 | return [] 63 | 64 | 65 | 66 | class ActionSearchPatientLocation(Action): 67 | 68 | def name(self) -> Text: 69 | return "action_patient_location" # !!!! this return value must match line 56 of domain.yml [ Step 4.a ] 70 | 71 | def run(self, dispatcher: CollectingDispatcher, 72 | tracker: Tracker, 73 | domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: 74 | 75 | print(tracker.latest_message) 76 | prediction = tracker.latest_message['entities'][0]['value'] 77 | 78 | ###### TigerGraph Query ##################### 79 | places = "" 80 | print(prediction) 81 | if prediction: 82 | places = conn.gsql("select infection_case from Patient where patient_id == {} ".format(prediction))[0]["attributes"]['infection_case'] 83 | 84 | if len(places) > 0: 85 | dispatcher.utter_message(template="utter_infection_place_filled",place=places,patientid=prediction) 86 | else: 87 | dispatcher.utter_message(template="utter_infection_place_empty") 88 | 89 | return [] 90 | 91 | 92 | 93 | class ActionSearchPokemon(Action): 94 | 95 | def name(self) -> Text: 96 | return "action_pokemon_type" # !!!! this return value must match line 56 of domain.yml [ Step 4.a ] 97 | 98 | def run(self, dispatcher: CollectingDispatcher, 99 | tracker: Tracker, 100 | domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: 101 | 102 | print(tracker.latest_message) 103 | prediction = tracker.latest_message['entities'][0]['value'] 104 | places = "" 105 | if len(places) > 0: 106 | dispatcher.utter_message(template="utter_pokemon_filled",pokemontype=places,pokemonname=prediction) 107 | else: 108 | dispatcher.utter_message(template="utter_pokemon_empty",pokemonname=prediction) 109 | 110 | return [] 111 | -------------------------------------------------------------------------------- /Covid-Chatbot/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Rasa NLU. 2 | # https://rasa.com/docs/rasa/nlu/components/ 3 | language: en 4 | 5 | pipeline: 6 | # # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model. 7 | # # If you'd like to customize it, uncomment and adjust the pipeline. 8 | # # See https://rasa.com/docs/rasa/tuning-your-model for more information. 9 | # - name: WhitespaceTokenizer 10 | # - name: RegexFeaturizer 11 | # - name: LexicalSyntacticFeaturizer 12 | # - name: CountVectorsFeaturizer 13 | # - name: CountVectorsFeaturizer 14 | # analyzer: char_wb 15 | # min_ngram: 1 16 | # max_ngram: 4 17 | # - name: DIETClassifier 18 | # epochs: 100 19 | # - name: EntitySynonymMapper 20 | # - name: ResponseSelector 21 | # epochs: 100 22 | # - name: FallbackClassifier 23 | # threshold: 0.3 24 | # ambiguity_threshold: 0.1 25 | 26 | # Configuration for Rasa Core. 27 | # https://rasa.com/docs/rasa/core/policies/ 28 | policies: 29 | # # No configuration for policies was provided. The following default policies were used to train your model. 30 | # # If you'd like to customize them, uncomment and adjust the policies. 31 | # # See https://rasa.com/docs/rasa/policies for more information. 32 | # - name: MemoizationPolicy 33 | # - name: TEDPolicy 34 | # max_history: 5 35 | # epochs: 100 36 | # - name: RulePolicy 37 | -------------------------------------------------------------------------------- /Covid-Chatbot/credentials.yml: -------------------------------------------------------------------------------- 1 | # This file contains the credentials for the voice & chat platforms 2 | # which your bot is using. 3 | # https://rasa.com/docs/rasa/messaging-and-voice-channels 4 | 5 | rest: 6 | # # you don't need to provide anything here - this channel doesn't 7 | # # require any credentials 8 | 9 | 10 | #facebook: 11 | # verify: "" 12 | # secret: "" 13 | # page-access-token: "" 14 | 15 | #slack: 16 | # slack_token: "" 17 | # slack_channel: "" 18 | # proxy: "" 19 | 20 | #socketio: 21 | # user_message_evt: 22 | # bot_message_evt: 23 | # session_persistence: 24 | 25 | #mattermost: 26 | # url: "https:///api/v4" 27 | # token: "" 28 | # webhook_url: "" 29 | 30 | # This entry is needed if you are using Rasa X. The entry represents credentials 31 | # for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers. 32 | rasa: 33 | url: "http://localhost:5002/api" 34 | -------------------------------------------------------------------------------- /Covid-Chatbot/data/nlu.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | 3 | nlu: 4 | - intent: greet 5 | examples: | 6 | - hey 7 | - hello 8 | - hi 9 | - hello there 10 | - good morning 11 | - good evening 12 | - moin 13 | - hey there 14 | - let's go 15 | - hey dude 16 | - goodmorning 17 | - goodevening 18 | - good afternoon 19 | 20 | - regex: patientid 21 | examples: | 22 | - \d{10,11} 23 | 24 | - regex: pokemontype 25 | examples: | 26 | - \b[A-Z]{2,12}\b 27 | 28 | 29 | - intent: infection_source 30 | examples: | 31 | - what patient is infected by [1234567890](patientid) 32 | - who is infected by [1234567890](patientid)? 33 | - did [1234567890](patientid) infect people ? 34 | - was [1234567890](patientid) a source of infection? 35 | 36 | 37 | 38 | - intent: pokemon_type 39 | examples: | 40 | - what is [AAAAAAAA](pokemontype) type? 41 | - what's the type of [AAAAAAAA](pokemontype)? 42 | 43 | # - intent: pokemon_types 44 | # examples: | 45 | # - what is [Charmender](pokemontype) type? 46 | # - what's the type of [charmender](pokemontype)? 47 | 48 | 49 | 50 | - intent: patient_location 51 | examples: | 52 | - Where is patient [1234567890](patientid) from ? 53 | - where [1234567890](patientid) got infected ? 54 | - at what location [1234567890](patientid) got infected ? 55 | 56 | 57 | 58 | - intent: goodbye 59 | examples: | 60 | - good afternoon 61 | - cu 62 | - good by 63 | - cee you later 64 | - good night 65 | - bye 66 | - goodbye 67 | - have a nice day 68 | - see you around 69 | - bye bye 70 | - see you later 71 | 72 | - intent: affirm 73 | examples: | 74 | - yes 75 | - y 76 | - indeed 77 | - of course 78 | - that sounds good 79 | - correct 80 | 81 | - intent: deny 82 | examples: | 83 | - no 84 | - n 85 | - never 86 | - I don't think so 87 | - don't like that 88 | - no way 89 | - not really 90 | 91 | - intent: mood_great 92 | examples: | 93 | - perfect 94 | - great 95 | - amazing 96 | - feeling like a king 97 | - wonderful 98 | - I am feeling very good 99 | - I am great 100 | - I am amazing 101 | - I am going to save the world 102 | - super stoked 103 | - extremely good 104 | - so so perfect 105 | - so good 106 | - so perfect 107 | 108 | - intent: mood_unhappy 109 | examples: | 110 | - my day was horrible 111 | - I am sad 112 | - I don't feel very well 113 | - I am disappointed 114 | - super sad 115 | - I'm so sad 116 | - sad 117 | - very sad 118 | - unhappy 119 | - not good 120 | - not very good 121 | - extremly sad 122 | - so saad 123 | - so sad 124 | 125 | - intent: bot_challenge 126 | examples: | 127 | - are you a bot? 128 | - are you a human? 129 | - am I talking to a bot? 130 | - am I talking to a human? 131 | -------------------------------------------------------------------------------- /Covid-Chatbot/data/rules.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | 3 | rules: 4 | 5 | - rule: Say goodbye anytime the user says goodbye 6 | steps: 7 | - intent: goodbye 8 | - action: utter_goodbye 9 | 10 | - rule: Say 'I am a bot' anytime the user challenges 11 | steps: 12 | - intent: bot_challenge 13 | - action: utter_iamabot 14 | 15 | - rule: Infection Inquiry 16 | steps: 17 | - intent: infection_source 18 | - action: action_search_patients 19 | 20 | 21 | - rule: Pokemon Inquiry 22 | steps: 23 | - intent: pokemon_type 24 | - action: action_pokemon_type 25 | 26 | 27 | - rule: Location Inquiry 28 | steps: 29 | - intent: patient_location 30 | - action: action_patient_location -------------------------------------------------------------------------------- /Covid-Chatbot/data/stories.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | 3 | stories: 4 | 5 | - story: happy path 6 | steps: 7 | - intent: greet 8 | - action: utter_greet 9 | - intent: mood_great 10 | - action: utter_happy 11 | 12 | - story: health path 13 | steps: 14 | - intent: greet 15 | - action: utter_greet 16 | 17 | 18 | 19 | 20 | - story: sad path 1 21 | steps: 22 | - intent: greet 23 | - action: utter_greet 24 | - intent: mood_unhappy 25 | - action: utter_cheer_up 26 | - action: utter_did_that_help 27 | - intent: affirm 28 | - action: utter_happy 29 | 30 | - story: sad path 2 31 | steps: 32 | - intent: greet 33 | - action: utter_greet 34 | - intent: mood_unhappy 35 | - action: utter_cheer_up 36 | - action: utter_did_that_help 37 | - intent: deny 38 | - action: utter_goodbye 39 | -------------------------------------------------------------------------------- /Covid-Chatbot/domain.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | 3 | intents: 4 | - greet 5 | - goodbye 6 | - affirm 7 | - deny 8 | - mood_great 9 | - mood_unhappy 10 | - bot_challenge 11 | - infection_source 12 | - patient_location 13 | - pokemon_type 14 | 15 | entities: 16 | - patientid 17 | - userlocation 18 | - pokemontype 19 | 20 | slots: 21 | patientid: 22 | type: text 23 | 24 | 25 | responses: 26 | utter_greet: 27 | - text: "Hey! How are you?" 28 | 29 | utter_infection_source_filled: 30 | - text: "there are {count} people infected {patientid}" 31 | utter_infection_source_empty: 32 | - text: "there are no records of infection." 33 | 34 | utter_infection_place_filled: 35 | - text: "the patient {patientid} got infected at {place} " 36 | utter_infection_place_empty: 37 | - text: "there are no records of infection location." 38 | 39 | utter_pokemon_filled: 40 | - text: "The {pokemonname} type is : {pokemontype}" 41 | utter_pokemon_empty: 42 | - text: "No records of the pokemon {pokemonname}." 43 | 44 | 45 | utter_cheer_up: 46 | - text: "Here is something to cheer you up:" 47 | image: "https://i.imgur.com/nGF1K8f.jpg" 48 | 49 | utter_did_that_help: 50 | - text: "Did that help you?" 51 | 52 | utter_happy: 53 | - text: "Great, carry on!" 54 | 55 | utter_goodbye: 56 | - text: "Bye" 57 | 58 | utter_iamabot: 59 | - text: "I am a bot, powered by Rasa." 60 | 61 | # Only modification compared to Sara Chatbot 62 | actions: 63 | - action_search_patients 64 | - action_patient_location 65 | - action_pokemon_type 66 | 67 | session_config: 68 | session_expiration_time: 60 69 | carry_over_slots_to_new_session: true 70 | -------------------------------------------------------------------------------- /Covid-Chatbot/endpoints.yml: -------------------------------------------------------------------------------- 1 | # This file contains the different endpoints your bot can use. 2 | 3 | # Server where the models are pulled from. 4 | # https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server 5 | 6 | #models: 7 | # url: http://my-server.com/models/default_core@latest 8 | # wait_time_between_pulls: 10 # [optional](default: 100) 9 | 10 | # Server which runs your custom actions. 11 | # https://rasa.com/docs/rasa/custom-actions 12 | 13 | action_endpoint: 14 | url: "http://localhost:5055/webhook" 15 | 16 | # Tracker store which is used to store the conversations. 17 | # By default the conversations are stored in memory. 18 | # https://rasa.com/docs/rasa/tracker-stores 19 | 20 | #tracker_store: 21 | # type: redis 22 | # url: 23 | # port: 24 | # db: 25 | # password: 26 | # use_ssl: 27 | 28 | #tracker_store: 29 | # type: mongod 30 | # url: 31 | # db: 32 | # username: 33 | # password: 34 | 35 | # Event broker which all conversation events should be streamed to. 36 | # https://rasa.com/docs/rasa/event-brokers 37 | 38 | #event_broker: 39 | # url: localhost 40 | # username: username 41 | # password: password 42 | # queue: queue 43 | -------------------------------------------------------------------------------- /Covid-Chatbot/requirements.txt: -------------------------------------------------------------------------------- 1 | rasa 2 | pyTigerGraph -------------------------------------------------------------------------------- /Covid-Chatbot/server.sh: -------------------------------------------------------------------------------- 1 | rasa run --endpoints endpoints.yml --connector socketio --credentials credentials.yml --port 5005 --cors "*" --enable-api 2 | rasa run actions 3 | python3 app.py 4 | 5 | 6 | -------------------------------------------------------------------------------- /Covid-Chatbot/story_graph.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | 0 [class="start active", fillcolor=green, fontsize=12, label=START, style=filled]; 3 | "-1" [class=end, fillcolor=red, fontsize=12, label=END, style=filled]; 4 | 1 [class=active, fontsize=12, label=action_session_start]; 5 | 2 [class=active, fontsize=12, label=utter_greet]; 6 | 3 [class="intent dashed active", label=" ? ", shape=rect]; 7 | 4 [class="intent active", fillcolor=lightblue, label=hi, shape=rect, style=filled]; 8 | 0 -> "-1" [class="", key=NONE, label=""]; 9 | 0 -> 1 [class=active, key=NONE, label=""]; 10 | 1 -> 4 [class=active, key=0]; 11 | 2 -> 3 [class=active, key=NONE, label=""]; 12 | 4 -> 2 [class=active, key=0]; 13 | } 14 | -------------------------------------------------------------------------------- /Covid-Chatbot/tests/test_stories.yml: -------------------------------------------------------------------------------- 1 | #### This file contains tests to evaluate that your bot behaves as expected. 2 | #### If you want to learn more, please see the docs: https://rasa.com/docs/rasa/testing-your-assistant 3 | 4 | stories: 5 | - story: happy path 1 6 | steps: 7 | - user: | 8 | hello there! 9 | intent: greet 10 | - action: utter_greet 11 | - user: | 12 | amazing 13 | intent: mood_great 14 | - action: utter_happy 15 | 16 | - story: happy path 2 17 | steps: 18 | - user: | 19 | hello there! 20 | intent: greet 21 | - action: utter_greet 22 | - user: | 23 | amazing 24 | intent: mood_great 25 | - action: utter_happy 26 | - user: | 27 | bye-bye! 28 | intent: goodbye 29 | - action: utter_goodbye 30 | 31 | - story: sad path 1 32 | steps: 33 | - user: | 34 | hello 35 | intent: greet 36 | - action: utter_greet 37 | - user: | 38 | not good 39 | intent: mood_unhappy 40 | - action: utter_cheer_up 41 | - action: utter_did_that_help 42 | - user: | 43 | yes 44 | intent: affirm 45 | - action: utter_happy 46 | 47 | - story: sad path 2 48 | steps: 49 | - user: | 50 | hello 51 | intent: greet 52 | - action: utter_greet 53 | - user: | 54 | not good 55 | intent: mood_unhappy 56 | - action: utter_cheer_up 57 | - action: utter_did_that_help 58 | - user: | 59 | not really 60 | intent: deny 61 | - action: utter_goodbye 62 | 63 | - story: sad path 3 64 | steps: 65 | - user: | 66 | hi 67 | intent: greet 68 | - action: utter_greet 69 | - user: | 70 | very terrible 71 | intent: mood_unhappy 72 | - action: utter_cheer_up 73 | - action: utter_did_that_help 74 | - user: | 75 | no 76 | intent: deny 77 | - action: utter_goodbye 78 | 79 | - story: say goodbye 80 | steps: 81 | - user: | 82 | bye-bye! 83 | intent: goodbye 84 | - action: utter_goodbye 85 | 86 | - story: bot challenge 87 | steps: 88 | - user: | 89 | are you a bot? 90 | intent: bot_challenge 91 | - action: utter_iamabot 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## RASA Unleashed with TigerGraph : 2 | 3 | ![](web/static/rasa_image.png) 4 | 5 | ## Demo : 6 | 7 | ![](web-rasa-tigergraph.gif) 8 | 9 | ### Configuration : 10 | 11 | please edit these variables 12 | 13 | ``` 14 | configs = { 15 | "host": "https://.i.tgcloud.io", 16 | "password": "", 17 | "graphname": "", 18 | "secret" : "" 19 | } 20 | ``` 21 | in : 22 | 23 | ``` 24 | rasaconnector/test.py 25 | Covid-Chatbot/actions/actions.py 26 | 27 | ``` 28 | 29 | 30 | 31 | ### Connector (test.py) 32 | 33 | 34 | ``` 35 | $ cd rasaconnector 36 | $ python3 -m virtualenv -p python3 . 37 | $ source bin/activate 38 | $ pip install requirements.txt 39 | $ python3 test.py 40 | 41 | ``` 42 | 43 | ### WEB (Port 5000) 44 | 45 | ``` 46 | $ cd web 47 | $ python3 -m virtualenv -p python3 . 48 | $ source bin/activate 49 | $ pip install requirements.txt 50 | $ python3 app.py 51 | 52 | ``` 53 | 54 | ### Assistant (Port 5005) 55 | 56 | ``` 57 | $ cd Covid-Chatbot 58 | $ python3 -m virtualenv -p python3 . 59 | $ source bin/activate 60 | $ pip install requirements.txt 61 | $ rasa train 62 | $ rasa run --endpoints endpoints.yml --connector socketio --credentials credentials.yml --port 5005 --cors "*" --enable-api 63 | 64 | ``` 65 | 66 | 67 | ### Actions Server (Port 5055) 68 | 69 | ``` 70 | $ cd Covid-Chatbot 71 | $ source bin/activate 72 | $ rasa run actions 73 | 74 | ``` 75 | 76 | 77 | Please check the ToDo in Covid-Chatbot Folder for detailed Steps 78 | -------------------------------------------------------------------------------- /rasaconnector/.gitignore: -------------------------------------------------------------------------------- 1 | # created by virtualenv automatically 2 | * 3 | -------------------------------------------------------------------------------- /rasaconnector/Samples/Edges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/rasaconnector/Samples/Edges.png -------------------------------------------------------------------------------- /rasaconnector/Samples/NLU.csv: -------------------------------------------------------------------------------- 1 | ;TYPE;INTENT;VALUE 2 | 1;intent;greet;hey 3 | 2;intent;greet;Hello 4 | 3;intent;greet;hi 5 | 4;intent;greet;good morning 6 | 5;intent;greet;good evening 7 | ;intent;greet;ola 8 | 6;intent;greet;hey there 9 | 7;intent;goodbye;bye 10 | 8;intent;goodbye;goodbye 11 | 9;intent;goodbye;see you later 12 | 10;intent;goodbye;see you around 13 | 11;intent;affirm;yes 14 | 12;intent;affirm;yep 15 | 13;intent;affirm;indeed 16 | 14;intent;affirm;of course 17 | 15;intent;affirm;correct 18 | 16;intent;deny;no 19 | 17;intent;deny;never 20 | 18;intent;deny;I don't think so 21 | 19;intent;deny;don't like that 22 | 20;intent;deny;no way 23 | 21;intent;deny;not really 24 | 22;intent;affirm;that sounds good 25 | 23;intent;mood_great;perfect 26 | 24;intent;mood_great;very good 27 | 25;intent;mood_great;great 28 | 26;intent;mood_great;amazing 29 | 27;intent;mood_great;wonderful 30 | 28;intent;mood_great;I am feeling very good 31 | 29;intent;mood_great;I am great 32 | 30;intent;mood_great;I'm good 33 | 31;intent;mood_great;I am good 34 | 32;intent;mood_great;I'm fine 35 | 33;intent;mood_great;fine 36 | 34;intent;mood_unhappy;sad 37 | 35;intent;mood_unhappy;very sad 38 | 36;intent;mood_unhappy;unhappy 39 | 37;intent;mood_unhappy;bad 40 | 38;intent;mood_unhappy;very bad 41 | 39;intent;mood_unhappy;awful 42 | 40;intent;mood_unhappy;terrible 43 | 41;intent;mood_unhappy;not very good 44 | 42;intent;mood_unhappy;extremely sad 45 | 43;intent;mood_unhappy;so sad 46 | 44;intent;mood_unhappy;not good 47 | 45;intent;mood_unhappy;so so 48 | 46;intent;bot_challenge;are you a bot? 49 | 47;intent;bot_challenge;are you a human? 50 | 48;intent;bot_challenge;am I talking to a bot? 51 | 49;intent;bot_challenge;am I talking to a human? 52 | 50;intent;age;which age groups have covid-19? 53 | 51;intent;age;covid-19 affects which ages? 54 | 52;intent;age;what is the number of infected patients in years 55 | 53;intent;age;what is the number of years old infected patients 56 | 54;intent;age;what is the number of years old infected patients 57 | 55;intent;infected;who were infected by patient 58 | 56;intent;infected;who infected patient 59 | 57;intent;infected;which patients did patient infect? 60 | 58;intent;appointement;Can i have an appointement? 61 | -------------------------------------------------------------------------------- /rasaconnector/Samples/nlu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/rasaconnector/Samples/nlu.png -------------------------------------------------------------------------------- /rasaconnector/Samples/nlu.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | nlu: 3 | - intent: greet 4 | examples: | 5 | - hey 6 | - Hello 7 | - hi 8 | - good morning 9 | - good evening 10 | - hey there 11 | - intent: goodbye 12 | examples: | 13 | - bye 14 | - goodbye 15 | - see you later 16 | - see you around 17 | - intent: affirm 18 | examples: | 19 | - yes 20 | - yep 21 | - indeed 22 | - of course 23 | - correct 24 | - that sounds good 25 | - intent: deny 26 | examples: | 27 | - no 28 | - never 29 | - I don't think so 30 | - don't like that 31 | - no way 32 | - not really 33 | - intent: mood_great 34 | examples: | 35 | - perfect 36 | - very good 37 | - great 38 | - amazing 39 | - wonderful 40 | - I am feeling very good 41 | - I am great 42 | - I'm good 43 | - I am good 44 | - I'm fine 45 | - fine 46 | - intent: mood_unhappy 47 | examples: | 48 | - sad 49 | - very sad 50 | - unhappy 51 | - bad 52 | - very bad 53 | - awful 54 | - terrible 55 | - not very good 56 | - extremely sad 57 | - so sad 58 | - not good 59 | - so so 60 | - intent: bot_challenge 61 | examples: | 62 | - are you a bot? 63 | - are you a human? 64 | - am I talking to a bot? 65 | - am I talking to a human? 66 | - intent: age 67 | examples: | 68 | - which age groups have covid-19? 69 | - covid-19 affects which ages? 70 | - what is the number of infected patients in years 71 | - what is the number of years old infected patients 72 | - what is the number of years old infected patients 73 | - intent: infected 74 | examples: | 75 | - who were infected by patient 76 | - who infected patient 77 | - which patients did patient infect? 78 | - intent: appointement 79 | examples: | 80 | - Can i have an appointement? 81 | -------------------------------------------------------------------------------- /rasaconnector/Samples/stories.csv: -------------------------------------------------------------------------------- 1 | ID;type;info;intent;value;;; 2 | 1;info;happy path;greet;utter_greet;;; 3 | 2;info;happy path;mood_great;utter_happy;;; 4 | 3;info;sad path 1;greet;utter_greet;;; 5 | 4;info;sad path 1;mood_unhappy;utter_cheer_up;;; 6 | 5;info;sad path 1;mood_unhappy;utter_did_that_help;;; 7 | 6;info;sad path 1;affirm;utter_happy;;; 8 | 7;info;sad path 2;greet;utter_greet;;; 9 | 8;info;sad path 2;mood_unhappy;utter_cheer_up;;; 10 | 9;info;sad path 2;mood_unhappy;utter_did_that_help;;; 11 | 10;info;sad path 2;deny;utter_goodbye;;; 12 | 11;info;say goodbye;goodbye;utter_goodbye;;; 13 | 12;info;bot challenge;bot challenge;"utter_iamabot 14 | -------------------------------------------------------------------------------- /rasaconnector/Samples/stories.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/rasaconnector/Samples/stories.png -------------------------------------------------------------------------------- /rasaconnector/Samples/stories.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | stories: 3 | -story: happy path 4 | steps: 5 | - intent: greet 6 | - action: utter_greet 7 | - intent: mood_great 8 | - action: utter_happy 9 | -story: sad path 1 10 | steps: 11 | - intent: greet 12 | - action: utter_greet 13 | - intent: mood_unhappy 14 | - action: utter_cheer_up 15 | - action: utter_did_that_help 16 | - intent: affirm 17 | - action: utter_happy 18 | -story: sad path 2 19 | steps: 20 | - intent: greet 21 | - action: utter_greet 22 | - intent: mood_unhappy 23 | - action: utter_cheer_up 24 | - action: utter_did_that_help 25 | - intent: deny 26 | - action: utter_goodbye 27 | -story: say goodbye 28 | steps: 29 | - intent: goodbye 30 | - action: utter_goodbye 31 | -story: bot challenge 32 | steps: 33 | - intent: bot challenge 34 | - action: "utter_iamabot 35 | -------------------------------------------------------------------------------- /rasaconnector/requirements.txt: -------------------------------------------------------------------------------- 1 | pyTigerGraph -------------------------------------------------------------------------------- /rasaconnector/test.py: -------------------------------------------------------------------------------- 1 | import pyTigerGraph as tg 2 | 3 | #######################################"" 4 | configs = { 5 | "host": "https://.i.tgcloud.io", 6 | "password": "", 7 | "graphname": "", 8 | "secret" : "" 9 | } 10 | #######################################" 11 | 12 | 13 | 14 | 15 | conn = tg.TigerGraphConnection(host=configs['host'], password=configs['password'], gsqlVersion="3.0.5", useCert=True, graphname=configs['graphname']) 16 | conn.apiToken = conn.getToken(configs['secret']) 17 | conn.gsql("USE graph {}".format(configs['graphname'])) 18 | #######################################" 19 | 20 | def nlu_md(): 21 | res = conn.gsql("SELECT type,intent,value FROM nlu LIMIT 100") 22 | intent = "" 23 | nlus = {} 24 | order = [] 25 | for element in res: 26 | order.append(element["v_id"]) 27 | order = sorted([int(x) for x in order]) 28 | for element in order: 29 | for e in res: 30 | if int(e["v_id"]) == element: 31 | if e["attributes"]["intent"] in nlus: 32 | nlus[e["attributes"]["intent"]].append(e["attributes"]["value"]) 33 | else: 34 | nlus[e["attributes"]["intent"]] = [e["attributes"]["value"]] 35 | break 36 | f = open("nlu.md","w") 37 | for intent in nlus: 38 | f.write("## intent:{}\n".format(intent)) 39 | for value in nlus[intent]: 40 | f.write(" - {}\n".format(value)) 41 | f.close() 42 | 43 | 44 | def stories_md(): 45 | res = conn.gsql("SELECT type,info,intent,value FROM stories LIMIT 100") 46 | info = "" 47 | intent = "" 48 | f = open("stories.md","w") 49 | story = {} 50 | order = [] 51 | for element in res: 52 | order.append(element["v_id"]) 53 | order = sorted([int(x) for x in order]) 54 | for element in order: 55 | for e in res: 56 | if int(e["v_id"]) == element: 57 | if e["attributes"]["info"] in story: 58 | if e["attributes"]["intent"] in story[e["attributes"]["info"]]: 59 | story[e["attributes"]["info"]][e["attributes"]["intent"]].append(e["attributes"]["value"]) 60 | else: 61 | story[e["attributes"]["info"]][e["attributes"]["intent"]] = [e["attributes"]["value"]] 62 | else: 63 | story[e["attributes"]["info"]] = {e["attributes"]["intent"]:[e["attributes"]["value"]]} 64 | break 65 | for info in story: 66 | f.write("## {}\n".format(info)) 67 | for intent in story[info]: 68 | f.write("* {}\n".format(intent)) 69 | for value in story[info][intent]: 70 | f.write(" - {}\n".format(value)) 71 | f.close() 72 | 73 | 74 | 75 | 76 | 77 | 78 | def nlu_yml(): 79 | res = conn.gsql("SELECT type,intent,value FROM nlu LIMIT 100") 80 | intent = "" 81 | nlus = {} 82 | order = [] 83 | for element in res: 84 | order.append(element["v_id"]) 85 | order = sorted([int(x) for x in order]) 86 | for element in order: 87 | for e in res: 88 | if int(e["v_id"]) == element: 89 | if e["attributes"]["intent"] in nlus: 90 | nlus[e["attributes"]["intent"]].append(e["attributes"]["value"]) 91 | else: 92 | nlus[e["attributes"]["intent"]] = [e["attributes"]["value"]] 93 | break 94 | f = open("nlu.yml","w") 95 | f.write('version: "2.0"\n') 96 | f.write("nlu:\n") 97 | for intent in nlus: 98 | f.write("- intent: {}\n".format(intent)) 99 | f.write(" examples: |\n") 100 | for value in nlus[intent]: 101 | f.write(" - {}\n".format(value)) 102 | f.close() 103 | 104 | 105 | def stories_yml(): 106 | res = conn.gsql("SELECT type,info,intent,value FROM stories LIMIT 100") 107 | info = "" 108 | intent = "" 109 | f = open("stories.yml","w") 110 | story = {} 111 | order = [] 112 | f.write('version: "2.0"\n') 113 | f.write("stories:\n") 114 | for element in res: 115 | order.append(element["v_id"]) 116 | order = sorted([int(x) for x in order]) 117 | for element in order: 118 | for e in res: 119 | if int(e["v_id"]) == element: 120 | if e["attributes"]["info"] in story: 121 | if e["attributes"]["intent"] in story[e["attributes"]["info"]]: 122 | story[e["attributes"]["info"]][e["attributes"]["intent"]].append(e["attributes"]["value"]) 123 | else: 124 | story[e["attributes"]["info"]][e["attributes"]["intent"]] = [e["attributes"]["value"]] 125 | else: 126 | story[e["attributes"]["info"]] = {e["attributes"]["intent"]:[e["attributes"]["value"]]} 127 | break 128 | for info in story: 129 | f.write("-story: {}\n".format(info)) 130 | f.write(" steps:\n") 131 | for intent in story[info]: 132 | f.write(" - intent: {}\n".format(intent)) 133 | for value in story[info][intent]: 134 | f.write(" - action: {}\n".format(value)) 135 | f.close() 136 | 137 | 138 | ################### RUN YML ##############" 139 | nlu_yml() 140 | stories_yml() 141 | 142 | 143 | ################### RUN MD ##############" 144 | nlu_md() 145 | stories_md() 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /web-rasa-tigergraph.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web-rasa-tigergraph.gif -------------------------------------------------------------------------------- /web-rasa-tigergraph.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web-rasa-tigergraph.mp4 -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | # created by virtualenv automatically 2 | * 3 | -------------------------------------------------------------------------------- /web/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | from flask import render_template 3 | 4 | app = Flask(__name__, static_url_path='/static') 5 | 6 | @app.route("/") 7 | def index(): 8 | return render_template('index.html') 9 | 10 | 11 | if __name__ == "__main__": 12 | app.run(debug=True) -------------------------------------------------------------------------------- /web/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web/requirements.txt -------------------------------------------------------------------------------- /web/static/Screen Shot 2020-12-09 at 1.07.47 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web/static/Screen Shot 2020-12-09 at 1.07.47 PM.png -------------------------------------------------------------------------------- /web/static/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web/static/bot.png -------------------------------------------------------------------------------- /web/static/rasa_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TigerGraph-DevLabs/RASA/941ea73bd8e183844ea346af0ed4d162eff8ffc1/web/static/rasa_image.png -------------------------------------------------------------------------------- /web/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | The TigerGraph Rasa Chatbot Demo 10 | 11 | 12 |
13 |
14 |
15 |
16 | 17 | 43 |
44 | 45 | 46 | --------------------------------------------------------------------------------