uipath-langchain 0.0.127__py3-none-any.whl → 0.0.128__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uipath-langchain might be problematic. Click here for more details.

@@ -1,8 +1,9 @@
1
1
  from typing import Any, Optional, Union
2
+ from uuid import uuid4
2
3
 
3
4
  from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
4
5
  from langgraph.graph import StateGraph
5
- from uipath._cli._runtime._contracts import UiPathRuntimeContext
6
+ from uipath._cli._runtime._contracts import UiPathRuntimeContext, UiPathTraceContext
6
7
 
7
8
  from .._utils._graph import LangGraphConfig
8
9
 
@@ -19,3 +20,149 @@ class LangGraphRuntimeContext(UiPathRuntimeContext):
19
20
  memory: Optional[AsyncSqliteSaver] = None
20
21
  langsmith_tracing_enabled: Union[str, bool, None] = False
21
22
  resume_triggers_table: str = "__uipath_resume_triggers"
23
+
24
+
25
+ class LangGraphRuntimeContextBuilder:
26
+ """Builder class for LangGraphRuntimeContext following the builder pattern."""
27
+
28
+ def __init__(self):
29
+ self._kwargs = {}
30
+
31
+ def with_defaults(
32
+ self, config_path: Optional[str] = None, **kwargs
33
+ ) -> "LangGraphRuntimeContextBuilder":
34
+ """Apply default configuration similar to LangGraphRuntimeContext.from_config().
35
+
36
+ Args:
37
+ config_path: Path to the configuration file (defaults to UIPATH_CONFIG_PATH env var or "uipath.json")
38
+ **kwargs: Additional keyword arguments to pass to with_defaults
39
+
40
+ Returns:
41
+ Self for method chaining
42
+ """
43
+ from os import environ as env
44
+
45
+ resolved_config_path = config_path or env.get(
46
+ "UIPATH_CONFIG_PATH", "uipath.json"
47
+ )
48
+ self._kwargs["config_path"] = resolved_config_path
49
+
50
+ bool_map = {"true": True, "false": False}
51
+ tracing = env.get("UIPATH_TRACING_ENABLED", True)
52
+ if isinstance(tracing, str) and tracing.lower() in bool_map:
53
+ tracing = bool_map[tracing.lower()]
54
+
55
+ self._kwargs.update(
56
+ {
57
+ "job_id": env.get("UIPATH_JOB_KEY"),
58
+ "execution_id": env.get("UIPATH_JOB_KEY"),
59
+ "trace_id": env.get("UIPATH_TRACE_ID"),
60
+ "tracing_enabled": tracing,
61
+ "logs_min_level": env.get("LOG_LEVEL", "INFO"),
62
+ "langsmith_tracing_enabled": env.get("LANGSMITH_TRACING", False),
63
+ **kwargs, # Allow overriding defaults with provided kwargs
64
+ }
65
+ )
66
+
67
+ self._kwargs["trace_context"] = UiPathTraceContext(
68
+ trace_id=env.get("UIPATH_TRACE_ID"),
69
+ parent_span_id=env.get("UIPATH_PARENT_SPAN_ID"),
70
+ root_span_id=env.get("UIPATH_ROOT_SPAN_ID"),
71
+ enabled=tracing,
72
+ job_id=env.get("UIPATH_JOB_KEY"),
73
+ org_id=env.get("UIPATH_ORGANIZATION_ID"),
74
+ tenant_id=env.get("UIPATH_TENANT_ID"),
75
+ process_key=env.get("UIPATH_PROCESS_UUID"),
76
+ folder_key=env.get("UIPATH_FOLDER_KEY"),
77
+ reference_id=env.get("UIPATH_JOB_KEY") or str(uuid4()),
78
+ )
79
+
80
+ return self
81
+
82
+ def with_entrypoint(
83
+ self, entrypoint: Optional[str]
84
+ ) -> "LangGraphRuntimeContextBuilder":
85
+ """Set the entrypoint for the runtime context.
86
+
87
+ Args:
88
+ entrypoint: The entrypoint to execute
89
+
90
+ Returns:
91
+ Self for method chaining
92
+ """
93
+ if entrypoint is not None:
94
+ self._kwargs["entrypoint"] = entrypoint
95
+ return self
96
+
97
+ def with_input(
98
+ self, input_data: Optional[str] = None, input_file: Optional[str] = None
99
+ ) -> "LangGraphRuntimeContextBuilder":
100
+ """Set the input data for the runtime context.
101
+
102
+ Args:
103
+ input_data: The input data as a string
104
+ input_file: Path to the input file
105
+
106
+ Returns:
107
+ Self for method chaining
108
+ """
109
+ if input_data is not None:
110
+ self._kwargs["input"] = input_data
111
+ if input_file is not None:
112
+ self._kwargs["input_file"] = input_file
113
+ return self
114
+
115
+ def with_resume(self, enable: bool = True) -> "LangGraphRuntimeContextBuilder":
116
+ """Enable or disable resume mode for the runtime context.
117
+
118
+ Args:
119
+ enable: Whether to enable resume mode (defaults to True)
120
+
121
+ Returns:
122
+ Self for method chaining
123
+ """
124
+ self._kwargs["resume"] = enable
125
+ return self
126
+
127
+ def with_langgraph_config(
128
+ self, config: LangGraphConfig
129
+ ) -> "LangGraphRuntimeContextBuilder":
130
+ """Set the LangGraph configuration.
131
+
132
+ Args:
133
+ config: The LangGraph configuration
134
+
135
+ Returns:
136
+ Self for method chaining
137
+ """
138
+ self._kwargs["langgraph_config"] = config
139
+ return self
140
+
141
+ def mark_eval_run(self, enable: bool = True) -> "LangGraphRuntimeContextBuilder":
142
+ """Mark this as an evaluation run.
143
+
144
+ Args:
145
+ enable: Whether this is an eval run (defaults to True)
146
+
147
+ Returns:
148
+ Self for method chaining
149
+ """
150
+ self._kwargs["is_eval_run"] = enable
151
+ return self
152
+
153
+ def build(self) -> "LangGraphRuntimeContext":
154
+ """Build and return the LangGraphRuntimeContext instance.
155
+
156
+ Returns:
157
+ A configured LangGraphRuntimeContext instance
158
+ """
159
+ config_path = self._kwargs.pop("config_path", None)
160
+ if config_path:
161
+ # Create context from config first, then update with any additional kwargs
162
+ context = LangGraphRuntimeContext.from_config(config_path)
163
+ for key, value in self._kwargs.items():
164
+ if hasattr(context, key):
165
+ setattr(context, key, value)
166
+ return context
167
+ else:
168
+ return LangGraphRuntimeContext(**self._kwargs)
@@ -0,0 +1,63 @@
1
+ import asyncio
2
+ from os import environ as env
3
+ from typing import List, Optional
4
+
5
+ from uipath._cli._evals._runtime import UiPathEvalContext, UiPathEvalRuntime
6
+ from uipath._cli._runtime._contracts import (
7
+ UiPathRuntimeContextBuilder,
8
+ UiPathRuntimeFactory,
9
+ )
10
+ from uipath._cli.middlewares import MiddlewareResult
11
+
12
+ from uipath_langchain._cli._runtime._context import (
13
+ LangGraphRuntimeContext,
14
+ LangGraphRuntimeContextBuilder,
15
+ )
16
+ from uipath_langchain._cli._runtime._runtime import LangGraphRuntime
17
+ from uipath_langchain._cli._utils._graph import LangGraphConfig
18
+
19
+
20
+ def langgraph_eval_middleware(
21
+ entrypoint: Optional[str], eval_set: Optional[str], eval_ids: List[str], **kwargs
22
+ ) -> MiddlewareResult:
23
+ def generate_eval_context(
24
+ runtime_context: LangGraphRuntimeContext,
25
+ ) -> UiPathEvalContext[LangGraphRuntimeContext]:
26
+ base_context = UiPathRuntimeContextBuilder().with_defaults().build()
27
+ return UiPathEvalContext(
28
+ runtime_context=runtime_context,
29
+ **kwargs,
30
+ **base_context.model_dump(),
31
+ )
32
+
33
+ try:
34
+ runtime_factory = UiPathRuntimeFactory(
35
+ LangGraphRuntime, LangGraphRuntimeContext
36
+ )
37
+ # Add default env variables
38
+ env["UIPATH_REQUESTING_PRODUCT"] = "uipath-python-sdk"
39
+ env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
40
+
41
+ context = (
42
+ LangGraphRuntimeContextBuilder()
43
+ .with_defaults(**kwargs)
44
+ .with_langgraph_config(LangGraphConfig())
45
+ .with_entrypoint(entrypoint)
46
+ .mark_eval_run()
47
+ ).build()
48
+
49
+ async def execute():
50
+ async with UiPathEvalRuntime[
51
+ LangGraphRuntime, LangGraphRuntimeContext
52
+ ].from_eval_context(
53
+ factory=runtime_factory, context=generate_eval_context(context)
54
+ ) as eval_runtime:
55
+ await eval_runtime.execute()
56
+
57
+ asyncio.run(execute())
58
+ return MiddlewareResult(should_continue=False)
59
+
60
+ except Exception as e:
61
+ return MiddlewareResult(
62
+ should_continue=False, error_message=f"Error running evaluation: {str(e)}"
63
+ )
@@ -4,10 +4,9 @@ from os import environ as env
4
4
  from typing import Optional
