├── .gitignore ├── CONTRIBUTE.md ├── Dockerfile-webchat ├── LICENSE ├── README.md ├── __pycache__ └── actions.cpython-310.pyc ├── actions.py ├── config.yml ├── credentials.yml ├── data └── flows.yml ├── docker-compose.yaml ├── domain.yml ├── endpoints.yml ├── index.html └── models ├── 20240822-191218-intricate-deque.tar.gz └── 20240822-191258-ancient-transfer.tar.gz /.gitignore: -------------------------------------------------------------------------------- 1 | .rasa* 2 | .config 3 | .keras/* 4 | -------------------------------------------------------------------------------- /CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | # Contributing to Docker ML FAQ Rasa 2 | 3 | Thank you for your interest in contributing to the **Docker ML FAQ Rasa** project! We welcome any kind of contributions, including bug reports, new feature suggestions, documentation improvements, and code contributions. 4 | 5 | ## Table of Contents 6 | - [How to Contribute](#how-to-contribute) 7 | - [Reporting Bugs](#reporting-bugs) 8 | - [Suggesting Features](#suggesting-features) 9 | - [Submitting Changes](#submitting-changes) 10 | - [Development Workflow](#development-workflow) 11 | - [Style Guide](#style-guide) 12 | - [License](#license) 13 | 14 | 15 | ## How to Contribute 16 | 17 | ### Reporting Bugs 18 | 19 | If you find a bug, please report it by [opening an issue](https://github.com/harsh4870/docker-ml-faq-rassa/issues). Make sure your issue includes: 20 | - A clear and descriptive title. 21 | - Steps to reproduce the problem. 22 | - Expected and actual behavior. 23 | - Any logs, screenshots, or relevant code snippets. 24 | - Your development environment (OS, Python version, etc.). 25 | 26 | ### Suggesting Features 27 | 28 | We are open to feature suggestions! If you have an idea to improve this project: 29 | 1. Check the [issue tracker](https://github.com/harsh4870/docker-ml-faq-rassa/issues) to ensure someone hasn’t already requested it. 30 | 2. If it’s a new suggestion, [open a feature request](https://github.com/harsh4870/docker-ml-faq-rassa/issues/new?template=feature_request.md) detailing the benefits and use cases of the proposed feature. 31 | 32 | ### Submitting Changes 33 | 34 | To submit changes (code, documentation, etc.): 35 | 1. **Fork** this repository. 36 | 2. **Create a branch** for your changes: `git checkout -b feature-branch`. 37 | 3. **Commit your changes**: `git commit -m 'Description of the changes'`. 38 | 4. **Push to your branch**: `git push origin feature-branch`. 39 | 5. **Submit a Pull Request (PR)**: Go to the original repository, and submit your PR. Include a detailed explanation of your changes. 40 | 41 | > **Note**: If your changes are related to fixing an issue, reference the issue number in your PR description. 42 | 43 | ## Development Workflow 44 | 45 | 1. **Set up the project**: 46 | - Clone the repository: `git clone https://github.com/harsh4870/docker-ml-faq-rassa.git` 47 | - Follow the instructions in the [README.md](README.md) to set up your development environment. 48 | 49 | 2. **Testing**: 50 | - Before submitting a PR, ensure all tests pass. 51 | - If you're adding new functionality, write the necessary tests. 52 | 53 | 3. **Pre-commit checks**: 54 | - Lint your code using `flake8` for Python code. 55 | - Ensure your code follows the project’s [Style Guide](#style-guide). 56 | 57 | ## Style Guide 58 | 59 | - Follow the [PEP 8](https://pep8.org/) guidelines for Python code. 60 | - Write clear and descriptive commit messages. 61 | - Keep functions and methods concise and focused on a single task. 62 | - When writing documentation, use [Markdown](https://www.markdownguide.org/) format and be clear and concise. 63 | 64 | ## License 65 | 66 | By contributing, you agree that your contributions will be licensed under the same license as this project—[MIT License](LICENSE). 67 | -------------------------------------------------------------------------------- /Dockerfile-webchat: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY index.html /usr/share/nginx/html 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Harsh Manvar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-ml-faq-rassa 2 | ML FAQ model demo with rasa & Docker 3 | 4 | ![Untitled-2022-12-29-1222](https://github.com/harsh4870/docker-ml-faq-rassa/assets/15871000/e2d4064c-3ef9-4640-a488-60c7d48a1608) 5 | 6 | #### Init Rasa 7 | 8 | ``` 9 | docker run -v ./:/app \ 10 | -e RASA_PRO_LICENSE= "" \ #Add value 11 | -e OPENAI_API_KEY= "" \ #Add value 12 | -e RASA_DUCKLING_HTTP_URL=localhost:8000 \ 13 | europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.9.3 \ 14 | init --template tutorial --no-prompt 15 | ``` 16 | 17 | #### Train Model 18 | 19 | ``` 20 | docker run -v ./:/app \ 21 | -e RASA_PRO_LICENSE= "" \ #Add value 22 | -e OPENAI_API_KEY= "" \ #Add value 23 | -e RASA_DUCKLING_HTTP_URL=localhost:8000 \ 24 | europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.9.3 \ 25 | train 26 | ``` 27 | 28 | #### Run model 29 | 30 | ``` 31 | docker run -d -p 5005:5005 -v ./:/app \ 32 | -e RASA_PRO_LICENSE= "" \ #Add value 33 | -e OPENAI_API_KEY= "" \ #Add value 34 | -e RASA_DUCKLING_HTTP_URL=localhost:8000 \ 35 | europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.9.3 \ 36 | run -m models --enable-api --cors "*" --debug 37 | ``` 38 | 39 | ## WebChat 40 | 41 | ``` 42 | docker run -p 5005:5005 -v $(pwd):/app :3.5.2 run -m models --enable-api --cors "*" --debug 43 | ``` 44 | 45 | #### Build the WebChat UI frontend 46 | 47 | ``` 48 | docker build -t rasa-webchat:v1 -f Dockerfile-webchat . 49 | ``` 50 | 51 | #### Run 52 | 53 | ``` 54 | docker run -p 8080:80 rasa-webchat:v1 55 | ``` 56 | 57 | Open `localhost:8080` in Browser 58 | 59 | Screenshot 2023-06-20 at 1 12 45 PM 60 | 61 | 62 | -------------------------------------------------------------------------------- /__pycache__/actions.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/docker-ml-faq-rasa/ef833fb02a2a2d918a159aee6f03d487a381a612/__pycache__/actions.cpython-310.pyc -------------------------------------------------------------------------------- /actions.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Text, Dict, List 2 | from rasa_sdk import Action, Tracker 3 | from rasa_sdk.executor import CollectingDispatcher 4 | from rasa_sdk.events import SlotSet 5 | 6 | 7 | class ActionCheckSufficientFunds(Action): 8 | def name(self) -> Text: 9 | return "action_check_sufficient_funds" 10 | 11 | def run( 12 | self, 13 | dispatcher: CollectingDispatcher, 14 | tracker: Tracker, 15 | domain: Dict[Text, Any], 16 | ) -> List[Dict[Text, Any]]: 17 | # hard-coded balance for tutorial purposes. in production this 18 | # would be retrieved from a database or an API 19 | balance = 1000 20 | transfer_amount = tracker.get_slot("amount") 21 | has_sufficient_funds = transfer_amount <= balance 22 | return [SlotSet("has_sufficient_funds", has_sufficient_funds)] 23 | -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | recipe: default.v1 2 | language: en 3 | pipeline: 4 | - name: SingleStepLLMCommandGenerator 5 | llm: 6 | model_name: gpt-4 7 | 8 | policies: 9 | - name: FlowPolicy 10 | # - name: EnterpriseSearchPolicy 11 | # - name: RulePolicy 12 | assistant_id: 20240822-191248-fixed-watt 13 | -------------------------------------------------------------------------------- /credentials.yml: -------------------------------------------------------------------------------- 1 | # This file contains the credentials for the voice & chat platforms 2 | # which your bot is using. 3 | # https://rasa.com/docs/rasa-pro/connectors/messaging-and-voice-channels/ 4 | 5 | rest: 6 | # # you don't need to provide anything here - this channel doesn't 7 | # # require any credentials 8 | 9 | 10 | #facebook: 11 | # verify: "" 12 | # secret: "" 13 | # page-access-token: "" 14 | 15 | #slack: 16 | # slack_token: "" 17 | # slack_channel: "" 18 | # slack_signing_secret: "" 19 | 20 | socketio: 21 | user_message_evt: user_uttered 22 | bot_message_evt: bot_uttered 23 | session_persistence: false 24 | 25 | #mattermost: 26 | # url: "https:///api/v4" 27 | # token: "" 28 | # webhook_url: "" 29 | 30 | # This entry is needed if you are using Rasa Enterprise. The entry represents credentials 31 | # for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers. 32 | rasa: 33 | url: "http://localhost:5002/api" 34 | -------------------------------------------------------------------------------- /data/flows.yml: -------------------------------------------------------------------------------- 1 | flows: 2 | transfer_money: 3 | description: This flow lets users send money to friends and family. 4 | steps: 5 | - collect: recipient 6 | - collect: amount 7 | description: the number of US dollars to send 8 | - action: utter_transfer_complete 9 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.0' 2 | services: 3 | rasa: 4 | #image: rasa/rasa:3.6.0-full 5 | image: europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.9.3 6 | environment: 7 | RASA_PRO_LICENSE: "" #Replace with original value 8 | OPENAI_API_KEY: "" #Replace with original value 9 | RASA_DUCKLING_HTTP_URL: localhost:8000 10 | ports: 11 | - 5005:5005 12 | volumes: 13 | - ./:/app 14 | command: run -m models --enable-api --cors "*" --debug 15 | webchat: 16 | build: 17 | context: . 18 | dockerfile: Dockerfile-webchat 19 | ports: 20 | - 8080:80 21 | -------------------------------------------------------------------------------- /domain.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | slots: 4 | recipient: 5 | type: text 6 | mappings: 7 | - type: from_llm 8 | amount: 9 | type: float 10 | mappings: 11 | - type: from_llm 12 | 13 | responses: 14 | utter_ask_recipient: 15 | - text: "Who would you like to send money to?" 16 | 17 | utter_ask_amount: 18 | - text: "How much money would you like to send?" 19 | 20 | utter_transfer_complete: 21 | - text: "All done. {amount} has been sent to {recipient}." 22 | -------------------------------------------------------------------------------- /endpoints.yml: -------------------------------------------------------------------------------- 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-pro/production/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-pro/concepts/custom-actions 12 | 13 | action_endpoint: 14 | url: "http://localhost:5055/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-pro/production/tracker-stores 19 | 20 | #tracker_store: 21 | # type: redis 22 | # url: 23 | # port: 24 | # db: 25 | # password: 26 | # use_ssl: 27 | 28 | #tracker_store: 29 | # type: mongod 30 | # url: 31 | # db: 32 | # username: 33 | # password: 34 | 35 | # Event broker which all conversation events should be streamed to. 36 | # https://rasa.com/docs/rasa-pro/production/event-brokers 37 | 38 | #event_broker: 39 | # url: localhost 40 | # username: username 41 | # password: password 42 | # queue: queue 43 | 44 | #nlg: 45 | # type: rephrase 46 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Custom Chatbot 5 | 6 | 7 | 8 |
9 | 10 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /models/20240822-191218-intricate-deque.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/docker-ml-faq-rasa/ef833fb02a2a2d918a159aee6f03d487a381a612/models/20240822-191218-intricate-deque.tar.gz -------------------------------------------------------------------------------- /models/20240822-191258-ancient-transfer.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/docker-ml-faq-rasa/ef833fb02a2a2d918a159aee6f03d487a381a612/models/20240822-191258-ancient-transfer.tar.gz --------------------------------------------------------------------------------