@@ -49,6 +49,7 @@ flow generating user intent for unhandled user utterance
49
49
activate polling llm request response
50
50
activate tracking bot talking state
51
51
global $bot_talking_state
52
+ global $user_message
52
53
53
54
await _user_said_something_unexpected as $user_said
54
55
$event = $user_said.event
@@ -60,15 +61,24 @@ flow generating user intent for unhandled user utterance
60
61
61
62
log 'unexpected user utterance: "{$event.final_transcript}"'
62
63
log 'start generating user intent...'
63
- $action = 'user said "{$event.final_transcript}"'
64
+
65
+ # Use the processed user message if available;
66
+ # otherwise, fall back to the original user input
67
+ if $user_message is not None
68
+ $message_for_llm = $user_message
69
+ else
70
+ $message_for_llm = $event.final_transcript
71
+
72
+ $action = 'user said "{$message_for_llm}"'
64
73
$intent = await GenerateUserIntentAction(user_action=$action, max_example_flows=20)
65
74
log 'generated user intent: {$intent}'
66
75
67
76
# Generate the 'user intent' by sending out the FinishFlow event
68
77
send FinishFlow(flow_id=$intent)
69
78
70
79
# We need to log the user action
71
- send UserActionLog(flow_id="user said", parameter=$event.final_transcript, intent_flow_id=$intent)
80
+ send UserActionLog(flow_id="user said", parameter=$message_for_llm, intent_flow_id=$intent)
81
+
72
82
# And we also need to log the generated user intent if not done by another mechanism
73
83
when UserIntentLog(flow_id=$intent)
74
84
return
@@ -84,6 +94,7 @@ flow continuation on unhandled user utterance
84
94
activate polling llm request response
85
95
activate tracking bot talking state
86
96
global $bot_talking_state
97
+ global $user_message
87
98
88
99
await _user_said_something_unexpected as $user_said
89
100
$event = $user_said.event
@@ -95,7 +106,15 @@ flow continuation on unhandled user utterance
95
106
abort
96
107
97
108
log 'start generating user intent and bot intent/action...'
98
- $action = 'user said "{$event.final_transcript}"'
109
+
110
+ # Use the processed user message if available;
111
+ # otherwise, fall back to the original user input
112
+ if $user_message is not None
113
+ $message_for_llm = $user_message
114
+ else
115
+ $message_for_llm = $event.final_transcript
116
+
117
+ $action = 'user said "{$message_for_llm}"'
99
118
100
119
101
120
# retrieve relevant chunks from KB if user_message is not empty
@@ -117,7 +136,8 @@ flow continuation on unhandled user utterance
117
136
send FinishFlow(flow_id=$user_intent)
118
137
119
138
# We need to log the user action
120
- send UserActionLog(flow_id="user said", parameter=$event.final_transcript, intent_flow_id=$user_intent)
139
+ send UserActionLog(flow_id="user said", parameter=$message_for_llm, intent_flow_id=$user_intent)
140
+
121
141
# And we also need to log the generated user intent if not done by another mechanism
122
142
when UserIntentLog(flow_id=$user_intent)
123
143
return
0 commit comments