Spaces:
Runtime error
Runtime error
Commit
·
265f62d
1
Parent(s):
a858c2b
Initial commit (#1)
Browse files- Initial commit (d990211a82dcffdcd4963b0ac81ae402a7a0bcb0)
Co-authored-by: Anand <[email protected]>
- Dockerfile +46 -0
- actions/__init__.py +0 -0
- actions/__pycache__/__init__.cpython-310.pyc +0 -0
- actions/__pycache__/actions.cpython-310.pyc +0 -0
- actions/actions.py +64 -0
- endpoints.yml +42 -0
- requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1
|
| 2 |
+
|
| 3 |
+
# Comments are provided throughout this file to help you get started.
|
| 4 |
+
# If you need more help, visit the Dockerfile reference guide at
|
| 5 |
+
# https://docs.docker.com/engine/reference/builder/
|
| 6 |
+
|
| 7 |
+
ARG PYTHON_VERSION=3.8
|
| 8 |
+
FROM python:${PYTHON_VERSION}-slim as base
|
| 9 |
+
|
| 10 |
+
# Copy the requirements file into the container.
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
|
| 13 |
+
# Install the dependencies from the requirements file.
|
| 14 |
+
RUN python -m pip install --no-cache-dir -r requirements.txt
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Prevents Python from writing pyc files.
|
| 18 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 19 |
+
|
| 20 |
+
# Keeps Python from buffering stdout and stderr to avoid situations where
|
| 21 |
+
# the application crashes without emitting any logs due to buffering.
|
| 22 |
+
ENV PYTHONUNBUFFERED=1
|
| 23 |
+
|
| 24 |
+
WORKDIR /app
|
| 25 |
+
# Copy the source code into the container.
|
| 26 |
+
COPY . .
|
| 27 |
+
|
| 28 |
+
# Create a non-privileged user that the app will run under.
|
| 29 |
+
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
| 30 |
+
# Switch to the non-privileged user to run the application.
|
| 31 |
+
USER 1001
|
| 32 |
+
|
| 33 |
+
# set entrypoint for interactive shells
|
| 34 |
+
ENTRYPOINT [ "rasa" ]
|
| 35 |
+
|
| 36 |
+
# Expose the port that the application listens on.
|
| 37 |
+
EXPOSE 7860
|
| 38 |
+
|
| 39 |
+
# Run the application.
|
| 40 |
+
#CMD ["run","--enable-api","--port","7860"]
|
| 41 |
+
|
| 42 |
+
# List of models: Arpit-v1.1.tar.gz, central+careersv1.0.tar.gz,Maisam+Arpit+anand+pankaj-bot-v1.0.tar.gz
|
| 43 |
+
|
| 44 |
+
# To specify model path
|
| 45 |
+
CMD ["run","actions","--port","7860"]
|
| 46 |
+
|
actions/__init__.py
ADDED
|
File without changes
|
actions/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (181 Bytes). View file
|
|
|
actions/__pycache__/actions.cpython-310.pyc
ADDED
|
Binary file (180 Bytes). View file
|
|
|
actions/actions.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
from typing import Any, Text, Dict, List
|
| 8 |
+
from rasa_sdk import Action, Tracker
|
| 9 |
+
from rasa_sdk.events import SlotSet, FollowupAction
|
| 10 |
+
from rasa_sdk.executor import CollectingDispatcher
|
| 11 |
+
import random
|
| 12 |
+
|
| 13 |
+
class GeneralHelp(Action):
|
| 14 |
+
def name(self) -> Text:
|
| 15 |
+
return "action_general_help"
|
| 16 |
+
|
| 17 |
+
def run(self, dispatcher: CollectingDispatcher,
|
| 18 |
+
tracker: Tracker,
|
| 19 |
+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
| 20 |
+
|
| 21 |
+
user_role = tracker.slots.get("user_role", None)
|
| 22 |
+
|
| 23 |
+
if user_role is None:
|
| 24 |
+
dispatcher.utter_message(text="Sure! Are you a developer or a client representing an organization?")
|
| 25 |
+
else:
|
| 26 |
+
return [FollowupAction("action_help_with_role")]
|
| 27 |
+
|
| 28 |
+
# Modified from @Rohit Garg's code https://github.com/rohitkg83/Omdena/blob/master/actions/actions.py
|
| 29 |
+
class ActionHelpWithRole(Action):
|
| 30 |
+
|
| 31 |
+
def name(self) -> Text:
|
| 32 |
+
return "action_help_with_role"
|
| 33 |
+
|
| 34 |
+
def run(self,
|
| 35 |
+
dispatcher: CollectingDispatcher,
|
| 36 |
+
tracker: Tracker,
|
| 37 |
+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
| 38 |
+
|
| 39 |
+
# Get the value of the first_occurrence_user_type slot
|
| 40 |
+
current_user_type = tracker.slots.get("user_role", None)
|
| 41 |
+
|
| 42 |
+
if current_user_type == 'developer':
|
| 43 |
+
msg = "Thanks a lot for providing the details. You can join one of our local chapter and collaborate on " \
|
| 44 |
+
"various projects and challenges to Develop Your Skills, Get Recognized, and Make an Impact. Please " \
|
| 45 |
+
"visit https://omdena.com/community for more details. Do you have any other questions? "
|
| 46 |
+
|
| 47 |
+
elif current_user_type == 'client':
|
| 48 |
+
msg = "Thanks a lot for providing the details. With us you can Innovate, Deploy and Scale " \
|
| 49 |
+
"AI Solutions in Record Time. For more details please visit https://omdena.com/offerings. Do you have any other questions? "
|
| 50 |
+
else:
|
| 51 |
+
msg = "Please enter either developer or client"
|
| 52 |
+
|
| 53 |
+
dispatcher.utter_message(text=msg)
|
| 54 |
+
|
| 55 |
+
class ResetSlotsAction(Action):
|
| 56 |
+
def name(self) -> Text:
|
| 57 |
+
return "action_reset_slots"
|
| 58 |
+
|
| 59 |
+
def run(self, dispatcher: CollectingDispatcher,
|
| 60 |
+
tracker: Tracker,
|
| 61 |
+
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
|
| 62 |
+
slots_to_reset = ["user_role"] # Add the names of the slots you want to reset
|
| 63 |
+
events = [SlotSet(slot, None) for slot in slots_to_reset]
|
| 64 |
+
return events
|
endpoints.yml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:7860/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: <host of the redis instance, e.g. localhost>
|
| 23 |
+
# port: <port of your redis instance, usually 6379>
|
| 24 |
+
# db: <number of your database within redis, e.g. 0>
|
| 25 |
+
# password: <password used for authentication>
|
| 26 |
+
# use_ssl: <whether or not the communication is encrypted, default false>
|
| 27 |
+
|
| 28 |
+
#tracker_store:
|
| 29 |
+
# type: mongod
|
| 30 |
+
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
|
| 31 |
+
# db: <name of the db within your mongo instance, e.g. rasa>
|
| 32 |
+
# username: <username used for authentication>
|
| 33 |
+
# password: <password used for authentication>
|
| 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
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
rasa
|