Skip to content

Commit 847541f

Browse files
committed
feat(status_interrupt): determine status based on err info
1 parent 63dcf96 commit 847541f

File tree

2 files changed

+57
-45
lines changed

2 files changed

+57
-45
lines changed

pyproject.toml

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
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"
77
dependencies = [
8-
"uipath>=2.1.65, <2.2.0",
9-
"langgraph>=0.5.0, <0.7.0",
10-
"langchain-core>=0.3.34",
11-
"langgraph-checkpoint-sqlite>=2.0.3",
12-
"langchain-community>=0.3.21",
13-
"langchain-openai>=0.3.3",
14-
"langchain>=0.3.4",
15-
"pydantic-settings>=2.6.0",
16-
"python-dotenv>=1.0.1",
17-
"httpx>=0.27.0",
18-
"openai>=1.65.5",
19-
"openinference-instrumentation-langchain>=0.1.50",
20-
"jsonschema-pydantic>=0.6",
8+
"uipath>=2.1.65, <2.2.0",
9+
"langgraph>=0.5.0, <0.7.0",
10+
"langchain-core>=0.3.34",
11+
"langgraph-checkpoint-sqlite>=2.0.3",
12+
"langchain-community>=0.3.21",
13+
"langchain-openai>=0.3.3",
14+
"langchain>=0.3.4",
15+
"pydantic-settings>=2.6.0",
16+
"python-dotenv>=1.0.1",
17+
"httpx>=0.27.0",
18+
"openai>=1.65.5",
19+
"openinference-instrumentation-langchain>=0.1.50",
20+
"jsonschema-pydantic>=0.6",
2121
]
2222
classifiers = [
23-
"Development Status :: 3 - Alpha",
24-
"Intended Audience :: Developers",
25-
"Topic :: Software Development :: Build Tools",
26-
"Programming Language :: Python :: 3.10",
27-
"Programming Language :: Python :: 3.11",
28-
"Programming Language :: Python :: 3.12",
23+
"Development Status :: 3 - Alpha",
24+
"Intended Audience :: Developers",
25+
"Topic :: Software Development :: Build Tools",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
2929
]
3030
maintainers = [
31-
{ name = "Marius Cosareanu", email = "marius.cosareanu@uipath.com" },
32-
{ name = "Cristian Pufu", email = "cristian.pufu@uipath.com" }
31+
{ name = "Marius Cosareanu", email = "marius.cosareanu@uipath.com" },
32+
{ name = "Cristian Pufu", email = "cristian.pufu@uipath.com" },
3333
]
3434

3535
[project.entry-points."uipath.middlewares"]
@@ -46,21 +46,19 @@ build-backend = "hatchling.build"
4646

4747
[dependency-groups]
4848
dev = [
49-
"mypy>=1.14.1",
50-
"ruff>=0.9.4",
51-
"pytest>=7.4.0",
52-
"pytest-cov>=4.1.0",
53-
"pytest-mock>=3.11.1",
54-
"pytest-asyncio>=1.0.0",
55-
"pre-commit>=4.1.0",
56-
"numpy>=1.24.0",
57-
"pytest_httpx>=0.35.0"
49+
"mypy>=1.14.1",
50+
"ruff>=0.9.4",
51+
"pytest>=7.4.0",
52+
"pytest-cov>=4.1.0",
53+
"pytest-mock>=3.11.1",
54+
"pytest-asyncio>=1.0.0",
55+
"pre-commit>=4.1.0",
56+
"numpy>=1.24.0",
57+
"pytest_httpx>=0.35.0",
5858
]
5959

6060
[project.optional-dependencies]
61-
langchain = [
62-
"uipath-langchain>=0.0.2"
63-
]
61+
langchain = ["uipath-langchain>=0.0.2"]
6462

6563
[tool.hatch.build.targets.wheel]
6664
packages = ["src/uipath_langchain"]
@@ -83,13 +81,8 @@ skip-magic-trailing-comma = false
8381
line-ending = "auto"
8482

8583
[tool.mypy]
86-
plugins = [
87-
"pydantic.mypy"
88-
]
89-
exclude = [
90-
"samples/.*",
91-
"testcases/.*"
92-
]
84+
plugins = ["pydantic.mypy"]
85+
exclude = ["samples/.*", "testcases/.*"]
9386

9487
follow_imports = "silent"
9588
warn_redundant_casts = true

src/uipath_langchain/_tracing/_oteladapter.py

Lines changed: 23 additions & 4 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,6 +164,15 @@ 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+
logger.debug(f"Determining status from error: {error}")
170+
if error and error.startswith("GraphInterrupt("):
171+
logger.debug(f"Status determined: {self.Status.INTERRUPTED}")
172+
return self.Status.INTERRUPTED
173+
return self.Status.ERROR
174+
return self.Status.SUCCESS
175+
164176
def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:
165177
"""Extracts, transforms, and maps attributes for a span."""
166178
if "Attributes" not in span_data:
@@ -206,6 +218,13 @@ def _process_span_attributes(self, span_data: Dict[str, Any]) -> Dict[str, Any]:
206218

207219
span_data["Attributes"] = json.dumps(processed_attributes)
208220

221+
# Determine status based on error information
222+
error = attributes.get("error") or attributes.get("exception.message")
223+
logger.debug(f"Span error info: {error}")
224+
status = self._determine_status(error)
225+
logger.debug(f"Determined status: {status}")
226+
span_data["Status"] = status
227+
209228
logger.debug(f"Transformed span: {span_data}")
210229
return span_data
211230

0 commit comments

Comments
 (0)