Need to call custom action when form is requesting for sots - rasa-nlu

am using rasa 1.9.5.
I have a form that gets activated and it will ask for the slots to fill. When it is asking for a slot to fill it's calling utter_slots_name. But my requirement is, I need to call custom action instead like action_slots_name.
I need to call custom action for all slot filling questions.
NLU:
## intent:greet
- Hi
- Hello
- I need a help
- just need help
- can you server me
## intent: greeting_with_name
- Hi I am [sharath](name), I need some services
- Hi myself [sharath](name), Need some services
- Hi this is [sharath](name), need some services
## intent: are_u_bot
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?
## intent: my_name_is
- my name is [sharath](name)
- [sharath](name)
- I am [sharath](name)
- Myself [sharath](name)
Stories:
## bot challenge
* bot_challenge
- utter_iamabot
## happy path
* greet
- action_greeting
- user_details
- form{"name":"user_details"}
- form{"name":null}
- action_askfor_services
Domain:
actions:
- action_askfor_services
- action_slots_name
- user_details
- action_greeting
intents:
- greet
- bot_challenge
- my_name_is
- greeting_with_name
form:
- user_details
entities:
- name
- phoneNo
- tenentId
- language
slots:
language:
type: text
name:
type: text
phoneNo:
type: text
tenentId:
type: text
requested_slot:
type: text
responses:
utter_iamabot:
- text: I am a bot, powered by Rasa.
utter_bye:
- text: bye
session_config:
carry_over_slots_to_new_session: true
session_expiration_time: 60

Related

form is not activated in Rasa 2.0

I'm trying to integrate a form in my rasa chatbot.
In domain.yml, I have included the following:
I declared the slots:
slots:
question1:
type: text
question2:
type: text
question3:
type: text
the questions that the form is supposed to send to the user:
utter_ask_question1:
- text:" first question goes here"
utter_ask_question2:
- text:" second question goes here"
utter_ask_question3:
- text:" third question goes here"
defined the form as:
forms:
user_quiz_form:
question1:
- type: from_text
# entity: date
question2:
- type: from_text
question3:
- type: from_text
the actions section also contains :
actions:
- action_submit
- user_quiz_form
The file rules.yml contains:
- rule: Activate quiz form
steps:
- intent: quiz
- action: utter_quiz
- action: user_quiz_form
- active_loop: user_quiz_form
- rule: Submit quiz form
condition:
- active_loop: user_quiz_form
steps:
- action: user_quiz_form
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: action_submit
and actions.py is:
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, EventType
from rasa_sdk.executor import CollectingDispatcher
import webbrowser
class ValidateForm(Action):
def name(self) -> Text:
return "user_quiz_form"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
required_slots = ["question1","question2", "question3"]
for slot_name in required_slots:
if tracker.slots.get(slot_name) is None:
# The slot is not filled yet. Request the user to fill this slot next.
return [SlotSet("requested_slot", slot_name)]
return [SlotSet("requested_slot", None)]
class ActionSubmit(Action):
def name(self) -> Text:
return "action_submit"
def run(
self,
dispatcher,
tracker: Tracker,
domain: "DomainDict",
) -> List[Dict[Text, Any]]:
print("****************SUBMIT*****************")
dispatcher.utter_message(template="utter_quiz_thanks", date=tracker.slots.get("question1"))
return []
When the form is triggered, it doesn't' ask the questions to the user and returns utter_quiz_thanks with None as question1 value.
Is this the same indentation you're using in your domain.yml? If so, you're missing some indents; the slots underneath the form need to be indented (see below for an example). My guess is that you're launching the form correctly, but due to the indent issues your assistant is treating it as a form with 0 questions.
forms:
restaurant_form:
cuisine:
- type: from_entity
entity: cuisine
num_people:
- type: from_entity
entity: number

Sinhala entity classifications

