Browse Source

Adding initial files

master
siddharth srivastava 2 years ago
parent
commit
e95ee787cb
17 changed files with 324 additions and 63 deletions
  1. BIN
      .rasa/cache/cache.db
  2. BIN
      __pycache__/database_connectivity.cpython-38.pyc
  3. BIN
      actions/__pycache__/__init__.cpython-38.pyc
  4. BIN
      actions/__pycache__/actions.cpython-38.pyc
  5. +35
    -4
      actions/actions.py
  6. BIN
      dget.jpg
  7. BIN
      assets/bot_widget-removebg-preview.png
  8. +0
    -0
      assets/demo.html
  9. BIN
      assets/robo_small.gif
  10. +40
    -48
      data/nlu.yml
  11. +22
    -1
      data/stories.yml
  12. +23
    -0
      database_connectivity.py
  13. +34
    -6
      domain.yml
  14. +2
    -2
      endpoints.yml
  15. +158
    -2
      index.html
  16. BIN
      models/20220905-122855-ragged-pintail.tar.gz
  17. +10
    -0
      testing.py

BIN
.rasa/cache/cache.db View File


BIN
__pycache__/database_connectivity.cpython-38.pyc View File


BIN
actions/__pycache__/__init__.cpython-38.pyc View File


BIN
actions/__pycache__/actions.cpython-38.pyc View File


+ 35
- 4
actions/actions.py View File

@@ -7,10 +7,12 @@

# This is a simple example for a custom action which utters "Hello World!"

# from typing import Any, Text, Dict, List
#
# from rasa_sdk import Action, Tracker
# from rasa_sdk.executor import CollectingDispatcher
from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from database_connectivity import DataUpdate
import datetime
#
#
# class ActionHelloWorld(Action):
@@ -25,3 +27,32 @@
# dispatcher.utter_message(text="Hello World!")
#
# return []

# class ActionHelloWorld(Action):

# def name(self) -> Text:
# return "action_hello_world"

# def run(self, dispatcher: CollectingDispatcher,
# tracker: Tracker,
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

# dispatcher.utter_message(text="Hello World!")

# return []



#FOR DATABASE CONNECTIVITY AND UPDATION.
# class ActionSubmit(Action):
# def name(self) -> Text:
# return "action_submit"

# def run(self, dispatcher: CollectingDispatcher,
# tracker: Tracker,
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

# current_time = str(datetime.datetime.now())
# current_time = current_time.split(":")
# current_time = current_time[0] + ":" + current_time[1]
# DataUpdate(tracker.get_slot("name"),tracker.get_slot("email"), current_time, tracker.sender_id)

BIN
assets/bot → dget.jpg View File


BIN
assets/bot_widget-removebg-preview.png View File

Before After
Width: 455  |  Height: 468  |  Size: 77 KiB

+ 0
- 0
assets/demo.html View File


BIN
assets/robo_small.gif View File

Before After
Width: 455  |  Height: 468  |  Size: 1.9 MiB

+ 40
- 48
data/nlu.yml View File

@@ -13,7 +13,7 @@ nlu:
- tell me about the pm kusum scheme
- pm kusum scheme details
- PM-KUSUM scheme informatio
- What is pm kusum?
- What is pm kusum?

- intent: component_A
examples: |
@@ -31,11 +31,14 @@ nlu:
- eligible A
- Who is eligible under Component A of PM-KUSUM Scheme?
- component A eligibility
- who can apply for component A?
- who can apply for component A?
- who is eligible for component A?

- intent: electricity
examples: |
- Who will purchase the generated electricity?
- who will purchase the generated electricity?
- who will buy the electricity?
- the generated electricity will be bought by whom?

- intent: lease
examples: |
@@ -131,50 +134,6 @@ nlu:
- that sounds good
- correct

- intent: deny
examples: |
- no
- n
- never
- I don't think so
- don't like that
- no way
- not really

- intent: mood_great
examples: |
- perfect
- great
- amazing
- feeling like a king
- wonderful
- I am feeling very good
- I am great
- I am amazing
- I am going to save the world
- super stoked
- extremely good
- so so perfect
- so good
- so perfect

- intent: mood_unhappy
examples: |
- my day was horrible
- I am sad
- I don't feel very well
- I am disappointed
- super sad
- I'm so sad
- sad
- very sad
- unhappy
- not good
- not very good
- extremly sad
- so saad
- so sad

- intent: bot_challenge
examples: |
- are you a bot?
@@ -199,5 +158,38 @@ nlu:
- thank you so much
- thank you
- thank u

- intent: name
examples: |
- siddharth srivastava
- rahul
- yashvant
- prashant sathe
- aryan
- pradip
- rohan verma
- ayappa nagubandi
- vivek sharma
- sanket yadav
- piyush
- tejas varale
- sachin jadhav
- ajay
- santosh
- varun oberoi
- salman shaikh
- mohna
- nikita

