From 6a01328e72a9978bb9ed4987d166defcfcc60c98 Mon Sep 17 00:00:00 2001 From: Cristian Pufu Date: Mon, 19 Jan 2026 07:25:34 +0200 Subject: [PATCH] fix: send chat input as dict --- pyproject.toml | 2 +- src/uipath/dev/__init__.py | 2 +- src/uipath/dev/ui/panels/_json_schema.py | 62 ++++++++++++++++++++++++ src/uipath/dev/ui/styles/terminal.tcss | 4 +- uv.lock | 2 +- 5 files changed, 68 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 231a846..6d68072 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-dev" -version = "0.0.16" +version = "0.0.17" description = "UiPath Developer Console" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/dev/__init__.py b/src/uipath/dev/__init__.py index 0110315..8b3a5bb 100644 --- a/src/uipath/dev/__init__.py +++ b/src/uipath/dev/__init__.py @@ -164,7 +164,7 @@ async def handle_chat_input(self, event: Input.Submitted) -> None: ) ) current_run.add_event(msg_ev) - current_run.input_data = {"messages": [msg]} + current_run.input_data = {"messages": [msg.model_dump(by_alias=True)]} if current_run.mode == ExecutionMode.DEBUG: asyncio.create_task( diff --git a/src/uipath/dev/ui/panels/_json_schema.py b/src/uipath/dev/ui/panels/_json_schema.py index e9abd95..db7866f 100644 --- a/src/uipath/dev/ui/panels/_json_schema.py +++ b/src/uipath/dev/ui/panels/_json_schema.py @@ -9,8 +9,66 @@ def mock_json_from_schema(schema: dict[str, Any]) -> Any: - For primitives: returns a sensible example / default / enum[0]. - Handles oneOf/anyOf by choosing the first option. - Special handling for LangChain message types. + - Special handling for UiPath conversational agent input schemas. """ + def _is_uipath_conversational_input(s: dict[str, Any]) -> bool: + """Check if this schema represents a UiPath conversational agent input.""" + if s.get("type") != "object": + return False + props = s.get("properties", {}) + # Check for the characteristic fields of ConversationalAgentInput + has_messages = "messages" in props + has_user_settings = "userSettings" in props + + if not (has_messages and has_user_settings): + return False + + # Additional check: messages should be an array + messages_prop = props.get("messages", {}) + if messages_prop.get("type") != "array": + return False + + # Check if $defs contains UiPath message types + defs = s.get("$defs", {}) + uipath_types = [ + "UiPathConversationMessage", + "UiPathConversationContentPart", + "UiPathInlineValue", + ] + has_uipath_defs = any(t in defs for t in uipath_types) + + return has_uipath_defs + + def _mock_uipath_conversational_input() -> dict[str, Any]: + """Generate a user-friendly mock for UiPath conversational agent input.""" + return { + "messages": [ + { + "messageId": "msg-001", + "role": "user", + "contentParts": [ + { + "contentPartId": "part-001", + "mimeType": "text/plain", + "data": {"inline": "Hello, how can you help me today?"}, + } + ], + "createdAt": "2025-01-19T10:00:00Z", + "updatedAt": "2025-01-19T10:00:00Z", + } + ], + "userSettings": { + "name": "John Doe", + "email": "john.doe@example.com", + "role": "Software Engineer", + "department": "Engineering", + "company": "Acme Corp", + "country": "United States", + "timezone": "America/New_York", + }, + } + def _is_langchain_messages_array(sub_schema: dict[str, Any]) -> bool: """Check if this is a LangChain messages array.""" if sub_schema.get("type") != "array": @@ -110,6 +168,10 @@ def _mock_value( # 9) Fallback return None + # Check for UiPath conversational input schema first + if _is_uipath_conversational_input(schema): + return _mock_uipath_conversational_input() + # Top-level: if it's an object with properties, build a dict if schema.get("type") == "object": if "properties" not in schema: diff --git a/src/uipath/dev/ui/styles/terminal.tcss b/src/uipath/dev/ui/styles/terminal.tcss index 627883d..3e51879 100644 --- a/src/uipath/dev/ui/styles/terminal.tcss +++ b/src/uipath/dev/ui/styles/terminal.tcss @@ -217,7 +217,9 @@ SpanDetailsDisplay { .json-input { margin-top: 1; - height: auto; + margin-bottom: 3; + height: 100%; + overflow-y: auto; } .run-actions { diff --git a/uv.lock b/uv.lock index 6d3cd2f..6be23ff 100644 --- a/uv.lock +++ b/uv.lock @@ -1006,7 +1006,7 @@ wheels = [ [[package]] name = "uipath-dev" -version = "0.0.16" +version = "0.0.17" source = { editable = "." } dependencies = [ { name = "pyperclip" },