-
Notifications
You must be signed in to change notification settings - Fork 29
feat: improve hitl details #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,8 @@ | |
|
|
||
| from langchain_core.messages import AIMessage, AnyMessage, BaseMessage, ToolMessage | ||
| from langgraph.types import Command, interrupt | ||
| from uipath.platform.common import CreateEscalation | ||
| from uipath._utils import UiPathUrl | ||
| from uipath.platform.common import CreateEscalation, UiPathConfig | ||
| from uipath.platform.guardrails import ( | ||
| BaseGuardrail, | ||
| GuardrailScope, | ||
|
|
@@ -76,10 +77,13 @@ async def _node( | |
| # Validate message count based on execution stage | ||
| _validate_message_count(state, execution_stage) | ||
|
|
||
| (redirect_url, tenant_name) = _get_agent_execution_viewer_url() | ||
| # Build base data dictionary with common fields | ||
| data: Dict[str, Any] = { | ||
| "GuardrailName": guardrail.name, | ||
| "GuardrailDescription": guardrail.description, | ||
| "TenantName": tenant_name, | ||
| "AgentTrace": redirect_url, | ||
| "Component": scope.name.lower(), | ||
| "ExecutionStage": _execution_stage_to_string(execution_stage), | ||
| "GuardrailResult": state.guardrail_validation_result, | ||
|
|
@@ -624,3 +628,40 @@ def _execution_stage_to_string( | |
| if execution_stage == ExecutionStage.PRE_EXECUTION: | ||
| return "PreExecution" | ||
| return "PostExecution" | ||
|
|
||
|
|
||
| def _get_agent_execution_viewer_url() -> tuple[str, str]: | ||
| """Generate the agent execution viewer URL based on execution context. | ||
|
|
||
| Args: | ||
| cloud_base_url: Optional cloud base URL. If not provided, will be extracted from environment. | ||
|
||
|
|
||
| Returns: | ||
| The constructed viewer URL for the agent execution. | ||
|
|
||
| Note: | ||
|
||
| Currently uses hardcoded values for agentId and packageVersion. | ||
| These should be made configurable in the future. | ||
| """ | ||
| cloud_base_url = UiPathConfig.base_url | ||
| uiPath_Url = UiPathUrl(cloud_base_url) | ||
| tenant_name = uiPath_Url.tenant_name | ||
| organization_id = UiPathConfig.organization_id | ||
| agent_id = UiPathConfig.project_id | ||
|
|
||
| # Route to appropriate URL based on source | ||
| if UiPathConfig.is_studio_project: | ||
| return ( | ||
| f"{uiPath_Url.base_url}/{organization_id}/studio_/designer/{agent_id}", | ||
| tenant_name, | ||
| ) | ||
| else: | ||
| execution_folder_id = UiPathConfig.folder_key | ||
| process_uuid = UiPathConfig.process_uuid | ||
| trace_id = UiPathConfig.trace_id | ||
| package_version = UiPathConfig.process_version | ||
|
|
||
| return ( | ||
| f"{uiPath_Url.base_url}/{organization_id}/agents_/deployed/{execution_folder_id}/{process_uuid}/{agent_id}/{package_version}/traces/{trace_id}", | ||
| tenant_name, | ||
| ) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have 2 different functions for url and tenant name? Currently it's a bit hidden that this func returns the tenant name too