Skip to content

Commit

Permalink
Merge branch 'dm2' into ENG-586-langchain-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma committed Oct 23, 2023
2 parents 9fabde3 + 9ae3440 commit 7daa8d5
Show file tree
Hide file tree
Showing 12 changed files with 903 additions and 204 deletions.
8 changes: 0 additions & 8 deletions examples/money_transfer/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@ 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:
Expand Down
1 change: 1 addition & 0 deletions rasa/cli/project_templates/tutorial/data/flows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ flows:
steps:
- collect: recipient
- collect: amount
description: the number of US dollars to send
- action: utter_transfer_complete
4 changes: 0 additions & 4 deletions rasa/cli/project_templates/tutorial/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ version: "3.1"
slots:
recipient:
type: text
mappings:
- type: custom
amount:
type: float
mappings:
- type: custom

responses:
utter_ask_recipient:
Expand Down
40 changes: 32 additions & 8 deletions rasa/core/policies/flow_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,40 @@ def _reset_scoped_slots(
self, current_flow: Flow, tracker: DialogueStateTracker
) -> List[Event]:
"""Reset all scoped slots."""

def _reset_slot(
slot_name: Text, dialogue_tracker: DialogueStateTracker
) -> None:
slot = dialogue_tracker.slots.get(slot_name, None)
initial_value = slot.initial_value if slot else None
events.append(SlotSet(slot_name, initial_value))

events: List[Event] = []

not_resettable_slot_names = set()

for step in current_flow.steps:
# reset all slots scoped to the flow
if (
isinstance(step, CollectInformationFlowStep)
and step.reset_after_flow_ends
):
slot = tracker.slots.get(step.collect, None)
initial_value = slot.initial_value if slot else None
events.append(SlotSet(step.collect, initial_value))
if isinstance(step, CollectInformationFlowStep):
# reset all slots scoped to the flow
if step.reset_after_flow_ends:
_reset_slot(step.collect, tracker)
else:
not_resettable_slot_names.add(step.collect)

# slots set by the set slots step should be reset after the flow ends
# unless they are also used in a collect step where `reset_after_flow_ends`
# is set to `False`
resettable_set_slots = [
slot["key"]
for step in current_flow.steps
if isinstance(step, SetSlotsFlowStep)
for slot in step.slots
if slot["key"] not in not_resettable_slot_names
]

for name in resettable_set_slots:
_reset_slot(name, tracker)

return events

def run_step(
Expand Down
2 changes: 1 addition & 1 deletion rasa/dialogue_understanding/commands/start_flow_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run_command_on_tracker(
"command_executor.skip_command.already_started_flow", command=self
)
return []
elif self.flow not in all_flows.non_pattern_flows():
elif self.flow not in all_flows.user_flow_ids:
structlogger.debug(
"command_executor.skip_command.start_invalid_flow_id", command=self
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Here is what happened previously in the conversation:

===
{% if current_flow != None %}
You are currently in the flow "{{ current_flow }}", which {{ current_flow.description }}
You have just asked the user for the slot "{{ collect }}"{% if collect_description %} ({{ collect_description }}){% endif %}.
You are currently in the flow "{{ current_flow }}".
You have just asked the user for the slot "{{ current_slot }}"{% if current_slot_description %} ({{ current_slot_description }}){% endif %}.

{% if flow_slots|length > 0 %}
Here are the slots of the currently active flow:
Expand Down
Loading

0 comments on commit 7daa8d5

Please sign in to comment.