- intent: email
examples: |
- rahul@gmail.com
- siddharth45@gmail.com
- yashsathe@yahoo.in
- abhijeet33@gmail.com
- intent: start
examples: |
- "hey"
- "Hi"
- "/start"

+ 22
- 1
data/stories.yml View File

@@ -70,4 +70,25 @@ stories:
- story: Out of scope
steps:
- intent: out_of_scope
- action: utter_default
- action: utter_default

# - story: user_information
# steps:
# - intent: start
# - action: utter_name
# - or:
# - intent: name
# - intent: electricity
# - intent: scheme
# - intent: component_A
# - intent: component_B
# - intent: component_C
# - intent: affirm
# - slot_was_set:
# - name: siddharth
# - action: utter_email
# - intent: email
# - slot_was_set:
# - email: siddharth@gmail.com
# - action: action_submit
# - action: utter_greet

+ 23
- 0
database_connectivity.py View File

@@ -0,0 +1,23 @@
import mysql.connector

def DataUpdate(name, email, date, session_id):
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
password = "1234",
database = "mydatabase"
)

mycursor = mydb.cursor()

#sql = "CREATE TABLE user_information (Name VARCHAR(255), Email VARCHAR(255), Date VARCHAR(255), Session ID VARCHAR(255));"
sql = 'INSERT INTO user_data (Name, Email, Date, Session_ID) VALUES ("{}", "{}", "{}", "{}");'.format(name, email, date, session_id)

mycursor.execute(sql)

mydb.commit()

print("Successful!")

#if __name__ == "__main__":
#DataUpdate("siddharth", "siddharth@gmail.com")

+ 34
- 6
domain.yml View File

@@ -17,12 +17,24 @@ intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- thanking
- out_of_scope
- name
- email
- start

# slots:
# name:
# type: text
# mappings:
# - type: from_text
# intent: name
# email:
# type: text
# mappings:
# - type: from_text
# intent: email

responses:
utter_eligible_A:
@@ -35,7 +47,7 @@ responses:
- title: "Know more about component B"
payload: '/component_B'
- title: "Know more about component C"
payload: '/component_C'
payload: '/component_C'

utter_electricity:
- text: "Power generated will be purchased by the local electricity distribution companies (Discoms)"
@@ -156,7 +168,14 @@ responses:
payload: '/component_C'

utter_greet:
- text: "Hello there! What would you like to know about PM-KUSUM?"
- text: "Hii! Welcome to PM-KUSUM.\n \n Get started using our quick links or start conversation by entering your query."
buttons:
- title: "Information about component A"
payload: '/component_A'
- title: "Information about component B"
payload: '/component_B'
- title: "Who will purchase the generated electricity?"
payload: '/electricity'

utter_goodbye:
- text: "Have a nice day. Bye!"
@@ -170,6 +189,15 @@ responses:
utter_your_welcome:
- text: "You're welcome!"

utter_name:
- text: "Enter your name: "

utter_email:
- text: "Enter your email ID: "

actions:
- action_submit

session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
carry_over_slots_to_new_session: False

+ 2
- 2
endpoints.yml View File

@@ -10,8 +10,8 @@
# Server which runs your custom actions.
# https://rasa.com/docs/rasa/custom-actions

#action_endpoint:
# url: "http://localhost:5055/webhook"
action_endpoint:
url: "http://localhost:5055/webhook"

# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.


+ 158
- 2
index.html View File

@@ -1,5 +1,152 @@
<html>
<head>
<style>
/* Some miscellenous widget manipulation */
.rw-launcher {
-webkit-animation-delay: 0;
-webkit-animation-duration: 0.5s;
-webkit-animation-name: slide-in;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: 0;
-moz-animation-duration: 0.5s;
-moz-animation-name: slide-in;
-moz-animation-fill-mode: forwards;
animation-delay: 0;
animation-duration: 0.5s;
animation-name: slide-in;
animation-fill-mode: forwards;
display: flex;
align-items: center !important;
justify-content: center;
background-color: white !important;
border: 0 !important;
box-shadow: 0 2px 10px 1px white!important;
height: 125px !important;
margin: 0;
width: 125px !important;
box-sizing:border-box
}
/* Resizing the widget */
.rw-launcher img {
width: 125 !important;
max-height: 125 !important;
object-fit: contain !important;
}
/* Getting rid of the rotation animation of the widget while closing */
.rw-close-launcher {
-webkit-animation-delay: 0;
-webkit-animation-duration: 0s !important;
-webkit-animation-name: rotation-lr !important;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: 0;
-moz-animation-duration: 0s !important;
-moz-animation-name: rotation-lr !important;
-moz-animation-fill-mode: forwards;
animation-delay: 0;
animation-duration: 0s !important;
animation-name: rotation-lr !important;
animation-fill-mode: forwards;
}

