Make end call tool can be cancelled
This commit is contained in:
@@ -603,15 +603,12 @@ class WorkflowBrain(BaseBrain):
|
||||
self._state.consume_user_turn()
|
||||
if self._engine.node_type(self._state.current_node_id) == "agent":
|
||||
self._state.status = WorkflowStatus.WAITING_USER
|
||||
if (
|
||||
self._waiting_for_generated_end_speech
|
||||
and self._runtime is not None
|
||||
and self._runtime.call_end.ending
|
||||
):
|
||||
if self._waiting_for_generated_end_speech:
|
||||
self._waiting_for_generated_end_speech = False
|
||||
await self._runtime.call_end.finish_after_current_speech(
|
||||
has_text=bool(content.strip()) and not interrupted
|
||||
)
|
||||
if self._runtime is not None and self._runtime.call_end.ending:
|
||||
await self._runtime.call_end.finish_after_current_speech(
|
||||
has_text=bool(content.strip()) and not interrupted
|
||||
)
|
||||
|
||||
async def on_realtime_user_speech_started(self) -> None:
|
||||
if self._realtime_controller is not None:
|
||||
@@ -1090,13 +1087,19 @@ class WorkflowBrain(BaseBrain):
|
||||
message_type = str(config.get("message_type") or "none")
|
||||
custom_message = str(config.get("custom_message") or "").strip()
|
||||
capture_reason = bool(config.get("capture_reason", True))
|
||||
allow_end_interruption = bool(
|
||||
config.get("allow_end_interruption", False)
|
||||
)
|
||||
|
||||
async def handler(args, _flow_manager):
|
||||
reason = str((args or {}).get("reason") or "end_conversation").strip()
|
||||
uses_custom_message = message_type == "custom" and bool(custom_message)
|
||||
self._waiting_for_generated_end_speech = not uses_custom_message
|
||||
runtime = self._require_runtime()
|
||||
runtime.call_end.begin(reason)
|
||||
runtime.call_end.begin(
|
||||
reason,
|
||||
interruptible=allow_end_interruption,
|
||||
)
|
||||
if uses_custom_message:
|
||||
await self._queue_visible_speech(
|
||||
custom_message,
|
||||
|
||||
Reference in New Issue
Block a user