-
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
1 parent
01355bf
commit 4963158
Showing
100 changed files
with
2,556 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM rasa/rasa-sdk:1.3.0 | ||
|
||
COPY requirements.txt / | ||
# To install system dependencies | ||
RUN apt-get update -qq && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ | ||
mkdir -p /opt/data/api | ||
|
||
# Oracle Stupidity begins here .. | ||
|
||
# installing zip for unzipping oracle instant client drivers | ||
|
||
## RUN apt-get update -qq && \ | ||
##apt-get install -y zip && \ | ||
##apt-get install libaio1 | ||
|
||
# Copy instant client zip to container | ||
|
||
## ADD ./oracle-instantclient/ /opt/data | ||
#ADD ./install-instantclient.sh /opt/data | ||
|
||
#WORKDIR /opt/data | ||
|
||
# set environment varibales for Oracle home | ||
|
||
## ENV ORACLE_HOME=/opt/oracle/instantclient | ||
## ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME | ||
|
||
## ENV OCI_HOME=/opt/oracle/instantclient | ||
## ENV OCI_LIB_DIR=/opt/oracle/instantclient | ||
## ENV OCI_INCLUDE_DIR=/opt/oracle/instantclient/sdk/include | ||
|
||
# INSTALL INSTANTCLIENT AND DEPENDENCIES | ||
## RUN /opt/data/install-instantclient.sh | ||
|
||
# To install packages from PyPI | ||
RUN pip install --no-cache-dir -r /requirements.txt |
Binary file not shown.
Binary file not shown.
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,93 @@ | ||
# This files contains your custom actions which can be used to run | ||
# custom Python code. | ||
# | ||
# See this guide on how to implement these action: | ||
# https://rasa.com/docs/core/customactions/#custom-actions-written-in-python | ||
|
||
|
||
# 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 | ||
|
||
# import cx_Oracle | ||
|
||
# Connect to oracle database | ||
# connection = cx_Oracle.connect("apps", "apps", "vision.ncbs.com/VIS") | ||
|
||
|
||
class ActionOnhandQuantity(Action): | ||
|
||
def name(self) -> Text: | ||
return "action_onhand_quantity" | ||
|
||
def run(self, dispatcher: CollectingDispatcher, | ||
tracker: Tracker, | ||
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | ||
cursor = connection.cursor() | ||
cursor.execute("select transaction_id from mtl_material_transactions where rownum = 1") | ||
|
||
for transaction_id in cursor: | ||
dispatcher.utter_message("Transaction ID is {}".format(transaction_id)) | ||
|
||
#dispatcher.utter_message("My first action ") | ||
|
||
return [] | ||
|
||
|
||
import requests | ||
import json | ||
|
||
from pymongo import MongoClient | ||
client = MongoClient('mongodb', 27017) | ||
db = client['eva_platform'] | ||
|
||
|
||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
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("My first action") | ||
|
||
return [] | ||
|
||
class ActionGrievanceDepartment(Action): | ||
|
||
def name(self) -> Text: | ||
return "action_grievance_department" | ||
|
||
def run(self, dispatcher: CollectingDispatcher, | ||
tracker: Tracker, | ||
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | ||
|
||
complainant_name = tracker.get_slot('complainant_name') | ||
complainant_city = tracker.get_slot('complainant_city') | ||
complainant_mobile = tracker.get_slot('complainant_mobile') | ||
complainant_email = tracker.get_slot('complainant_email') | ||
latest_intent_name = tracker.latest_message['intent'].get('name') | ||
grievance_issue = tracker.get_slot(latest_intent_name) | ||
insert_record = { | ||
"sender_id": tracker.sender_id, | ||
"complainant_name": complainant_name, | ||
"complainant_city": complainant_city, | ||
"complainant_mobile": complainant_mobile, | ||
"complainant_email": complainant_email, | ||
"ministry_department": latest_intent_name.replace('_', ' '), | ||
"grievance_issue": grievance_issue | ||
} | ||
|
||
insert_result = db.grievance.insert_one(json.loads(json.dumps(insert_record))) | ||
dispatcher.utter_message("Your grievance for "+ latest_intent_name.replace('_', ' ') +" department has been logged.") | ||
return [] |
13 changes: 13 additions & 0 deletions
13
actions-endpoint/oracle-instantclient/install-instantclient.sh
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,13 @@ | ||
#!/usr/bin/env bash | ||
unzip /opt/data/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/oracle | ||
unzip /opt/data/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/oracle | ||
mv /opt/oracle/instantclient_12_1 /opt/oracle/instantclient | ||
ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so | ||
ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so | ||
|
||
export ORACLE_HOME="/opt/oracle/instantclient" | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME | ||
|
||
export OCI_HOME="/opt/oracle/instantclient" | ||
export OCI_LIB_DIR="/opt/oracle/instantclient" | ||
export OCI_INCLUDE_DIR="/opt/oracle/instantclient/sdk/include" |
Binary file added
BIN
+652 KB
actions-endpoint/oracle-instantclient/instantclient-sdk-linux.x64-12.1.0.2.0.zip
Binary file not shown.
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 @@ | ||
pymongo |
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,15 @@ | ||
FROM python:3.7-slim | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y --no-install-recommends build-essential gcc | ||
|
||
# layer caching for faster builds | ||
COPY requirements.txt / | ||
RUN pip install -r /requirements.txt | ||
|
||
ADD . /api_gateway | ||
WORKDIR /api_gateway | ||
|
||
ENTRYPOINT ["python"] | ||
|
||
CMD ["-u","app.py"] |
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,33 @@ | ||
# API gateway for eva-platform | ||
|
||
## Config File options | ||
|
||
|
||
### Configure Port | ||
|
||
PORT=8089 | ||
|
||
Port on which the api gateway would be deployed | ||
|
||
### Configure MongoDB | ||
MONGODB_URL=mongodb://mongodb:27017 | ||
MONGODB_NAME=eva_platform | ||
MongoDB Server connection settings and the defualt database name | ||
|
||
### Socketio Logging | ||
|
||
LOGGING=TRUE | ||
Enable / Disable socketio logging using this config option | ||
|
||
### Volume Settings | ||
|
||
SEED_DATA_PATH=/vol_chatbot_data/seed_data/ | ||
SESSION_MODEL_PATH=/vol_chatbot_data/temp/trainer-sessions/ | ||
DEPLOY_MODEL_PATH=/vol_chatbot_data/rasa/server/models/ | ||
|
||
Paths on the Docker volume for application | ||
|
||
### Rasa Endpoint | ||
|
||
RASA_URL=http://rasa:5005/model | ||
Rasa Endpoint URL |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,56 @@ | ||
from aiohttp import web | ||
import socketio | ||
from config import CONFIG | ||
import aiohttp_cors | ||
import json | ||
|
||
if CONFIG.get('api_gateway', 'LOGGING') == 'TRUE': | ||
print("--------------------Starting Socketio Connection in Debug Mode --------------------------") | ||
sio = socketio.AsyncServer(async_mode='aiohttp', logger=True, engineio_logger=True, ping_timeout=60000000, ping_interval=6000000 ) | ||
else: | ||
sio = socketio.AsyncServer(async_mode='aiohttp', logger=False, engineio_logger=False, ping_timeout=60000000, ping_interval= 6000000) | ||
|
||
app = web.Application() | ||
sio.attach(app) | ||
cors = aiohttp_cors.setup(app) | ||
|
||
async def index(request): | ||
print(request) | ||
with open('index.html') as f: | ||
return web.Response(text=f.read(), content_type='text/html') | ||
|
||
# Imports for Endpoints | ||
|
||
import endpoints | ||
import rooms_endpoints | ||
|
||
try_chat_now = endpoints.TryNow() | ||
|
||
async def trynow(request): | ||
return await try_chat_now.on_trynow(request) | ||
|
||
async def chatnow(request): | ||
return await try_chat_now.on_chatNow(request) | ||
|
||
app.router.add_get('/', index) | ||
cors.add(app.router.add_route("POST", "/tryNow", trynow), { | ||
"*": aiohttp_cors.ResourceOptions( | ||
allow_credentials=True, | ||
expose_headers=("X-Custom-Server-Header",), | ||
allow_headers=("X-Requested-With", "Content-Type"), | ||
max_age=3600, | ||
) | ||
}) | ||
cors.add(app.router.add_route("POST", "/chatNow", chatnow), { | ||
"*": aiohttp_cors.ResourceOptions( | ||
allow_credentials=True, | ||
expose_headers=("X-Custom-Server-Header",), | ||
allow_headers=("X-Requested-With", "Content-Type"), | ||
max_age=3600, | ||
) | ||
}) | ||
|
||
# We kick off our server | ||
if __name__ == '__main__': | ||
sio.attach(app) | ||
web.run_app(app, port=CONFIG.get('api_gateway', 'PORT')) |
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,21 @@ | ||
[api_gateway] | ||
PORT=8089 | ||
|
||
# Change Mongodb connection form mongodb to localhost for local testing | ||
|
||
MONGODB_URL=mongodb://mongodb:27017 | ||
#MONGODB_URL=mongodb://localhost:27017 | ||
MONGODB_NAME=eva_platform | ||
LOGGING=TRUE | ||
|
||
# Change below paths when local testing. During compose volume is mounted | ||
|
||
;SEED_DATA_PATH=../vol_chatbot_data/seed_data/ | ||
;SESSION_MODEL_PATH=../vol_chatbot_data/temp/trainer-sessions/ | ||
;DEPLOY_MODEL_PATH=../vol_chatbot_data/rasa/server/models/ | ||
;RASA_URL=http://localhost:5005/model | ||
|
||
SEED_DATA_PATH=/vol_chatbot_data/seed_data/ | ||
SESSION_MODEL_PATH=/vol_chatbot_data/temp/trainer-sessions/ | ||
DEPLOY_MODEL_PATH=/vol_chatbot_data/rasa/server/models/ | ||
RASA_URL=http://rasa:5005/model |
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,20 @@ | ||
from configparser import ConfigParser | ||
import os | ||
|
||
DEFAULT_CONFIG_FILE = 'config.ini' | ||
|
||
|
||
def get_config_file(): | ||
return os.environ.get('CONFIG_FILE', DEFAULT_CONFIG_FILE) | ||
|
||
|
||
CONFIG_FILE = get_config_file() | ||
|
||
|
||
def create_config(config_file=None): | ||
parser = ConfigParser() | ||
parser.read(config_file or CONFIG_FILE) | ||
return parser | ||
|
||
|
||
CONFIG = create_config() |
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,11 @@ | ||
from motor.motor_asyncio import AsyncIOMotorClient | ||
from config import CONFIG | ||
|
||
|
||
# noinspection PyMethodMayBeStatic | ||
class ConDatabase: | ||
|
||
def connect(): | ||
client = AsyncIOMotorClient(CONFIG.get('api_gateway', 'MONGODB_URL')) | ||
db = client[CONFIG.get('api_gateway', 'MONGODB_NAME')] | ||
return db |
Oops, something went wrong.