UserWarning: Misaligned entity annotation in message ‘කමල්’ with intent ‘username’. Make sure the start and end values of entities in the training data match the token boundaries (e.g. entities don’t include trailing whitespaces or punctuation).Make sure the start and end values of entities in the training data match the token boundaries (e.g. entities don’t include trailing whitespaces or punctuation).
I am using Sinhala language and also I am using rasa open source .
This is my nlu part
{
"text": "කමල්",
"intent": "username",
"entities": [
{
"start": 1,
"end": 8,
"value": "කමල්",
"entity": "uname"
}
]
},
Config.yml
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en
pipeline:
- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
analyzer: "char_wb"
min_ngram: 1
max_ngram: 4
- name: DIETClassifier
epochs: 100
- name: EntitySynonymMapper
- name: ResponseSelector
epochs: 100
# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
- name: MemoizationPolicy
- name: TEDPolicy
max_history: 5
epochs: 100
- name: MappingPolicy
You're using the WhitespaceTokenizer which will split the text into tokens if there is a space between characters. It seems that the text that you provide (apologies, I do not recognize the language) does not split tokens using space. That is why the entire text is seen as a single token.
It looks like you may need to find another tokenizer for your language. I don't know which tokenizer might apply though. Feel free to contribute to the discussion here.

How to use $ref for tags between files

I am using Open API 3.0, in A.yaml
# something above
tags:
- name: user
description: Operations about user
- name: user_stuff
description: API for user stuff
- name: another_user_stuff
description: API for another user stuff
# something below
Then, in B.yaml, I want to make reference to the tags in A.yaml, for example the tag of user. Suppose in B.yaml, we have
post:
tags:
$ref: <What are the things should be here?>
summary: do somthing
description: "do something"
requestBody:
# bla bla bla
required: true
responses:
"200":
description: uccessfully
x-swagger-router-controller: B
How can I make a reference from B.yaml to A.yaml?
The tags keyword does not support $ref. All tags must be defined inline.
# B.yaml
tags:
- name: foo
description: Operations to manage Foos.
paths:
/something:
post:
tags:
- foo
- bar
That said, you don't have to define tags in the global tags section in order to use them in operations. The global tags section is used only to define extra tag metadata, such as descriptions and externalDocs, or the tag order in documentation tools.

Different yaml inputs for CWL scatter

I have a commandline tool in cwl which can take the following input:
fastq:
class: File
path: /path/to/fastq_R1.fq.gz
fastq2:
class: File
path: /path/to/fastq_R2.fq.gz
sample_name: foo
Now I want to scatter over this commandline tool and the only way I can think to do it is with scatterMethod: dotproduct and an input of something like:
fastqs:
- class: File
path: /path/to/fastq_1_R1.fq.gz
- class: File
path: /path/to/fastq_2_R1.fq.gz
fastq2s:
- class: File
path: /path/to/fastq_1_R2.fq.gz
- class: File
path: /path/to/fastq_2_R2.fq.gz
sample_names: [foo, bar]
Is there any other way for me to design the workflow and / or input file such that each input group is sectioned together? Something like
paired_end_fastqs:
- fastq:
class: File
path: /path/to/fastq_1_R1.fq.gz
fastq2:
class: File
path: /path/to/fastq_1_R2.fq.gz
sample_name: foo
- fastq:
class: File
path: /path/to/fastq_2_R1.fq.gz
fastq2:
class: File
path: /path/to/fastq_2_R2.fq.gz
sample_name: bar
You could accomplish this with a nested workflow wrapper that maps a record to each individual field, and then using that workflow to scatter over an array of records. The workflow would look something like this:
---
class: Workflow
cwlVersion: v1.0
id: workflow
inputs:
- id: paired_end_fastqs
type:
type: record
name: paired_end_fastqs
fields:
- name: fastq
type: File
- name: fastq2
type: File
- name: sample_name
type: string
outputs: []
steps:
- id: tool
in:
- id: fastq
source: paired_end_fastqs
valueFrom: "$(self.fastq)"
- id: fastq2
source: paired_end_fastqs
valueFrom: "$(self.fastq2)"
- id: sample_name
source: paired_end_fastqs
valueFrom: "$(self.sample_name)"
out: []
run: "./tool.cwl"
requirements:
- class: StepInputExpressionRequirement
Specify a workflow input of type record, with fields for each of the inputs the tool accepts, the ones you want to keep together while scattering. Connect the workflow input to each tool input, its source. Using valueFrom on the step inputs, transform the record (self is the source this context) to pass only the appropriate field to the tool.
More about valueFrom in workflow steps: https://www.commonwl.org/v1.0/Workflow.html#WorkflowStepInput
Then use this wrapper in your actual workflow and scatter over paired_end_fastqs with an array of records.

Why am I getting '`parse': (<unknown>): mapping values are not allowed in this context' in YAML file in Ruby