5
5
 
6
6
  from dotenv import load_dotenv
7
- from uipath._cli._runtime._contracts import UiPathTraceContext
8
7
  from uipath._cli.middlewares import MiddlewareResult
9
8
 
10
- from ._runtime._context import LangGraphRuntimeContext
9
+ from ._runtime._context import LangGraphRuntimeContextBuilder
11
10
  from ._runtime._exception import LangGraphRuntimeError
12
11
  from ._runtime._runtime import LangGraphRuntime
13
12
  from ._utils._graph import LangGraphConfig
@@ -26,45 +25,20 @@ def langgraph_run_middleware(
26
25
  ) # Continue with normal flow if no langgraph.json
27
26
 
28
27
  try:
29
- bool_map = {"true": True, "false": False}
30
- tracing = env.get("UIPATH_TRACING_ENABLED", True)
31
- if isinstance(tracing, str) and tracing.lower() in bool_map:
32
- tracing = bool_map[tracing.lower()]
28
+ # Add default env variables
29
+ env["UIPATH_REQUESTING_PRODUCT"] = "uipath-python-sdk"
30
+ env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
33
31
 
34
- async def execute():
35
- context: LangGraphRuntimeContext = LangGraphRuntimeContext.from_config(
36
- env.get("UIPATH_CONFIG_PATH", "uipath.json"), **kwargs
37
- )
38
- context.entrypoint = entrypoint
39
- context.input = input
40
- context.resume = resume
41
- context.langgraph_config = config
42
- context.debug = kwargs.get("debug", False)
43
- context.logs_min_level = env.get("LOG_LEVEL", "INFO")
44
- context.job_id = env.get("UIPATH_JOB_KEY", None)
45
- context.execution_id = env.get("UIPATH_JOB_KEY", None)
46
- context.trace_id = env.get("UIPATH_TRACE_ID")
47
- context.is_eval_run = kwargs.get("is_eval_run", False)
48
- context.tracing_enabled = tracing
49
- context.input_file = kwargs.get("input_file", None)
50
- context.execution_output_file = kwargs.get("execution_output_file", None)
51
- context.trace_context = UiPathTraceContext(
52
- enabled=tracing,
53
- trace_id=env.get("UIPATH_TRACE_ID"),
54
- parent_span_id=env.get("UIPATH_PARENT_SPAN_ID"),
55
- root_span_id=env.get("UIPATH_ROOT_SPAN_ID"),
56
- job_id=env.get("UIPATH_JOB_KEY"),
57
- org_id=env.get("UIPATH_ORGANIZATION_ID"),
58
- tenant_id=env.get("UIPATH_TENANT_ID"),
59
- process_key=env.get("UIPATH_PROCESS_UUID"),
60
- folder_key=env.get("UIPATH_FOLDER_KEY"),
61
- )
62
- context.langsmith_tracing_enabled = env.get("LANGSMITH_TRACING", False)
63
-
64
- # Add default env variables
65
- env["UIPATH_REQUESTING_PRODUCT"] = "uipath-python-sdk"
66
- env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
32
+ context = (
33
+ LangGraphRuntimeContextBuilder()
34
+ .with_defaults(**kwargs)
35
+ .with_langgraph_config(config)
36
+ .with_entrypoint(entrypoint)
37
+ .with_input(input_data=input, input_file=kwargs.get("input_file"))
38
+ .with_resume(resume)
39
+ ).build()
67
40
 
