From c1f1fa5ea3792e2ced1dc0d882e18b2a107e5d5a Mon Sep 17 00:00:00 2001 From: GabrielVasilescu04 Date: Wed, 4 Feb 2026 13:25:32 +0200 Subject: [PATCH] feat: add chat interrupt models --- pyproject.toml | 2 +- src/uipath/core/chat/__init__.py | 10 +++++-- src/uipath/core/chat/interrupt.py | 44 ++++++++++++++++++++++++------- uv.lock | 2 +- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5315f3a..b6834a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-core" -version = "0.2.3" +version = "0.2.4" description = "UiPath Core abstractions" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/core/chat/__init__.py b/src/uipath/core/chat/__init__.py index 52694d4..225fb2b 100644 --- a/src/uipath/core/chat/__init__.py +++ b/src/uipath/core/chat/__init__.py @@ -79,9 +79,12 @@ UiPathConversationExchangeStartEvent, ) from .interrupt import ( - UiPathConversationInterruptEndEvent, + InterruptTypeEnum, + UiPathConversationGenericInterruptStart, UiPathConversationInterruptEvent, UiPathConversationInterruptStartEvent, + UiPathConversationToolCallConfirmationInterruptStart, + UiPathConversationToolCallConfirmationValue, ) from .message import ( UiPathConversationMessage, @@ -122,9 +125,12 @@ "UiPathConversationMessageEvent", "UiPathConversationMessage", # Interrupt + "InterruptTypeEnum", "UiPathConversationInterruptStartEvent", - "UiPathConversationInterruptEndEvent", "UiPathConversationInterruptEvent", + "UiPathConversationToolCallConfirmationValue", + "UiPathConversationToolCallConfirmationInterruptStart", + "UiPathConversationGenericInterruptStart", # Content "UiPathConversationContentPartChunkEvent", "UiPathConversationContentPartStartEvent", diff --git a/src/uipath/core/chat/interrupt.py b/src/uipath/core/chat/interrupt.py index 7dfd300..aaac012 100644 --- a/src/uipath/core/chat/interrupt.py +++ b/src/uipath/core/chat/interrupt.py @@ -1,12 +1,39 @@ """Interrupt events for human-in-the-loop patterns.""" -from typing import Any +from enum import Enum +from typing import Any, Literal, Union from pydantic import BaseModel, ConfigDict, Field -class UiPathConversationInterruptStartEvent(BaseModel): - """Signals the start of an interrupt - a pause point where the agent needs external input.""" +class InterruptTypeEnum(str, Enum): + """Enum of known interrupt types.""" + + TOOL_CALL_CONFIRMATION = "uipath_cas_tool_call_confirmation" + + +class UiPathConversationToolCallConfirmationValue(BaseModel): + """Schema for tool call confirmation interrupt value.""" + + tool_call_id: str = Field(..., alias="toolCallId") + tool_name: str = Field(..., alias="toolName") + input_schema: Any = Field(..., alias="inputSchema") + input_value: Any | None = Field(None, alias="inputValue") + + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) + + +class UiPathConversationToolCallConfirmationInterruptStart(BaseModel): + """Tool call confirmation interrupt start event with strong typing.""" + + type: Literal["uipath_cas_tool_call_confirmation"] + value: UiPathConversationToolCallConfirmationValue + + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) + + +class UiPathConversationGenericInterruptStart(BaseModel): + """Generic interrupt start event for custom interrupt types.""" type: str value: Any @@ -14,13 +41,10 @@ class UiPathConversationInterruptStartEvent(BaseModel): model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) -class UiPathConversationInterruptEndEvent(BaseModel): - """Signals the interrupt end event with the provided value.""" - - # Can be any type - model_config = ConfigDict( - validate_by_name=True, validate_by_alias=True, extra="allow" - ) +UiPathConversationInterruptStartEvent = Union[ + UiPathConversationToolCallConfirmationInterruptStart, + UiPathConversationGenericInterruptStart, +] class UiPathConversationInterruptEvent(BaseModel): diff --git a/uv.lock b/uv.lock index f6c6ff6..c5aa483 100644 --- a/uv.lock +++ b/uv.lock @@ -991,7 +991,7 @@ wheels = [ [[package]] name = "uipath-core" -version = "0.2.3" +version = "0.2.4" source = { editable = "." } dependencies = [ { name = "opentelemetry-instrumentation" },