I am getting the above error when trying to open my Yaml file in Ruby. I have checked the YAML in this validator and it has passed http://yamllint.com/. I'm not sure what could be wrong with my YAML that would be preventing it from opening. Any ideas? Here is the YAML file. I am trying to open the file with yml = YAML::load(File.open('servers.yml'))
---
servers:
- ps-overture-d01
location: ps-overture-d01
tomcat_location: /home/tomcat/tomcat/webapps/report/
user: tomcat
menus:
- Accounts Receivable
reports:
- Accounts Receivable Aging Report
name: AccountsReceivableAgingReport
location: /public/Common/Reports/Accounts_Receivable_Reports
- Inventory
reports:
- Inventory Master List Report
name: InventoryMasterListReport
location: /public/Common/Reports/Inventory_Reports
- Inventory Totals Report
name: InventoryTotalsReport
location: /public/Common/Reports/Inventory_Reports
- Dealer Purchasing Report
name: DealerPurchasingReport
location: /public/Common/Reports/Inventory_Reports
- DOA Report
name: DOAReport
location: /public/Common/Reports/Inventory_Reports
- Stock Transfers Report
name: StockTransfersReport
location: /public/Common/Reports/Inventory_Reports
- Removed Inventory Report
name: RemovedInventoryReport
location: /public/Common/Reports/Inventory_Reports
- Inventory Order Sheet Report
name: InventoryOrderSheetReport
location: /public/Common/Reports/Inventory_Reports
- Inventory Totals GMROI Report
name: InventoryTotalsGMROIReport
location: /public/Common/Reports/Inventory_Reports
- Master Inventory GMROI Report
name: MasterInventoryGMROIReport
location: /public/Common/Reports/Inventory_Reports
- Dead Stock Report
name: DeadInventoryReport
location: /public/Common/Reports/Inventory_Reports
- Dead Stock Report Details
name: DeadInventoryReportDetails
location: /public/Common/Reports/Inventory_Reports
- Negative Quantity Report
name: NegativeInventoryQTYReport
location: /public/Common/Reports/Inventory_Reports
Your problem lies in lines which have no colon:
- ps-overture-d01
location: ps-overture-d01
What http://yamllint.com/ does is concatenate them to the next line:
? "ps-overture-d01 location"
: ps-overture-d01
Ruby's YAML library does not do that, but throws an error instead. I'm not sure you meant to have the lines in question concatenated, so you need to see how to properly adjust the YAML to give a sensible structure, perhaps add id: to each of those lines?
- id: ps-overture-d01
location: ps-overture-d01
Here is your example, with the change I suggested:
---
servers:
- id: ps-overture-d01
location: ps-overture-d01
tomcat_location: /home/tomcat/tomcat/webapps/report/
user: tomcat
menus:
- id: Accounts Receivable
reports:
- id: Accounts Receivable Aging Report
name: AccountsReceivableAgingReport
location: /public/Common/Reports/Accounts_Receivable_Reports
- id: Inventory
reports:
- id: Inventory Master List Report
name: InventoryMasterListReport
location: /public/Common/Reports/Inventory_Reports
- id: Inventory Totals Report
name: InventoryTotalsReport
location: /public/Common/Reports/Inventory_Reports
- id: Dealer Purchasing Report
name: DealerPurchasingReport
location: /public/Common/Reports/Inventory_Reports
- id: DOA Report
name: DOAReport
location: /public/Common/Reports/Inventory_Reports
- id: Stock Transfers Report
name: StockTransfersReport
location: /public/Common/Reports/Inventory_Reports
- id: Removed Inventory Report
name: RemovedInventoryReport
location: /public/Common/Reports/Inventory_Reports
- id: Inventory Order Sheet Report
name: InventoryOrderSheetReport
location: /public/Common/Reports/Inventory_Reports
- id: Inventory Totals GMROI Report
name: InventoryTotalsGMROIReport
location: /public/Common/Reports/Inventory_Reports
- id: Master Inventory GMROI Report
name: MasterInventoryGMROIReport
location: /public/Common/Reports/Inventory_Reports
- id: Dead Stock Report
name: DeadInventoryReport
location: /public/Common/Reports/Inventory_Reports
- id: Dead Stock Report Details
name: DeadInventoryReportDetails
location: /public/Common/Reports/Inventory_Reports
- id: Negative Quantity Report
name: NegativeInventoryQTYReport
location: /public/Common/Reports/Inventory_Reports

Resources