/* Getting rid of the rotation animation of the widget while opening */
.rw-open-launcher {
-webkit-animation-delay: 0;
-webkit-animation-duration: 0.5s;
-webkit-animation-name: rotation-rl;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: 0;
-moz-animation-duration: .5s;
-moz-animation-name: rotation-rl;
-moz-animation-fill-mode: forwards;
animation-delay: 0;
animation-duration: 0s !important;
animation-name: rotation-rl;
animation-fill-mode: forwards;
}
</style>
</head>
<body>
<style>
/* Background color for the header */
.rw-conversation-container .rw-header{background-color: #233e80;}
/* Correction of the shadow for the chat window */
.rw-conversation-container {
-webkit-animation-delay: 0;
-webkit-animation-duration: .5s;
-webkit-animation-name: slide-in;
-webkit-animation-fill-mode: forwards;
-moz-animation-delay: 0;
-moz-animation-duration: .5s;
-moz-animation-name: slide-in;
-moz-animation-fill-mode: forwards;
animation-delay: 0;
animation-duration: .5s;
animation-name: slide-in;
animation-fill-mode: forwards;
border-radius: 10px;
box-shadow: 0px -20px 12px 0px hsl(0deg 14% 89% / 0%), inset 4px -7px 3.7px -1px rgb(0 0 0 / 7%), 0 5px 7px -1px hsl(0deg 0% 0% / 9%), 2px -8px 12.5px -1px rgb(84 25 25 / 10%), 2px -6px 23.4px 0px rgb(255 0 0 / 12%), inset -3px -5px 56px 0px rgb(237 0 0 / 17%);
overflow: hidden;
width: 370px;
}
/* Resizing avatar (to the left of replies) */
.rw-conversation-container .rw-avatar {
width: 55px;
height: 55px;
border-radius: 100%;
margin-right: -3px;
/* position: relative; */
bottom: 0px;
}
/* Positioning the avatar to the left of replies rather than at the top*/
.rw-conversation-container .rw-message {
margin: 10px;
font-size: 16px;
line-height: 20px;
display: flex;
font-family: Inter,sans-serif;
flex-wrap: unset !important;
position: relative;
}
/* Header avatar resizing */
.rw-conversation-container .rw-header .rw-avatar {
all: initial;
height: 57px;
width: 57px;
position: absolute;
top: 4px;
left: 0px;
}
/* Color box for buttons (payload) */
.rw-conversation-container .rw-reply {
-webkit-transition: box-shadow .3s ease,top .3s ease;
-moz-transition: box-shadow .3s ease,top .3s ease;
-o-transition: box-shadow .3s ease,top .3s ease;
transition: box-shadow .3s ease,top .3s ease;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
-webkit-flex-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
background-color: #fafafa;
border: 1px solid #135afe;
border-radius: 15px;
color: #233e80;
padding: 4px 8px;
max-width: 215px;
min-height: 1.7em;
font-weight: 500;
text-align: center;
font-family: Inter,sans-serif;
cursor: pointer;
margin: 0.25em;
text-decoration: unset;
box-shadow: unset !important/*0 .2px .7px -7pxrgba(0,0,0,.277),0 .5px 1.8px -7pxrgba(0,0,0,.369),0 1.2px 3.8px -7pxrgba(0,0,0,.442),0 4px 13px -7pxrgba(0,0,0,.64);*/
}
</style>
<script>!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
@@ -8,12 +155,21 @@
// Replace 1.x.x with the version that you want
(e.async = !0),
(e.onload = () => {
window.localStorage.clear()
window.WebChat.default(
{
initPayload: '/greet',
customData: { language: "en" },
socketUrl: "https://rasa-chatbot-1234.herokuapp.com",
socketUrl: "http://localhost:5005",
profileAvatar: "./assets/bot_widget-removebg-preview.png",
openLauncherImage: "./assets/robo_small.gif",
closeImage: "./assets/robo_small.gif",
title: "PM-KUSUM",
inputTextFieldHint: "Start a conversation",
connectingText: 'Waiting for server...',
showCloseButton: true
// add other props here
},
},
null
);
}),


BIN
models/20220729-142405-clean-hop.tar.gz → models/20220905-122855-ragged-pintail.tar.gz View File


+ 10
- 0
testing.py View File

@@ -0,0 +1,10 @@
# name = 'Siddharth'
# email = 'siddharthsrivastava77@gmail.com'

# print('INSERT INTO users (name, email) VALUES ("{}", "{}");'.format(name, email))
import datetime
# using now() to get current time
current_time = str(datetime.datetime.now())
current_time = current_time.split(":")
print(current_time[0] + ":" + current_time[1])

Loading…
Cancel
Save