rasa-pro 3.12.0rc1__py3-none-any.whl → 3.12.0rc3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

Files changed (70) hide show
  1. README.md +10 -13
  2. rasa/cli/dialogue_understanding_test.py +5 -8
  3. rasa/cli/llm_fine_tuning.py +47 -12
  4. rasa/cli/project_templates/calm/domain/list_contacts.yml +1 -2
  5. rasa/cli/project_templates/calm/domain/remove_contact.yml +1 -2
  6. rasa/cli/project_templates/calm/domain/shared.yml +1 -4
  7. rasa/core/actions/action_handle_digressions.py +35 -13
  8. rasa/core/channels/voice_stream/asr/asr_event.py +5 -0
  9. rasa/core/channels/voice_stream/audiocodes.py +19 -6
  10. rasa/core/channels/voice_stream/call_state.py +3 -9
  11. rasa/core/channels/voice_stream/genesys.py +40 -55
  12. rasa/core/channels/voice_stream/voice_channel.py +61 -39
  13. rasa/core/policies/flows/flow_executor.py +7 -2
  14. rasa/core/processor.py +0 -1
  15. rasa/core/tracker_store.py +123 -34
  16. rasa/dialogue_understanding/commands/can_not_handle_command.py +1 -1
  17. rasa/dialogue_understanding/commands/cancel_flow_command.py +1 -1
  18. rasa/dialogue_understanding/commands/change_flow_command.py +1 -1
  19. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +1 -1
  20. rasa/dialogue_understanding/commands/clarify_command.py +1 -1
  21. rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -1
  22. rasa/dialogue_understanding/commands/handle_digressions_command.py +1 -7
  23. rasa/dialogue_understanding/commands/human_handoff_command.py +1 -1
  24. rasa/dialogue_understanding/commands/knowledge_answer_command.py +1 -1
  25. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +1 -1
  26. rasa/dialogue_understanding/commands/set_slot_command.py +2 -1
  27. rasa/dialogue_understanding/commands/skip_question_command.py +1 -1
  28. rasa/dialogue_understanding/commands/start_flow_command.py +3 -1
  29. rasa/dialogue_understanding/commands/utils.py +2 -32
  30. rasa/dialogue_understanding/generator/command_parser.py +41 -0
  31. rasa/dialogue_understanding/generator/constants.py +7 -2
  32. rasa/dialogue_understanding/generator/llm_based_command_generator.py +9 -2
  33. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +1 -1
  34. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +29 -48
  35. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_fallback_other_models_template.jinja2 +57 -0
  36. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +23 -50
  37. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +141 -27
  38. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +32 -18
  39. rasa/dialogue_understanding/processor/command_processor.py +43 -23
  40. rasa/dialogue_understanding/stack/utils.py +49 -6
  41. rasa/dialogue_understanding_test/du_test_case.py +30 -10
  42. rasa/dialogue_understanding_test/du_test_result.py +1 -1
  43. rasa/e2e_test/assertions.py +6 -8
  44. rasa/e2e_test/llm_judge_prompts/answer_relevance_prompt_template.jinja2 +5 -1
  45. rasa/e2e_test/llm_judge_prompts/groundedness_prompt_template.jinja2 +4 -0
  46. rasa/engine/language.py +67 -25
  47. rasa/llm_fine_tuning/conversations.py +3 -31
  48. rasa/llm_fine_tuning/llm_data_preparation_module.py +5 -3
  49. rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +18 -13
  50. rasa/llm_fine_tuning/paraphrasing_module.py +6 -2
  51. rasa/llm_fine_tuning/train_test_split_module.py +27 -27
  52. rasa/llm_fine_tuning/utils.py +7 -0
  53. rasa/shared/constants.py +4 -0
  54. rasa/shared/core/domain.py +2 -0
  55. rasa/shared/core/slots.py +6 -0
  56. rasa/shared/providers/_configs/azure_entra_id_config.py +8 -8
  57. rasa/shared/providers/llm/litellm_router_llm_client.py +1 -0
  58. rasa/shared/providers/llm/openai_llm_client.py +2 -2
  59. rasa/shared/providers/router/_base_litellm_router_client.py +38 -7
  60. rasa/shared/utils/llm.py +69 -10
  61. rasa/telemetry.py +13 -3
  62. rasa/tracing/instrumentation/attribute_extractors.py +2 -5
  63. rasa/validator.py +2 -2
  64. rasa/version.py +1 -1
  65. {rasa_pro-3.12.0rc1.dist-info → rasa_pro-3.12.0rc3.dist-info}/METADATA +12 -14
  66. {rasa_pro-3.12.0rc1.dist-info → rasa_pro-3.12.0rc3.dist-info}/RECORD +69 -68
  67. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_default.jinja2 +0 -68
  68. {rasa_pro-3.12.0rc1.dist-info → rasa_pro-3.12.0rc3.dist-info}/NOTICE +0 -0
  69. {rasa_pro-3.12.0rc1.dist-info → rasa_pro-3.12.0rc3.dist-info}/WHEEL +0 -0
  70. {rasa_pro-3.12.0rc1.dist-info → rasa_pro-3.12.0rc3.dist-info}/entry_points.txt +0 -0
