Skip to content

Commit c813a66

Browse files
authored
Merge pull request #203 from UiPath/feat/status_interrupt
feat(status_interrupt): determine status based on err info
2 parents 63dcf96 + e69f7e1 commit c813a66

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

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-langchain"
3-
version = "0.0.136"
3+
version = "0.0.137"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"

src/uipath_langchain/_tracing/_oteladapter.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import json
22
import logging
3-
from typing import Any, Dict, List
3+
from typing import Any, Dict, List, Optional
44

5-
from opentelemetry.sdk.trace.export import (
6-
SpanExportResult,
7-
)
5+
from opentelemetry.sdk.trace.export import SpanExportResult
86
from uipath.tracing import LlmOpsHttpExporter
97

108
logger = logging.getLogger(__name__)
@@ -71,6 +69,11 @@ class LangChainExporter(LlmOpsHttpExporter):
7169
# Add more mappings as needed
7270
}
7371

72+
class Status:
73+
SUCCESS = 1
74+
ERROR = 2
75+
INTERRUPTED = 3
76+
7477
def __init__(self, *args: Any, **kwargs: Any) -> None:
7578
super().__init__(*args, **kwargs)
7679

@@ -161,13 +164,18 @@ def _map_tool_call_attributes(self, attributes: Dict[str, Any]) -> Dict[str, Any
161164

162165
return result
163166

167+
def _determine_status(self, error: Optional[str]) -> int:
168+
if error:
169+
if error and error.startswith("GraphInterrupt("):
170+
return self.Status.INTERRUPTED
171+
return self.Status.ERROR
172+
return self.Status.SUCCESS
173+
164174
def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:
165175
"""Extracts, transforms, and maps attributes for a span."""
166176
if "Attributes" not in span_data:
167177
return span_data
168178

169-
logger.debug(f"Processing span: {span_data}")
170-
171179
attributes_val = span_data["Attributes"]
172180
if isinstance(attributes_val, str):
173181
try:
@@ -206,7 +214,11 @@ def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:
206214

207215
span_data["Attributes"] = json.dumps(processed_attributes)
208216

209-
logger.debug(f"Transformed span: {span_data}")
217+
# Determine status based on error information
218+
error = attributes.get("error") or attributes.get("exception.message")
219+
status = self._determine_status(error)
220+
span_data["Status"] = status
221+
210222
return span_data
211223

212224
def _send_with_retries(

0 commit comments

Comments
 (0)