Skip to content

Commit 0426a8e

Browse files
feat: add generic chat interrupts
1 parent d3b8271 commit 0426a8e

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.8.31"
3+
version = "2.8.32"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/_cli/_chat/_bridge.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
from typing import Any
99
from urllib.parse import urlparse
1010

11+
from pydantic import ValidationError
12+
1113
from uipath.core.chat import (
1214
UiPathConversationEvent,
1315
UiPathConversationExchangeEndEvent,
1416
UiPathConversationExchangeEvent,
17+
UiPathConversationGenericInterruptStartEvent,
1518
UiPathConversationInterruptEndEvent,
1619
UiPathConversationInterruptEvent,
1720
UiPathConversationMessageEvent,
@@ -264,6 +267,33 @@ async def emit_interrupt_event(self, resume_trigger: UiPathResumeTrigger):
264267
"Cannot emit interrupt event: api_resume is None"
265268
)
266269

270+
# Try to parse as tool call confirmation first
271+
try:
272+
start_event = UiPathConversationToolCallConfirmationInterruptStartEvent(
273+
type="uipath_cas_tool_call_confirmation",
274+
value=UiPathConversationToolCallConfirmationValue(
275+
**resume_trigger.api_resume.request
276+
),
277+
)
278+
except Exception:
279+
# Fall back to generic interrupt if parsing fails
280+
logger.info(
281+
"Failed to parse as tool call confirmation, using generic interrupt"
282+
)
283+
284+
# Wrap request in JSON if it's not already a dict
285+
request_value = resume_trigger.api_resume.request
286+
if not isinstance(request_value, dict):
287+
request_value = {"value": request_value}
288+
289+
# Extract type from request
290+
interrupt_type = request_value.get("type", "uipath_cas_generic")
291+
292+
start_event = UiPathConversationGenericInterruptStartEvent(
293+
type=interrupt_type,
294+
value=request_value,
295+
)
296+
267297
interrupt_event = UiPathConversationEvent(
268298
conversation_id=self.conversation_id,
269299
exchange=UiPathConversationExchangeEvent(
@@ -272,12 +302,7 @@ async def emit_interrupt_event(self, resume_trigger: UiPathResumeTrigger):
272302
message_id=self._current_message_id,
273303
interrupt=UiPathConversationInterruptEvent(
274304
interrupt_id=self._interrupt_id,
275-
start=UiPathConversationToolCallConfirmationInterruptStartEvent(
276-
type="uipath_cas_tool_call_confirmation",
277-
value=UiPathConversationToolCallConfirmationValue(
278-
**resume_trigger.api_resume.request
279-
),
280-
),
305+
start=start_event,
281306
),
282307
),
283308
),

0 commit comments

Comments
 (0)