Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit de6ed2a

Browse files
Merge pull request #31 from UiPath/feature/add-interrupt-models
feat: add chat interrupt models
2 parents 5ffb39f + 26b0c60 commit de6ed2a

4 files changed

Lines changed: 83 additions & 12 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-core"
3-
version = "0.2.4"
3+
version = "0.3.0"
44
description = "UiPath Core abstractions"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/core/chat/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@
7979
UiPathConversationExchangeStartEvent,
8080
)
8181
from .interrupt import (
82+
InterruptTypeEnum,
83+
UiPathConversationGenericInterruptEndEvent,
84+
UiPathConversationGenericInterruptStartEvent,
8285
UiPathConversationInterruptEndEvent,
8386
UiPathConversationInterruptEvent,
8487
UiPathConversationInterruptStartEvent,
88+
UiPathConversationToolCallConfirmationEndValue,
89+
UiPathConversationToolCallConfirmationInterruptEndEvent,
90+
UiPathConversationToolCallConfirmationInterruptStartEvent,
91+
UiPathConversationToolCallConfirmationValue,
8592
)
8693
from .message import (
8794
UiPathConversationMessage,
@@ -122,9 +129,16 @@
122129
"UiPathConversationMessageEvent",
123130
"UiPathConversationMessage",
124131
# Interrupt
132+
"InterruptTypeEnum",
125133
"UiPathConversationInterruptStartEvent",
126134
"UiPathConversationInterruptEndEvent",
127135
"UiPathConversationInterruptEvent",
136+
"UiPathConversationToolCallConfirmationValue",
137+
"UiPathConversationToolCallConfirmationEndValue",
138+
"UiPathConversationToolCallConfirmationInterruptStartEvent",
139+
"UiPathConversationToolCallConfirmationInterruptEndEvent",
140+
"UiPathConversationGenericInterruptStartEvent",
141+
"UiPathConversationGenericInterruptEndEvent",
128142
# Content
129143
"UiPathConversationContentPartChunkEvent",
130144
"UiPathConversationContentPartStartEvent",

src/uipath/core/chat/interrupt.py

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,83 @@
11
"""Interrupt events for human-in-the-loop patterns."""
22

3-
from typing import Any
3+
from enum import Enum
4+
from typing import Any, Literal, Union
45

56
from pydantic import BaseModel, ConfigDict, Field
67

78

8-
class UiPathConversationInterruptStartEvent(BaseModel):
9-
"""Signals the start of an interrupt - a pause point where the agent needs external input."""
9+
class InterruptTypeEnum(str, Enum):
10+
"""Enum of known interrupt types."""
11+
12+
TOOL_CALL_CONFIRMATION = "uipath_cas_tool_call_confirmation"
13+
14+
15+
class UiPathConversationToolCallConfirmationValue(BaseModel):
16+
"""Schema for tool call confirmation interrupt value."""
17+
18+
tool_call_id: str = Field(..., alias="toolCallId")
19+
tool_name: str = Field(..., alias="toolName")
20+
input_schema: Any = Field(..., alias="inputSchema")
21+
input_value: Any | None = Field(None, alias="inputValue")
22+
23+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
24+
25+
26+
class UiPathConversationToolCallConfirmationInterruptStartEvent(BaseModel):
27+
"""Tool call confirmation interrupt start event with strong typing."""
28+
29+
type: Literal["uipath_cas_tool_call_confirmation"]
30+
value: UiPathConversationToolCallConfirmationValue
31+
32+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
33+
34+
35+
class UiPathConversationGenericInterruptStartEvent(BaseModel):
36+
"""Generic interrupt start event for custom interrupt types."""
1037

1138
type: str
1239
value: Any
1340

1441
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
1542

1643

17-
class UiPathConversationInterruptEndEvent(BaseModel):
18-
"""Signals the interrupt end event with the provided value."""
44+
UiPathConversationInterruptStartEvent = Union[
45+
UiPathConversationToolCallConfirmationInterruptStartEvent,
46+
UiPathConversationGenericInterruptStartEvent,
47+
]
1948

20-
# Can be any type
21-
model_config = ConfigDict(
22-
validate_by_name=True, validate_by_alias=True, extra="allow"
23-
)
49+
50+
class UiPathConversationToolCallConfirmationEndValue(BaseModel):
51+
"""Schema for tool call confirmation end value."""
52+
53+
approved: bool
54+
input: Any | None = None
55+
56+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
57+
58+
59+
class UiPathConversationToolCallConfirmationInterruptEndEvent(BaseModel):
60+
"""Tool call confirmation interrupt end event with strong typing."""
61+
62+
type: Literal["uipath_cas_tool_call_confirmation"]
63+
value: UiPathConversationToolCallConfirmationEndValue
64+
65+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
66+
67+
68+
class UiPathConversationGenericInterruptEndEvent(BaseModel):
69+
"""Generic interrupt end event for custom interrupt types."""
70+
71+
type: str
72+
value: Any
73+
74+
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
75+
76+
77+
UiPathConversationInterruptEndEvent = Union[
78+
UiPathConversationToolCallConfirmationInterruptEndEvent,
79+
UiPathConversationGenericInterruptEndEvent,
80+
]
2481

2582

2683
class UiPathConversationInterruptEvent(BaseModel):
@@ -30,6 +87,6 @@ class UiPathConversationInterruptEvent(BaseModel):
3087
start: UiPathConversationInterruptStartEvent | None = Field(
3188
None, alias="startInterrupt"
3289
)
33-
end: Any | None = Field(None, alias="endInterrupt")
90+
end: UiPathConversationInterruptEndEvent | None = Field(None, alias="endInterrupt")
3491

3592
model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)