@@ -141,7 +141,9 @@ class StartFlowCommand(Command):
141
141
  def regex_pattern() -> str:
142
142
  mapper = {
143
143
  CommandSyntaxVersion.v1: r"StartFlow\(['\"]?([a-zA-Z0-9_-]+)['\"]?\)",
144
- CommandSyntaxVersion.v2: r"^[^\w]*start flow ['\"]?([a-zA-Z0-9_-]+)['\"]?",
144
+ CommandSyntaxVersion.v2: (
145
+ r"""^[\s\W\d]*start flow ['"`]?([a-zA-Z0-9_-]+)['"`]*"""
146
+ ),
145
147
  }
146
148
  return mapper.get(
147
149
  CommandSyntaxManager.get_syntax_version(),
@@ -1,14 +1,11 @@
1
- from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Union
1
+ from typing import TYPE_CHECKING, List, Optional, Tuple, Union
2
2
 
3
3
  import structlog
4
4
 
5
5
  from rasa.dialogue_understanding.patterns.validate_slot import (
6
6
  ValidateSlotPatternFlowStackFrame,
7
7
  )
8
- from rasa.shared.constants import (
9
- ACTION_ASK_PREFIX,
10
- UTTER_ASK_PREFIX,
11
- )
8
+ from rasa.shared.constants import ACTION_ASK_PREFIX, UTTER_ASK_PREFIX
12
9
  from rasa.shared.core.events import Event, SlotSet
13
10
  from rasa.shared.core.slots import Slot
14
11
  from rasa.shared.core.trackers import DialogueStateTracker
@@ -100,7 +97,6 @@ def create_validate_frames_from_slot_set_events(
100
97
  events: List[Event],
101
98
  validate_frames: List[ValidateSlotPatternFlowStackFrame] = [],
102
99
  should_break: bool = False,
103
- update_corrected_slots: bool = False,
104
100
  ) -> Tuple[DialogueStateTracker, List[ValidateSlotPatternFlowStackFrame]]:
105
101
  """Process SlotSet events and create validation frames.
106
102
 
@@ -111,8 +107,6 @@ def create_validate_frames_from_slot_set_events(
111
107
  if True, break out of the event loop as soon as the first non-SlotSet
112
108
  event is encountered.
113
109
  if False, continue processing the events until the end.
114
- update_corrected_slots: whether or not corrected slots in the last
115
- correction frame need to be updated.
116
110
 
117
111
  Returns:
118
112
  Tuple of (updated tracker, list of validation frames).
@@ -130,29 +124,5 @@ def create_validate_frames_from_slot_set_events(
130
124
 
131
125
  if frame:
132
126
  validate_frames.append(frame)
133
- if update_corrected_slots:
134
- tracker = update_corrected_slots_in_correction_frame(
135
- tracker, event.key, event.value
136
- )
137
127
 
138
128
  return tracker, validate_frames
139
-
140
-
141
- def update_corrected_slots_in_correction_frame(
142
- tracker: DialogueStateTracker, slot_name: str, slot_value: Any
143
- ) -> DialogueStateTracker:
144
- """Update the corrected_slots and new_slot_values of the
145
- CorrectionPatternFlowStackFrame with only valid values.
146
- """
147
- stack = tracker.stack
148
- top_frame = stack.top()
149
- del top_frame.corrected_slots[slot_name] # type: ignore[union-attr]
150
- top_frame.new_slot_values.remove(slot_value) # type: ignore[union-attr]
151
-
152
- # since we can't directly modify a stack we have to pop first
153
- # and then push back the updated frame
154
- stack.pop()
155
- stack.push(top_frame)
156
- new_events = tracker.create_stack_updated_events(stack)
157
- tracker.update_with_events(new_events)
158
- return tracker
@@ -1,4 +1,5 @@
1
1
  import re
2
+ import sys
2
3
  from functools import lru_cache
3
4
  from typing import Any, Callable, Dict, List, Optional, Type, Union
4
5
 
@@ -78,6 +79,44 @@ def _get_additional_parsing_logic(
78
79
  return command_to_parsing_fn_mapper.get(command_clz)
79
80
 
80
81
 
82
+ def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None:
83
+ clz_not_inheriting_from_command_clz = [
84
+ command_clz
85
+ for command_clz in command_classes
86
+ if not issubclass(command_clz, Command)
87
+ ]
88
+
89
+ if clz_not_inheriting_from_command_clz:
90
+ structlogger.error(
91
+ "command_parser.validate_custom_commands.invalid_command",
92
+ invalid_commands=clz_not_inheriting_from_command_clz,
93
+ event_info=(
94
+ "The additional command classes must be a subclass of the 'Command' "
95
+ "class. Please refer to the class in "
96
+ "`rasa.dialogue_understanding.commands.command.Command`"
97
+ ),
98
+ )
99
+ sys.exit(1)
100
+
101
+ clz_not_adhering_to_prompt_command_protocol = [
102
+ command_clz
103
+ for command_clz in command_classes
104
+ if not isinstance(command_clz, PromptCommand)
105
+ ]
106
+
107
+ if clz_not_adhering_to_prompt_command_protocol:
108
+ structlogger.error(
109
+ "command_parser.validate_custom_commands.invalid_command",
110
+ invalid_commands=clz_not_adhering_to_prompt_command_protocol,
111
+ event_info=(
112
+ "The additional command classes must adhere to the 'PromptCommand' "
113
+ "protocol. Please refer to the protocol in "
114
+ "`rasa.dialogue_understanding.commands.prompt_command.PromptCommand`"
115
+ ),
116
+ )
117
+ sys.exit(1)
118
+
119
+
81
120
  def parse_commands(
82
121
  actions: Optional[str],
83
122
  flows: FlowsList,
@@ -93,6 +132,8 @@ def parse_commands(
93
132
  return []
94
133
 
95
134
  commands: List[Command] = []
135
+ validate_custom_commands(additional_commands or [])
136
+
96
137
  default_commands = DEFAULT_COMMANDS
97
138
  if default_commands_to_remove:
98
139
  default_commands = _create_default_commands(default_commands_to_remove)
@@ -1,7 +1,9 @@
1
1
  from rasa.shared.constants import (
2
+ MAX_TOKENS_CONFIG_KEY,
2
3
  MODEL_CONFIG_KEY,
3
4
  OPENAI_PROVIDER,
4
5
  PROVIDER_CONFIG_KEY,
6
+ TEMPERATURE_CONFIG_KEY,
5
7
  TIMEOUT_CONFIG_KEY,
6
8
  )
7
9
  from rasa.shared.utils.llm import (
@@ -12,8 +14,8 @@ from rasa.shared.utils.llm import (
12
14
  DEFAULT_LLM_CONFIG = {
13
15
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
14
16
  MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME_ADVANCED,
15
- "temperature": 0.0,
16
- "max_tokens": DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
17
+ TEMPERATURE_CONFIG_KEY: 0.0,
18
+ MAX_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
17
19
  TIMEOUT_CONFIG_KEY: 7,
18
20
  }
19
21
 
@@ -28,3 +30,6 @@ FLOW_RETRIEVAL_FLOW_THRESHOLD = 20
28
30
 
29
31
  COMMAND_PROMPT_FILE_NAME = "command_prompt.jinja2"
30
32
  LLM_BASED_COMMAND_GENERATOR_CONFIG_FILE = "config.json"
33
+
34
+ MODEL_NAME_GPT_4O_2024_11_20 = "gpt-4o-2024-11-20"
35
+ MODEL_NAME_CLAUDE_3_5_SONNET_20240620 = "claude-3-5-sonnet-20240620"
@@ -175,7 +175,7 @@ class LLMBasedCommandGenerator(
175
175
  """
176
176
  self.perform_llm_health_check(
177
177
  self.config.get(LLM_CONFIG_KEY),
178
- DEFAULT_LLM_CONFIG,
178
+ self.get_default_llm_config(),
179
179
  "llm_based_command_generator.train",
180
180
  LLMBasedCommandGenerator.__name__,
181
181
  )
@@ -332,7 +332,9 @@ class LLMBasedCommandGenerator(
332
332
  Raises:
333
333
  ProviderClientAPIException: If an error occurs during the LLM API call.
334
334
  """
335
- llm = llm_factory(self.config.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG)
335
+ llm = llm_factory(
336
+ self.config.get(LLM_CONFIG_KEY), self.get_default_llm_config()
337
+ )
336
338
  try:
337
339
  return await llm.acompletion(prompt)
338
340
  except Exception as e:
@@ -619,3 +621,8 @@ class LLMBasedCommandGenerator(
619
621
  )
620
622
  )
621
623
  return prior_commands, filtered_commands
624
+
625
+ @staticmethod
626
+ def get_default_llm_config() -> Dict[str, Any]:
627
+ """Get the default LLM config for the command generator."""
628
+ return DEFAULT_LLM_CONFIG
@@ -226,7 +226,7 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
226
226
  # be completed, "predict" the ErrorCommand
227
227
  commands = [ErrorCommand()]
228
228
 
229
- if not commands:
229
+ if not commands and not prior_commands:
230
230
  # if for any reason the final list of commands is empty,
231
231
  # "predict" CannotHandle
232
232
  commands = [CannotHandleCommand()]
@@ -1,77 +1,58 @@
1
+ ## Task Description
1
2
  Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.
2
3
 
4
+ --
5
+
3
6
  ## Available Actions:
4
- * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`
5
- * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values
6
- * `cancel flow`: Cancelling the current flow
7
+ * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
8
+ * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
9
+ * `cancel flow`: Cancelling the current flow.
7
10
  * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: Disambiguate which flow should be started when user input is ambiguous by listing the potential flows as options. For example, `disambiguate flows list_contacts add_contact remove_contact ...` if the user just wrote "contacts".
8
- * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services
11
+ * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services.
9
12
  * `offtopic reply`: Responding to casual or social user messages that are unrelated to any flows, engaging in friendly conversation and addressing off-topic remarks.
10
- * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one
13
+ * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one.
11
14
 
15
+ --
12
16
 
13
17
  ## General Tips
14
18
  * Do not fill slots with abstract values or placeholders.
19
+ * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
20
+ * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
21
+ * Always refer to the slot description to determine what information should be extracted and how it should be formatted.
22
+ * For text slots, extract values exactly as provided by the user unless the slot description specifies otherwise. Preserve formatting and avoid rewording, truncation, or making assumptions.
15
23
  * Only use information provided by the user.
16
24
  * Use clarification in ambiguous cases.
17
25
  * Multiple flows can be started. If a user wants to digress into a second flow, you do not need to cancel the current flow.
26
+ * Do not cancel the flow unless the user explicitly requests it.
18
27
  * Strictly adhere to the provided action format.
19
- * For categorical slots try to match the user message with potential slot values. Use "other" if you cannot match it
20
28
  * Focus on the last message and take it one step at a time.
21
29
  * Use the previous conversation steps only to aid understanding.
22
30
 
31
+ --
23
32
 
24
- ## Available Flows:
25
- Use the following structured date:
26
- ```xml
27
- <flows>
28
- {% for flow in available_flows %}<flow>
29
- <name>{{ flow.name }}</name>
30
- <description>{{ flow.description }}</description>
31
- <slots>{% for slot in flow.slots %}
32
- <slot>
33
- <name>{{ slot.name }}</name>
34
- <description>{{ slot.description }}</description>
35
- <allowed_values>{{ slot.allowed_values }}</allowed_values>
36
- </slot>{% endfor %}
37
- </slots>
38
- </flow>
39
- {% endfor %}
40
- </flows>
33
+ ## Available Flows and Slots
34
+ Use the following structured data:
35
+ ```json
36
+ {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":"{{ flow.description }}"{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
41
37
  ```
42
38
 
39
+ --
40
+
43
41
  ## Current State
44
- {% if current_flow != None %}
45
- Use the following structured date:
46
- ```xml
47
- <current_state>
48
- <active_flow>{{ current_flow }}</active_flow>
49
- <current_step>
50
- <requested_slot>{{ current_slot }}</requested_slot>
51
- <requested_slot_description>{{ current_slot_description }}</requested_slot_description>
52
- </current_step>
53
- <slots>
54
- {% for slot in flow_slots %}<slot>
55
- <name>{{ slot.name }}</name>
56
- <value>{{ slot.value }}</value>
57
- <type>{{ slot.type }}</type>
58
- <description>{{ slot.description }}</description>{% if slot.allowed_values %}
59
- <allowed_values>{{ slot.allowed_values }}</allowed_values>{% endif %}
60
- </slot>
61
- {% endfor %}
62
- </slots>
63
- </current_state>
64
- ```
65
- {% else %}
66
- You are currently not inside any flow.
67
- {% endif %}
42
+ {% if current_flow != None %}Use the following structured data:
43
+ ```json
44
+ {"active_flow":"{{ current_flow }}","current_step":{"requested_slot":"{{ current_slot }}","requested_slot_description":"{{ current_slot_description }}"},"slots":[{% for slot in flow_slots %}{"name":"{{ slot.name }}","value":"{{ slot.value }}","type":"{{ slot.type }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":"{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
45
+ ```{% else %}
46
+ You are currently not inside any flow.{% endif %}
68
47
 
48
+ ---
69
49
 
70
50
  ## Conversation History
71
51
  {{ current_conversation }}
72
52
 
53
+ ---
73
54
 
74
55
  ## Task
75
- Create an action list with one action per line in response to the users last message: """{{ user_message }}""".
56
+ Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
76
57
 
77
58
  Your action list:
@@ -0,0 +1,57 @@
1
+ ## Task Description
2
+ Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.
3
+
4
+ ---
5
+
6
+ ## Available Flows and Slots
7
+ Use the following structured data:
8
+ ```json
9
+ {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":"{{ flow.description }}"{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
10
+ ```
11
+
12
+ ---
13
+
14
+ ## Available Actions:
15
+ * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
+ * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
+ * `cancel flow`: Cancelling the current flow.
18
+ * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: Disambiguate which flow should be started when user input is ambiguous by listing the potential flows as options. For example, `disambiguate flows list_contacts add_contact remove_contact ...` if the user just wrote "contacts".
19
+ * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services.
20
+ * `offtopic reply`: Responding to casual or social user messages that are unrelated to any flows, engaging in friendly conversation and addressing off-topic remarks.
21
+ * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one.
22
+
23
+ ---
24
+
25
+ ## General Tips
26
+ * Do not fill slots with abstract values or placeholders.
27
+ * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
28
+ * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
29
+ * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
30
+ * Only use information provided by the user.
31
+ * Use clarification in ambiguous cases.
32
+ * Multiple flows can be started. If a user wants to digress into a second flow, you do not need to cancel the current flow.
33
+ * Do not cancel the flow unless the user explicitly requests it.
34
+ * Strictly adhere to the provided action format.
35
+ * Focus on the last message and take it one step at a time.
36
+ * Use the previous conversation steps only to aid understanding.
37
+
38
+ ---
39
+
40
+ ## Current State
41
+ {% if current_flow != None %}Use the following structured data:
42
+ ```json
43
+ {"active_flow":"{{ current_flow }}","current_step":{"requested_slot":"{{ current_slot }}","requested_slot_description":"{{ current_slot_description }}"},"slots":[{% for slot in flow_slots %}{"name":"{{ slot.name }}","value":"{{ slot.value }}","type":"{{ slot.type }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":"{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
44
+ ```{% else %}
45
+ You are currently not inside any flow.{% endif %}
46
+
47
+ ---
48
+
49
+ ## Conversation History
50
+ {{ current_conversation }}
51
+
52
+ ---
53
+
54
+ ## Task
55
+ Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
56
+
57
+ Your action list:
@@ -1,73 +1,46 @@
1
1
  ## Task Description
2
2
  Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.
3
3
 
4
- --
4
+ ---
5
+
6
+ ## Available Flows and Slots
7
+ Use the following structured data:
8
+ ```json
9
+ {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":"{{ flow.description }}"{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
10
+ ```
11
+
12
+ ---
5
13
 
6
14
  ## Available Actions:
7
- * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`
8
- * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values
9
- * `cancel flow`: Cancelling the current flow
15
+ * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
+ * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
+ * `cancel flow`: Cancelling the current flow.
10
18
  * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: Disambiguate which flow should be started when user input is ambiguous by listing the potential flows as options. For example, `disambiguate flows list_contacts add_contact remove_contact ...` if the user just wrote "contacts".
11
- * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services
19
+ * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services.
12
20
  * `offtopic reply`: Responding to casual or social user messages that are unrelated to any flows, engaging in friendly conversation and addressing off-topic remarks.
13
- * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one
21
+ * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one.
14
22
 
15
- --
23
+ ---
16
24
 
17
25
  ## General Tips
18
26
  * Do not fill slots with abstract values or placeholders.
27
+ * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
28
+ * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
29
+ * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
19
30
  * Only use information provided by the user.
20
31
  * Use clarification in ambiguous cases.
21
32
  * Multiple flows can be started. If a user wants to digress into a second flow, you do not need to cancel the current flow.
33
+ * Do not cancel the flow unless the user explicitly requests it.
22
34
  * Strictly adhere to the provided action format.
23
- * For categorical slots try to match the user message with potential slot values. Use "other" if you cannot match it
24
35
  * Focus on the last message and take it one step at a time.
25
36
  * Use the previous conversation steps only to aid understanding.
26
37
 
27
- --
28
-
29
- ## Available Flows and Slots
30
- Use the following structured date:
31
- ```json
32
- {
33
- "flows": [
34
- {% for flow in available_flows %}{
35
- "name": "{{ flow.name }}",
36
- "description": "{{ flow.description }}"{% if flow.slots %},
37
- "slots": [{% for slot in flow.slots %}
38
- {
39
- "name": "{{ slot.name }}"{% if slot.description %},
40
- "description": "{{ slot.description }}"{% endif %}{% if slot.allowed_values %},
41
- "allowed_values": {{ slot.allowed_values }}{% endif %}
42
- }{% if not loop.last %},{% endif %}{% endfor %}
43
- ]{% endif %}
44
- }{% if not loop.last %},
45
- {% endif %}{% endfor %}
46
- ]
47
- }
48
- ```
49
-
50
- --
38
+ ---
51
39
 
52
40
  ## Current State
53
- {% if current_flow != None %}Use the following structured date:
41
+ {% if current_flow != None %}Use the following structured data:
54
42
  ```json
55
- {
56
- "active_flow": "{{ current_flow }}",
57
- "current_step": {
58
- "requested_slot": "{{ current_slot }}",
59
- "requested_slot_description": "{{ current_slot_description }}"
60
- },
61
- "slots": [{% for slot in flow_slots %}
62
- {
63
- "name": "{{ slot.name }}",
64
- "value": "{{ slot.value }}",
65
- "type": "{{ slot.type }}"{% if slot.description %},
66
- "description": "{{ slot.description }}"{% endif %}{% if slot.allowed_values %},
67
- "allowed_values": "{{ slot.allowed_values }}"{% endif %}
68
- }{% if not loop.last %},{% endif %}{% endfor %}
69
- ]
70
- }
43
+ {"active_flow":"{{ current_flow }}","current_step":{"requested_slot":"{{ current_slot }}","requested_slot_description":"{{ current_slot_description }}"},"slots":[{% for slot in flow_slots %}{"name":"{{ slot.name }}","value":"{{ slot.value }}","type":"{{ slot.type }}"{% if slot.description %},"description":"{{ slot.description }}"{% endif %}{% if slot.allowed_values %},"allowed_values":"{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
71
44
  ```{% else %}
72
45
  You are currently not inside any flow.{% endif %}
73
46
 
@@ -79,6 +52,6 @@ You are currently not inside any flow.{% endif %}
79
52
  ---
80
53
 
81
54
  ## Task
82
- Create an action list with one action per line in response to the users last message: """{{ user_message }}""".
55
+ Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
83
56
 
84
57
  Your action list: