Skip to content

Commit

Permalink
moodbot updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rgstephens committed Oct 31, 2023
1 parent 0dd893a commit 20afecc
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 27 deletions.
12 changes: 9 additions & 3 deletions examples/moodbot/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Moodbot

The `moodbot` example simulates how you can use your bot on different channels.
The `moodbot` is a basic Rasa chatbot example.

## What’s inside this example?

This example contains some training data and the main files needed to build an
assistant on your local machine. The `moodbot` consists of the following files:

- **data/nlu.yml** contains training examples for the NLU model
- **data/stories.yml** contains training stories for the Core model
- **data/rules.yml** contains training rules for the Core model
- **config.yml** contains the model configuration
- **domain.yml** contains the domain of the assistant
- **credentials.yml** contains credentials for the different channels
Expand All @@ -24,7 +24,13 @@ different channels. To do so execute the following steps:
```
The model will be stored in the `/models` directory as a zipped file.

2. Run a Rasa server that connects, for example, to Facebook:
2. If using Rasa Pro, run the e2e tests to confirm the model works as expected:
```
rasa test e2e
```
The results should show no errors.

3. Run a Rasa server that connects, for example, to Facebook:
```
rasa run -m models -p 5002 --connector facebook --credentials credentials.yml
```
Expand Down
46 changes: 33 additions & 13 deletions examples/moodbot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,37 @@ assistant_id: mood_bot
language: en

pipeline:
- name: "SpacyNLP"
model: "en_core_web_md"
- name: "SpacyTokenizer"
- name: "SpacyFeaturizer"
- name: "DIETClassifier"
entity_recognition: False
epochs: 1

# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
# - name: WhitespaceTokenizer
# - name: RegexFeaturizer
# - name: LexicalSyntacticFeaturizer
# - name: CountVectorsFeaturizer
# - name: CountVectorsFeaturizer
# analyzer: char_wb
# min_ngram: 1
# max_ngram: 4
# - name: DIETClassifier
# epochs: 100
# constrain_similarities: true
# - name: EntitySynonymMapper
# - name: ResponseSelector
# epochs: 100
# constrain_similarities: true
# - name: FallbackClassifier
# threshold: 0.3
# ambiguity_threshold: 0.1
policies:
- name: TEDPolicy
max_history: 5
epochs: 1
- name: MemoizationPolicy
- name: RulePolicy
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
# - name: MemoizationPolicy
# - name: RulePolicy
# - name: UnexpecTEDIntentPolicy
# max_history: 5
# epochs: 100
# - name: TEDPolicy
# max_history: 5
# epochs: 100
# constrain_similarities: true
2 changes: 1 addition & 1 deletion examples/moodbot/data/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ nlu:
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
- am I talking to a human?
47 changes: 38 additions & 9 deletions examples/moodbot/data/rules.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
version: "3.1"
rules:
- rule: Say goodbye anytime the user says goodbye
steps:
- intent: goodbye
- action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
steps:
- intent: bot_challenge
- action: utter_iamabot
- rule: greet
steps:
- intent: greet
- action: utter_greet

- rule: Say goodbye anytime the user says goodbye
steps:
- intent: goodbye
- action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
steps:
- intent: bot_challenge
- action: utter_iamabot

- rule: mood_great
steps:
- intent: mood_great
- action: utter_happy

- rule: mood_unhappy helped
steps:
- intent: mood_unhappy
- action: utter_cheer_up
- action: utter_did_that_help
wait_for_user_input: false

- rule: mood_unhappy helped
steps:
- action: utter_did_that_help
- intent: affirm
- action: utter_happy

- rule: mood_unhappy didn't help
steps:
- action: utter_did_that_help
- intent: deny
- action: utter_goodbye
2 changes: 1 addition & 1 deletion examples/moodbot/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ responses:

session_config:
session_expiration_time: 60 # value in minutes
carry_over_slots_to_new_session: true
carry_over_slots_to_new_session: true
50 changes: 50 additions & 0 deletions examples/moodbot/tests/e2e_test_cases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
test_cases:
- test_case: greet happy
steps:
- user: 'good morning'
- utter: utter_greet
- user: 'great'
- utter: utter_happy

- test_case: greet,sad,yes
steps:
- user: 'hello there'
- utter: utter_greet
- user: 'sad'
# - action: action_set_slot
- utter: utter_cheer_up
- utter: utter_did_that_help
- user: 'yes'
- utter: utter_happy

- test_case: greet,sad,no
steps:
- user: 'hey there'
- utter: utter_greet
- user: 'sad'
- utter: utter_cheer_up
- utter: utter_did_that_help
- user: 'no'
- utter: utter_goodbye

- test_case: greet,happy,yes
steps:
- user: 'hey dude'
- utter: utter_greet
- user: 'amazing'
- utter: utter_happy

- test_case: goodbye
steps:
- user: bye
- utter: utter_goodbye

- test_case: bot_challenge
steps:
- user: are you a bot
- utter: utter_iamabot

- test_case: bot_challenge AI
steps:
- user: are you a AI
- utter: utter_iamabot
55 changes: 55 additions & 0 deletions examples/moodbot_calm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Moodbot

The `moodbot` is a basic Rasa chatbot example. This version uses the Rasa CALM
approach to using LLMs.

## What’s inside this example?

This example contains some training data and the main files needed to build an
assistant on your local machine. The `moodbot` consists of the following files:

- **data/nlu.yml** contains training examples for the NLU model
- **data/flows.yml** contains training flows
- **data/rules.yml** contains training rules for the Core model
- **config.yml** contains the model configuration
- **domain.yml** contains the domain of the assistant
- **credentials.yml** contains credentials for the different channels

## How to use this example?

Using this example you can build an actual assistant and chat with it on
different channels. To do so execute the following steps:

1. Train a Rasa model containing the Rasa NLU and Rasa Core models by running:
```
rasa train
```
The model will be stored in the `/models` directory as a zipped file.

2. If using Rasa Pro, run the e2e tests to confirm the model works as expected:
```
rasa test e2e
```
The results should show no errors.

3. Run a Rasa server that connects, for example, to Facebook:
```
rasa run -m models -p 5002 --connector facebook --credentials credentials.yml
```
If you want to connect to a different channel, replace `facebook` with the name of the
desired channel.
All available channels are listed in the `credentials.yml` file.
For more information on the different channels read our
[documentation](http://rasa.com/docs/rasa/messaging-and-voice-channels)

If you don't want to use any channel, you can chat with your bot
on the command line, using the following command:
```
rasa shell
```

For more information about the individual commands, please check out our
[documentation](http://rasa.com/docs/rasa/command-line-interface).

## Encountered any issues?
Let us know about it by posting on [Rasa Community Forum](https://forum.rasa.com)!
13 changes: 13 additions & 0 deletions examples/moodbot_calm/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
recipe: default.v1
assistant_id: mood_bot
language: en

pipeline:
- name: LLMCommandGenerator
llm:
model_name: gpt-4
# model_name: "text-davinci-003"

policies:
- name: FlowPolicy
- name: RulePolicy
33 changes: 33 additions & 0 deletions examples/moodbot_calm/credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
twilio:
account_sid: "ACbc2dxxxxxxxxxxxx19d54bdcd6e41186"
auth_token: "e231c197493a7122d475b4xxxxxxxxxx"
twilio_number: "+440123456789"

slack:
slack_token: "xoxb-xxx"
slack_channel: "#my_channel" # leave out this param to post to DMs with bot app
slack_signing_secret: "123456701ea89032asdebfe5a74518"

telegram:
access_token: "490161424:AAGlRxinBRtKGb21_rlOEMtDFZMXBl6EC0o"
verify: "your_bot"
webhook_url: "your_url.com/webhook"

mattermost:
url: "https://chat.example.com/api/v4"
token: "YOUR-TOKEN"

facebook:
verify: "rasa-bot"
secret: "3e34709d01ea89032asdebfe5a74518"
page-access-token: "EAAbHPa7H9rEBAAuFk4Q3gPKbDedQnx4djJJ1JmQ7CAqO4iJKrQcNT0wtD"

webexteams:
access_token: "ADD-YOUR-BOT-ACCESS-TOKEN"
room: "YOUR-WEBEXTEAMS-ROOM-ID"

rocketchat:
user: "your_bot_user"
password: "you_bot_pass"
server_url: "localhost:3000"
ssl: false
22 changes: 22 additions & 0 deletions examples/moodbot_calm/data/flows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
flows:
greet:
description: user has started a conversation with a greeting or asking what the bot can do
steps:
- collect: how_are_you
id: "1"
next:
- if: how_are_you == "happy"
then:
- action: utter_happy
next: END
- else:
- action: utter_cheer_up
next: "did_help" # would be nice if this line wasn't required, default go to next step
- collect: did_that_help
id: "2"
next:
- if: did_that_help
then:
action: utter_happy
- else:
action: utter_goodbye
49 changes: 49 additions & 0 deletions examples/moodbot_calm/data/nlu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.1"

nlu:
- intent: affirm
examples: |
- yes
- yup
- intent: deny
examples: |
- no
- nope
- intent: greet
examples: |
- hey
- hello
- hi
- hello there
- good morning
- good evening
- moin
- hey there
- let's go
- hey dude
- goodmorning
- goodevening
- good afternoon
- intent: goodbye
examples: |
- good afternoon
- cu
- good by
- cee you later
- good night
- bye
- goodbye
- have a nice day
- see you around
- bye bye
- see you later
- intent: bot_challenge
examples: |
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
11 changes: 11 additions & 0 deletions examples/moodbot_calm/data/rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.1"
rules:
- rule: Say goodbye anytime the user says goodbye
steps:
- intent: goodbye
- action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
steps:
- intent: bot_challenge
- action: utter_iamabot
Loading

0 comments on commit 20afecc

Please sign in to comment.