41
+ async def execute():
68
42
  async with LangGraphRuntime.from_context(context) as runtime:
69
43
  if context.resume is False and context.job_id is None:
70
44
  # Delete the previous graph state file at debug time
@@ -1,6 +1,7 @@
1
1
  from uipath._cli.middlewares import Middlewares
2
2
 
3
3
  from ._cli.cli_dev import langgraph_dev_middleware
4
+ from ._cli.cli_eval import langgraph_eval_middleware
4
5
  from ._cli.cli_init import langgraph_init_middleware
5
6
  from ._cli.cli_new import langgraph_new_middleware
6
7
  from ._cli.cli_run import langgraph_run_middleware
@@ -12,3 +13,4 @@ def register_middleware():
12
13
  Middlewares.register("run", langgraph_run_middleware)
13
14
  Middlewares.register("new", langgraph_new_middleware)
14
15
  Middlewares.register("dev", langgraph_dev_middleware)
16
+ Middlewares.register("eval", langgraph_eval_middleware)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath-langchain
3
- Version: 0.0.127
3
+ Version: 0.0.128
4
4
  Summary: UiPath Langchain
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-langchain-python
@@ -25,7 +25,7 @@ Requires-Dist: openai>=1.65.5
25
25
  Requires-Dist: openinference-instrumentation-langchain>=0.1.50
