File tree 3 files changed +24
-9
lines changed
3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -508,12 +508,23 @@ def get_first_bot_intent(strings: List[str]) -> Optional[str]:
508
508
509
509
def get_first_bot_action (strings : List [str ]) -> Optional [str ]:
510
510
"""Returns first bot action."""
511
- action : Optional [str ] = None
511
+ action_started = False
512
+ action : str = ""
512
513
for string in strings :
513
514
if string .startswith ("bot action: " ):
514
- action = string .replace ("bot action: " , "" )
515
- elif action and (string .startswith (" and" ) or string .startswith (" or" )):
515
+ if action != "" :
516
+ action += "\n "
517
+ action += string .replace ("bot action: " , "" )
518
+ action_started = True
519
+ elif (
520
+ string .startswith (" and" ) or string .startswith (" or" )
521
+ ) and action_started :
516
522
action = action + string
523
+ elif string == "" :
524
+ action_started = False
525
+ continue
526
+ elif action != "" :
527
+ return action
517
528
return action
518
529
519
530
Original file line number Diff line number Diff line change @@ -569,6 +569,7 @@ async def create_flow(
569
569
events : List [dict ],
570
570
name : str ,
571
571
body : str ,
572
+ decorators : Optional [str ] = None ,
572
573
) -> dict :
573
574
"""Create a new flow during runtime."""
574
575
@@ -578,10 +579,14 @@ async def create_flow(
578
579
flow_name = f"_dynamic_{ uuid } { name } "
579
580
# TODO: parse potential parameters from flow name with a regex
580
581
582
+ body = f"flow { flow_name } \n " + body
583
+ if decorators :
584
+ body = decorators + "\n " + body
585
+
581
586
return {
582
587
"name" : flow_name ,
583
588
"parameters" : [],
584
- "body" : f"flow { flow_name } \n " + body ,
589
+ "body" : body ,
585
590
}
586
591
587
592
@action (name = "GenerateValueAction" , is_system_action = True , execute_async = True )
Original file line number Diff line number Diff line change @@ -104,19 +104,18 @@ flow continuation on unhandled user utterance
104
104
# Create and start new flow or an existing on with same name as bot intent
105
105
$flow_exists = False
106
106
if $bot_intent is None
107
- $bot_intent = "bot custom action "
107
+ $bot_intent = "bot reacts accordingly "
108
108
else
109
109
$flow_exists = await CheckValidFlowExistsAction(flow_id=$bot_intent)
110
110
111
111
if $flow_exists == False and $bot_action is not None
112
- $flow_info = await CreateFlowAction(name=$bot_intent, body=$bot_action)
112
+ $flow_info = await CreateFlowAction(name=$bot_intent, body=$bot_action, decorators='@meta(bot_intent="{$bot_intent}")\n' )
113
113
$flows = await AddFlowsAction(config=$flow_info.body)
114
114
if len($flows) == 0
115
115
print "Failed parsing created bot action flow!"
116
116
return
117
- # Start
118
- await await_flow_by_name $flow_info.name
119
- await RemoveFlowsAction(flow_ids=[$flow_info.name])
117
+ await await_flow_by_name $flow_info.name
118
+ await RemoveFlowsAction(flow_ids=[$flow_info.name])
120
119
121
120
122
121
flow unhandled user intent -> $intent
You can’t perform that action at this time.
0 commit comments