Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatbot Deployment #5

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d8e66a3
Initial push
Daryl-Loo Jan 24, 2022
813421a
Desktop setup
Daryl-Loo Jan 24, 2022
494da03
vmware
Daryl-Loo Jan 24, 2022
64a82e2
changes from nicholas
Daryl-Loo Jan 24, 2022
ca63f66
updated intents
Daryl-Loo Jan 25, 2022
060fcc3
Changes from Nicholas (limit request)
Daryl-Loo Jan 25, 2022
f542b1c
some misc changes at the end ofday
Daryl-Loo Jan 25, 2022
d6c58ad
trained model
Daryl-Loo Jan 25, 2022
4305406
failed approach to welcome message
Daryl-Loo Jan 27, 2022
028f771
Added start prompt for bot
limnicholased Jan 27, 2022
691f8ac
changes prior to amending the intents
Daryl-Loo Jan 28, 2022
cda72d5
partial intents changes
Daryl-Loo Jan 28, 2022
2d8a7bf
Updated prompt message to produce one time render
limnicholased Jan 28, 2022
97487dc
partial intents
Daryl-Loo Jan 28, 2022
04be3cb
Merge branch 'main' of https://github.com/Daryl-Loo/chatbot-deployment
Daryl-Loo Jan 28, 2022
e2805ff
corrected minor grammatical error
limnicholased Jan 28, 2022
655569b
updated capitalization for 'live' in live agent
limnicholased Jan 28, 2022
4813495
Updated to DiGiCOR logo
limnicholased Jan 28, 2022
475c857
updated to DiGiCOR logo
limnicholased Jan 28, 2022
f9072d5
final push before changing
Daryl-Loo Feb 14, 2022
9eb995a
Merge branch 'main' of https://github.com/Daryl-Loo/chatbot-deployment
Daryl-Loo Feb 14, 2022
586f9d8
moving folder
Daryl-Loo Feb 14, 2022
92c3baa
Guidelines for Chatbot Development
limnicholased Feb 14, 2022
4392a23
Update README.md
limnicholased Feb 14, 2022
525f747
Update README.md
limnicholased Feb 14, 2022
bc0105b
Update README.md
limnicholased Feb 14, 2022
261247f
Update README.md
limnicholased Feb 14, 2022
ec85b70
Add files via upload
limnicholased Feb 14, 2022
8a5245c
Add files via upload
limnicholased Feb 14, 2022
d7d5ff5
Add files via upload
limnicholased Feb 14, 2022
226cd8e
Add files via upload
limnicholased Feb 14, 2022
2a4fefd
Add files via upload
limnicholased Feb 14, 2022
0970211
Add files via upload
limnicholased Feb 14, 2022
b196d0d
Add files via upload
limnicholased Feb 14, 2022
d02d259
Instructions
limnicholased Feb 14, 2022
227eb77
Update README.md
Daryl-Loo Feb 14, 2022
6b78409
Update README.md
Daryl-Loo Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added Advanced Search Page Queries.docx
Binary file not shown.
Binary file added Commercial API Comparisons.pdf
Binary file not shown.
Binary file added Dynamic Link Format.pdf
Binary file not shown.
Binary file added Prior Correspondence.pdf
Binary file not shown.
Binary file added Pros and Cons Analysis - Chatbot APIs.pptx
Binary file not shown.
100 changes: 48 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
# Chatbot Deployment with Flask and JavaScript

