Skip to content

Commit 560ece2

Browse files
authored
Merge pull request #153 from UiPath/feat/dev_terminal
feat: dev terminal
2 parents 467793d + 56aa64a commit 560ece2

File tree

5 files changed

+1826
-1677
lines changed

5 files changed

+1826
-1677
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.0.123"
3+
version = "0.0.124"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
77
dependencies = [
8-
"uipath>=2.1.10, <2.2.0",
8+
"uipath>=2.1.30, <2.2.0",
99
"langgraph>=0.5.0, <0.7.0",
1010
"langchain-core>=0.3.34",
1111
"langgraph-checkpoint-sqlite>=2.0.3",
@@ -16,6 +16,7 @@ dependencies = [
1616
"python-dotenv>=1.0.1",
1717
"httpx>=0.27.0",
1818
"openai>=1.65.5",
19+
"openinference-instrumentation-langchain>=0.1.50",
1920
]
2021
classifiers = [
2122
"Development Status :: 3 - Alpha",

src/uipath_langchain/_cli/_runtime/_runtime.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from ..._utils import _instrument_traceable_attributes
2020
from ...tracers import AsyncUiPathTracer
21+
from .._utils._graph import LangGraphConfig
2122
from ._context import LangGraphRuntimeContext
2223
from ._exception import LangGraphRuntimeError
2324
from ._input import LangGraphInputProcessor
@@ -190,12 +191,14 @@ async def validate(self) -> None:
190191
) from e
191192

192193
if self.context.langgraph_config is None:
193-
raise LangGraphRuntimeError(
194-
"CONFIG_MISSING",
195-
"Invalid configuration",
196-
"Failed to load configuration",
197-
UiPathErrorCategory.DEPLOYMENT,
198-
)
194+
self.context.langgraph_config = LangGraphConfig()
195+
if not self.context.langgraph_config.exists:
196+
raise LangGraphRuntimeError(
197+
"CONFIG_MISSING",
198+
"Invalid configuration",
199+
"Failed to load configuration",
200+
UiPathErrorCategory.DEPLOYMENT,
201+
)
199202

200203
try:
201204
self.context.langgraph_config.load_config()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import asyncio
2+
from typing import Optional
3+
4+
from openinference.instrumentation.langchain import (
5+
LangChainInstrumentor,
6+
get_current_span,
7+
)
8+
from uipath._cli._dev._terminal import UiPathDevTerminal
9+
from uipath._cli._runtime._contracts import UiPathRuntimeFactory
10+
from uipath._cli._utils._console import ConsoleLogger
11+
from uipath._cli.middlewares import MiddlewareResult
12+
13+
from ._runtime._context import LangGraphRuntimeContext
14+
from ._runtime._runtime import LangGraphRuntime
15+
16+
console = ConsoleLogger()
17+
18+
19+
def langgraph_dev_middleware(interface: Optional[str]) -> MiddlewareResult:
20+
"""Middleware to launch the developer terminal"""
21+
22+
try:
23+
if interface == "terminal":
24+
runtime_factory = UiPathRuntimeFactory(
25+
LangGraphRuntime, LangGraphRuntimeContext
26+
)
27+
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
28+
app = UiPathDevTerminal(runtime_factory)
29+
asyncio.run(app.run_async())
30+
else:
31+
console.error(f"Unknown interface: {interface}")
32+
except KeyboardInterrupt:
33+
console.info("Debug session interrupted by user")
34+
except Exception as e:
35+
console.error(f"Error occurred: {e}")
36+
return MiddlewareResult(
37+
should_continue=False,
38+
should_include_stacktrace=True,
39+
)
40+
41+
return MiddlewareResult(should_continue=False)

src/uipath_langchain/middlewares.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from uipath._cli.middlewares import Middlewares
22

3+
from ._cli.cli_dev import langgraph_dev_middleware
34
from ._cli.cli_init import langgraph_init_middleware
45
from ._cli.cli_new import langgraph_new_middleware
56
from ._cli.cli_run import langgraph_run_middleware
@@ -10,3 +11,4 @@ def register_middleware():
1011
Middlewares.register("init", langgraph_init_middleware)
1112
Middlewares.register("run", langgraph_run_middleware)
1213
Middlewares.register("new", langgraph_new_middleware)
14+
Middlewares.register("dev", langgraph_dev_middleware)

0 commit comments

Comments
 (0)