Skip to content

Commit 4963158

Browse files
authored
Add files via upload
1 parent 01355bf commit 4963158

File tree

100 files changed

+2556
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2556
-0
lines changed

actions-endpoint/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM rasa/rasa-sdk:1.3.0
2+
3+
COPY requirements.txt /
4+
# To install system dependencies
5+
RUN apt-get update -qq && \
6+
apt-get clean && \
7+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
8+
mkdir -p /opt/data/api
9+
10+
# Oracle Stupidity begins here ..
11+
12+
# installing zip for unzipping oracle instant client drivers
13+
14+
## RUN apt-get update -qq && \
15+
##apt-get install -y zip && \
16+
##apt-get install libaio1
17+
18+
# Copy instant client zip to container
19+
20+
## ADD ./oracle-instantclient/ /opt/data
21+
#ADD ./install-instantclient.sh /opt/data
22+
23+
#WORKDIR /opt/data
24+
25+
# set environment varibales for Oracle home
26+
27+
## ENV ORACLE_HOME=/opt/oracle/instantclient
28+
## ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
29+
30+
## ENV OCI_HOME=/opt/oracle/instantclient
31+
## ENV OCI_LIB_DIR=/opt/oracle/instantclient
32+
## ENV OCI_INCLUDE_DIR=/opt/oracle/instantclient/sdk/include
33+
34+
# INSTALL INSTANTCLIENT AND DEPENDENCIES
35+
## RUN /opt/data/install-instantclient.sh
36+
37+
# To install packages from PyPI
38+
RUN pip install --no-cache-dir -r /requirements.txt
Binary file not shown.
Binary file not shown.

actions-endpoint/actions/actions.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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/core/customactions/#custom-actions-written-in-python
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 cx_Oracle
16+
17+
# Connect to oracle database
18+
# connection = cx_Oracle.connect("apps", "apps", "vision.ncbs.com/VIS")
19+
20+
21+
class ActionOnhandQuantity(Action):
22+
23+
def name(self) -> Text:
24+
return "action_onhand_quantity"
25+
26+
def run(self, dispatcher: CollectingDispatcher,
27+
tracker: Tracker,
28+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
29+
cursor = connection.cursor()
30+
cursor.execute("select transaction_id from mtl_material_transactions where rownum = 1")
31+
32+
for transaction_id in cursor:
33+
dispatcher.utter_message("Transaction ID is {}".format(transaction_id))
34+
35+
#dispatcher.utter_message("My first action ")
36+
37+
return []
38+
39+
40+
import requests
41+
import json
42+
43+
from pymongo import MongoClient
44+
client = MongoClient('mongodb', 27017)
45+
db = client['eva_platform']
46+
47+
48+
49+
import logging
50+
logger = logging.getLogger(__name__)
51+
52+
53+
class ActionHelloWorld(Action):
54+
55+
def name(self) -> Text:
56+
return "action_hello_world"
57+
58+
def run(self, dispatcher: CollectingDispatcher,
59+
tracker: Tracker,
60+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
61+
62+
dispatcher.utter_message("My first action")
63+
64+
return []
65+
66+
class ActionGrievanceDepartment(Action):
67+
68+
def name(self) -> Text:
69+
return "action_grievance_department"
70+
71+
def run(self, dispatcher: CollectingDispatcher,
72+
tracker: Tracker,
73+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
74+
75+
complainant_name = tracker.get_slot('complainant_name')
76+
complainant_city = tracker.get_slot('complainant_city')
77+
complainant_mobile = tracker.get_slot('complainant_mobile')
78+
complainant_email = tracker.get_slot('complainant_email')
79+
latest_intent_name = tracker.latest_message['intent'].get('name')
80+
grievance_issue = tracker.get_slot(latest_intent_name)
81+
insert_record = {
82+
"sender_id": tracker.sender_id,
83+
"complainant_name": complainant_name,
84+
"complainant_city": complainant_city,
85+
"complainant_mobile": complainant_mobile,
86+
"complainant_email": complainant_email,
87+
"ministry_department": latest_intent_name.replace('_', ' '),
88+
"grievance_issue": grievance_issue
89+
}
90+
91+
insert_result = db.grievance.insert_one(json.loads(json.dumps(insert_record)))
92+
dispatcher.utter_message("Your grievance for "+ latest_intent_name.replace('_', ' ') +" department has been logged.")
93+
return []
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
unzip /opt/data/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/oracle
3+
unzip /opt/data/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/oracle
4+
mv /opt/oracle/instantclient_12_1 /opt/oracle/instantclient
5+
ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so
6+
ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so
7+
8+
export ORACLE_HOME="/opt/oracle/instantclient"
9+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
10+
11+
export OCI_HOME="/opt/oracle/instantclient"
12+
export OCI_LIB_DIR="/opt/oracle/instantclient"
13+
export OCI_INCLUDE_DIR="/opt/oracle/instantclient/sdk/include"

actions-endpoint/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pymongo

api_gateway/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.7-slim
2+
3+
RUN apt-get update
4+
RUN apt-get install -y --no-install-recommends build-essential gcc
5+
6+
# layer caching for faster builds
7+
COPY requirements.txt /
8+
RUN pip install -r /requirements.txt
9+
10+
ADD . /api_gateway
11+
WORKDIR /api_gateway
12+
13+
ENTRYPOINT ["python"]
14+
15+
CMD ["-u","app.py"]

api_gateway/Readme.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# API gateway for eva-platform
2+
3+
## Config File options
4+
5+
6+
### Configure Port
7+
8+
PORT=8089
9+
10+
Port on which the api gateway would be deployed
11+
12+
### Configure MongoDB
13+
MONGODB_URL=mongodb://mongodb:27017
14+
MONGODB_NAME=eva_platform
15+
MongoDB Server connection settings and the defualt database name
16+
17+
### Socketio Logging
18+
19+
LOGGING=TRUE
20+
Enable / Disable socketio logging using this config option
21+
22+
### Volume Settings
23+
24+
SEED_DATA_PATH=/vol_chatbot_data/seed_data/
25+
SESSION_MODEL_PATH=/vol_chatbot_data/temp/trainer-sessions/
26+
DEPLOY_MODEL_PATH=/vol_chatbot_data/rasa/server/models/
27+
28+
Paths on the Docker volume for application
29+
30+
### Rasa Endpoint
31+
32+
RASA_URL=http://rasa:5005/model
33+
Rasa Endpoint URL
592 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)