In this tutorial we deploy the chatbot I created in [this](https://github.com/python-engineer/pytorch-chatbot) tutorial with Flask and JavaScript.

This gives 2 deployment options:
- Deploy within Flask app with jinja2 template
- Serve only the Flask prediction API. The used html and javascript files can be included in any Frontend application (with only a slight modification) and can run completely separate from the Flask App then.

## Initial Setup:
This repo currently contains the starter files.

Clone repo and create a virtual environment
```
$ git clone https://github.com/python-engineer/chatbot-deployment.git
$ cd chatbot-deployment
$ python3 -m venv venv
$ . venv/bin/activate
```
Install dependencies
```
$ (venv) pip install Flask torch torchvision nltk
```
Install nltk package
```
$ (venv) python
>>> import nltk
>>> nltk.download('punkt')
```
Modify `intents.json` with different intents and responses for your Chatbot

Run
```
$ (venv) python train.py
```
This will dump data.pth file. And then run
the following command to test it in the console.
```
$ (venv) python chat.py
```

Now for deployment follow my tutorial to implement `app.py` and `app.js`.

## Watch the Tutorial
[![Alt text](https://img.youtube.com/vi/a37BL0stIuM/hqdefault.jpg)](https://youtu.be/a37BL0stIuM)
[https://youtu.be/a37BL0stIuM](https://youtu.be/a37BL0stIuM)

## Note
In the video we implement the first approach using jinja2 templates within our Flask app. Only slight modifications are needed to run the frontend separately. I put the final frontend code for a standalone frontend application in the [standalone-frontend](/standalone-frontend) folder.

## Credits:
This repo was used for the frontend code:
https://github.com/hitchcliff/front-end-chatjs
# Chatbot Training and Deployment

Objective:

We are planning to deploy a new chatbot for our FAQ Page.
The chatbot should be able to identify certain key phrasings from user input,
such as the make and models of a specific product on our site, and often,
multiple products names will appear in a single input.
Our advanced search function currently yields the relevant results according to user queries.
We are looking to implement a chatbot that can aid user navigation via the chatbot by providing dynamic links to our advanced search page
(comprising a list of filtered/relevant products according to user queries).
We have a specific format for our dynamic link generation but in order to construct it,
and we require the extraction of the aforementioned key phrases and entity recognition in order to amalgamate them into the required link structure.

Project Chatbot: https://docs.google.com/spreadsheets/d/17QFaHgvD6dlTbNiOdj4rlE-T3I7H9fXXHaNJVZ4-A0Y/edit?usp=sharing

Research: https://docs.google.com/document/d/11yLE81vcrzVn15s2jeLP5cnzcMiyKryaz84i_KLOtL4/edit?usp=sharing

Various approaches to DiGiCOR chatbot prototypes, ranked from best (1) to worst (7):
1. IBM Watson Assistant and Discovery
2. Amazon Lex
3. Wit.ai with Messenger
4. Alterra.ai with Messenger
5. DialogFlow with Google AutoML
6. Microsoft Azure Cognitive Services for Language
7. Python Libraries (NLTK/ Spacy)

Conclusion:

Based on assessments of key features/functionality, IBM Watson Assistant (Plus) is the chosen approach as approved by Roham, Richard and Cathy.
Begin by setting up the IBM Cloud Account (requires a credit/debit card, ask Cathy/Roham for it), there should be no immediate charge.
Start training the chatbot intents and utterances using IBM Watson Assistant Lite. Request for approval for Plus Subscription when required.
Live Agent Handover, Dynamic Link Generation and FAQ training can all be handled by IBM Watson Assistant (Provides entity recognition and key-phrase extraction).
Watson Discovery (optional extension) is a powerful search engine that performs web scraping for the site to yield potential relevant responses to unclear user input.

Guidelines:

Develop your roadmap as required.
Training and Testing should take 2- 3 weeks.

Assistance:

IBM Support - $250/month
OutThought Consultant - $1800/day

Links to IBM Assistant Docs that would be useful:
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-welcome-new-assistant
Walks you through step by step on how to make and deploy the assistant
25 changes: 25 additions & 0 deletions flask chatbot/.idea/chatbot-deployment.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flask chatbot/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flask chatbot/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions flask chatbot/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flask chatbot/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

153 changes: 153 additions & 0 deletions flask chatbot/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions flask chatbot/Flask Application Setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$ git clone https://github.com/python-engineer/chatbot-deployment.git
$ cd chatbot-deployment
$ python3 -m venv venv
$ venv\Scripts\activate
$ conda create -n py39 python=3.9
$ conda activate py39
$ pip3.9 install package
$ python3
$ python3 train.py
$ python3 chat.py
52 changes: 52 additions & 0 deletions flask chatbot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Chatbot Deployment with Flask and JavaScript

In this tutorial we deploy the chatbot I created in [this](https://github.com/python-engineer/pytorch-chatbot) tutorial with Flask and JavaScript.

This gives 2 deployment options:
- Deploy within Flask app with jinja2 template
- Serve only the Flask prediction API. The used html and javascript files can be included in any Frontend application (with only a slight modification) and can run completely separate from the Flask App then.

## Initial Setup:
This repo currently contains the starter files.

Clone repo and create a virtual environment
```
$ git clone https://github.com/python-engineer/chatbot-deployment.git
$ cd chatbot-deployment
$ python3 -m venv venv
$ . venv/bin/activate
```
Install dependencies
```
$ (venv) pip install Flask torch torchvision nltk
```
Install nltk package
```
$ (venv) python
>>> import nltk
>>> nltk.download('punkt')
```
Modify `intents.json` with different intents and responses for your Chatbot

Run
```
$ (venv) python train.py
```
This will dump data.pth file. And then run
the following command to test it in the console.
```
$ (venv) python chat.py
```

Now for deployment follow my tutorial to implement `app.py` and `app.js`.

## Watch the Tutorial
[![Alt text](https://img.youtube.com/vi/a37BL0stIuM/hqdefault.jpg)](https://youtu.be/a37BL0stIuM)
[https://youtu.be/a37BL0stIuM](https://youtu.be/a37BL0stIuM)

## Note
In the video we implement the first approach using jinja2 templates within our Flask app. Only slight modifications are needed to run the frontend separately. I put the final frontend code for a standalone frontend application in the [standalone-frontend](/standalone-frontend) folder.

## Credits:
This repo was used for the frontend code:
https://github.com/hitchcliff/front-end-chatjs
Binary file added flask chatbot/__pycache__/app.cpython-39.pyc
Binary file not shown.
Binary file added flask chatbot/__pycache__/chat.cpython-310.pyc
Binary file not shown.
Binary file added flask chatbot/__pycache__/chat.cpython-39.pyc
Binary file not shown.
Binary file added flask chatbot/__pycache__/model.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Loading