26
26
  Requires-Dist: pydantic-settings>=2.6.0
27
27
  Requires-Dist: python-dotenv>=1.0.1
28
- Requires-Dist: uipath<2.2.0,>=2.1.41
28
+ Requires-Dist: uipath<2.2.0,>=2.1.44
29
29
  Provides-Extra: langchain
30
30
  Description-Content-Type: text/markdown
31
31
 
@@ -1,11 +1,12 @@
1
1
  uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,80
2
- uipath_langchain/middlewares.py,sha256=EOWVTr52SFLEf5lzGAvcDN2qbtPsy4_EsFoXlV-cqdY,618
2
+ uipath_langchain/middlewares.py,sha256=6ljfbtWekrYc5G9KWDLSaViJ1DVIaNM-4qeB1BfHywE,731
3
3
  uipath_langchain/_cli/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
4
4
  uipath_langchain/_cli/cli_dev.py,sha256=VlI8qgCw-63I97tp_9lbXs-CVcNSjpd2sC13YNZAIuU,1401
5
+ uipath_langchain/_cli/cli_eval.py,sha256=iAXiRuX_IYwQVNC9x-btcqx0YNgCVNCpYRu8ZaQ_glo,2168
5
6
  uipath_langchain/_cli/cli_init.py,sha256=xhxJ8tuMSrVUNHvltgyPpOrvgMA-wq9shHeYYwvHILs,8199
6
7
  uipath_langchain/_cli/cli_new.py,sha256=dL8-Rri6u67ZZdbb4nT38A5xD_Q3fVnG0UK9VSeKaqg,2563
7
- uipath_langchain/_cli/cli_run.py,sha256=R-cUi3lO3Qd4ysTXD7PW4sa1RsB427v_Y6xUQxWijfQ,3725
8
- uipath_langchain/_cli/_runtime/_context.py,sha256=yyzYJDmk2fkH4T5gm4cLGRyXtjLESrpzHBT9euqluTA,817
8
+ uipath_langchain/_cli/cli_run.py,sha256=GJ8t1wZSRG644G5rL_u6GdPSKBI4Muj075Y9YlJSk3c,2202
9
+ uipath_langchain/_cli/_runtime/_context.py,sha256=jY3CZY2gynJO19LOp8HK0qle7cJAUmiYIVFnpEga7K8,5800
9
10
  uipath_langchain/_cli/_runtime/_conversation.py,sha256=S1KTx_q-La7ikPRT3nBcIp8t-J9CF0QB0DCduQIIB28,11149
10
11
  uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJs_xF0OQXCCOvbYM,546
11
12
  uipath_langchain/_cli/_runtime/_input.py,sha256=3IKrZR9xmxYg6l_1TbFpaLOWPDvK8d3nSKIHPGEEGzE,5715
@@ -32,8 +33,8 @@ uipath_langchain/tracers/_instrument_traceable.py,sha256=0e841zVzcPWjOGtmBx0GeHb
32
33
  uipath_langchain/tracers/_utils.py,sha256=JOT1tKMdvqjMDtj2WbmbOWMeMlTXBWavxWpogX7KlRA,1543
33
34
  uipath_langchain/vectorstores/__init__.py,sha256=w8qs1P548ud1aIcVA_QhBgf_jZDrRMK5Lono78yA8cs,114
34
35
  uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=TncIXG-YsUlO0R5ZYzWsM-Dj1SVCZbzmo2LraVxXelc,9559
35
- uipath_langchain-0.0.127.dist-info/METADATA,sha256=-pkEhqb6QF5H9pH-3TVabaJmMZcsWrd-sAH6EMlPhpg,4235
36
- uipath_langchain-0.0.127.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
- uipath_langchain-0.0.127.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
38
- uipath_langchain-0.0.127.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
39
- uipath_langchain-0.0.127.dist-info/RECORD,,
36
+ uipath_langchain-0.0.128.dist-info/METADATA,sha256=j7n4C35F6bOqi7JE4_X-50klv2NTZeO1ov-ab94JEdI,4235
37
+ uipath_langchain-0.0.128.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ uipath_langchain-0.0.128.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
39
+ uipath_langchain-0.0.128.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
40
+ uipath_langchain-0.0.128.dist-info/RECORD,,