-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use (completed) tutorial bot as example - wip
- Loading branch information
Showing
6 changed files
with
152 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,19 @@ | ||
from typing import Any, Text, Dict, List | ||
from rasa_sdk import Action, Tracker | ||
from rasa_sdk.executor import CollectingDispatcher | ||
from rasa_sdk.events import SlotSet | ||
|
||
class ActionSufficientFunds(Action): | ||
def name(self) -> Text: | ||
return "action_sufficient_funds" | ||
|
||
def run(self, dispatcher: CollectingDispatcher, | ||
tracker: Tracker, | ||
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | ||
balance = 1000 # hard-coded for tutorial purposes | ||
# a real api call would look something like | ||
# result = requests.get("https://example.com/api/balance") | ||
# balance = result.json()["balance"] | ||
transfer_amount = tracker.get_slot("amount") | ||
has_sufficient_funds = transfer_amount <= balance | ||
return [SlotSet("has_sufficient_funds", has_sufficient_funds)] |
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 @@ | ||
recipe: default.v1 | ||
language: en | ||
pipeline: | ||
- name: LLMCommandGenerator | ||
llm: | ||
model_name: gpt-4 | ||
|
||
policies: | ||
- name: rasa.core.policies.flow_policy.FlowPolicy | ||
# - name: rasa_plus.ml.DocsearchPolicy | ||
# - name: RulePolicy | ||
|
||
assistant_id: 20230405-114328-tranquil-mustard |
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,28 @@ | ||
flows: | ||
transfer_money: | ||
description: This flow lets users send money to friends and family. | ||
steps: | ||
- id: "ask_recipient" | ||
collect_information: recipient | ||
next: "ask_amount" | ||
- id: "ask_amount" | ||
collect_information: amount | ||
next: "check_funds" | ||
- id: "check_funds" | ||
action: action_sufficient_funds | ||
next: | ||
- if: has_sufficient_funds | ||
then: "confirm_transfer" | ||
- else: "insufficient_funds" | ||
- id: "insufficient_funds" | ||
action: utter_insufficient_funds | ||
- id: "confirm_transfer" | ||
collect_information: final_confirmation | ||
next: | ||
- if: final_confirmation | ||
then: "transfer_successful" | ||
- else: "transfer_cancelled" | ||
- id: "transfer_cancelled" | ||
action: utter_transfer_cancelled | ||
- id: "transfer_successful" | ||
action: utter_transfer_complete |
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,43 @@ | ||
version: "3.1" | ||
|
||
slots: | ||
recipient: | ||
type: text | ||
mappings: | ||
- type: custom | ||
amount: | ||
type: float | ||
mappings: | ||
- type: custom | ||
final_confirmation: | ||
type: bool | ||
mappings: | ||
- type: custom | ||
has_sufficient_funds: | ||
type: bool | ||
mappings: | ||
- type: custom | ||
|
||
responses: | ||
utter_ask_recipient: | ||
- text: "Who would you like to send money to?" | ||
|
||
utter_ask_amount: | ||
- text: "How much money would you like to send?" | ||
|
||
utter_transfer_complete: | ||
- text: "All done. ${amount} has been sent to {recipient}." | ||
|
||
utter_ask_final_confirmation: | ||
- text: "Please confirm: you want to transfer ${amount} to {recipient}?" | ||
|
||
utter_transfer_cancelled: | ||
- text: "Your transfer has been cancelled." | ||
|
||
utter_insufficient_funds: | ||
- text: "You do not have enough funds to make this transaction." | ||
|
||
|
||
|
||
actions: | ||
- action_sufficient_funds |
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,7 @@ | ||
test_cases: | ||
- test_case: user corrects recipient in the next message | ||
steps: | ||
- user: I want to send 400 dollars to James | ||
- utter: utter_ask_final_confirmation | ||
- user: yes | ||
- utter: utter_transfer_complete |
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,42 @@ | ||
# This file contains the different endpoints your bot can use. | ||
|
||
# Server where the models are pulled from. | ||
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server | ||
|
||
#models: | ||
# url: http://my-server.com/models/default_core@latest | ||
# wait_time_between_pulls: 10 # [optional](default: 100) | ||
|
||
# Server which runs your custom actions. | ||
# https://rasa.com/docs/rasa/custom-actions | ||
|
||
action_endpoint: | ||
url: "http://localhost:5055/webhook" | ||
|
||
# Tracker store which is used to store the conversations. | ||
# By default the conversations are stored in memory. | ||
# https://rasa.com/docs/rasa/tracker-stores | ||
|
||
#tracker_store: | ||
# type: redis | ||
# url: <host of the redis instance, e.g. localhost> | ||
# port: <port of your redis instance, usually 6379> | ||
# db: <number of your database within redis, e.g. 0> | ||
# password: <password used for authentication> | ||
# use_ssl: <whether or not the communication is encrypted, default false> | ||
|
||
#tracker_store: | ||
# type: mongod | ||
# url: <url to your mongo instance, e.g. mongodb://localhost:27017> | ||
# db: <name of the db within your mongo instance, e.g. rasa> | ||
# username: <username used for authentication> | ||
# password: <password used for authentication> | ||
|
||
# Event broker which all conversation events should be streamed to. | ||
# https://rasa.com/docs/rasa/event-brokers | ||
|
||
#event_broker: | ||
# url: localhost | ||
# username: username | ||
# password: password | ||
# queue: queue |