uipath-langchain 0.0.128__py3-none-any.whl → 0.0.129__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,9 +1,8 @@
1
1
  from typing import Any, Optional, Union
2
- from uuid import uuid4
3
2
 
4
3
  from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
5
4
  from langgraph.graph import StateGraph
6
- from uipath._cli._runtime._contracts import UiPathRuntimeContext, UiPathTraceContext
5
+ from uipath._cli._runtime._contracts import UiPathRuntimeContext
7
6
 
8
7
  from .._utils._graph import LangGraphConfig
9
8
 
@@ -20,149 +19,3 @@ class LangGraphRuntimeContext(UiPathRuntimeContext):
20
19
  memory: Optional[AsyncSqliteSaver] = None
21
20
  langsmith_tracing_enabled: Union[str, bool, None] = False
22
21
  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)
@@ -50,8 +50,6 @@ class LangGraphRuntime(UiPathBaseRuntime):
50
50
  """
51
51
  _instrument_traceable_attributes()
52
52
 
53
- await self.validate()
54
-
55
53
  if self.context.state_graph is None:
56
54
  return None
57
55
 
@@ -196,17 +194,6 @@ class LangGraphRuntime(UiPathBaseRuntime):
196
194
  async def validate(self) -> None:
197
195
  """Validate runtime inputs."""
198
196
  """Load and validate the graph configuration ."""
199
- try:
200
- if self.context.input:
201
- self.context.input_json = json.loads(self.context.input)
202
- except json.JSONDecodeError as e:
203
- raise LangGraphRuntimeError(
204
- "INPUT_INVALID_JSON",
205
- "Invalid JSON input",
206
- "The input data is not valid JSON.",
207
- UiPathErrorCategory.USER,
208
- ) from e
209
-
210
197
  if self.context.langgraph_config is None:
211
198
  self.context.langgraph_config = LangGraphConfig()
212
199
  if not self.context.langgraph_config.exists:
@@ -4,15 +4,13 @@ from typing import List, Optional
4
4
 
5
5
  from uipath._cli._evals._runtime import UiPathEvalContext, UiPathEvalRuntime
6
6
  from uipath._cli._runtime._contracts import (
7
- UiPathRuntimeContextBuilder,
8
7
  UiPathRuntimeFactory,
9
8
  )
9
+ from uipath._cli._utils._eval_set import EvalHelpers
10
10
  from uipath._cli.middlewares import MiddlewareResult
11
+ from uipath.eval._helpers import auto_discover_entrypoint
11
12
 
12
- from uipath_langchain._cli._runtime._context import (
13
- LangGraphRuntimeContext,
14
- LangGraphRuntimeContextBuilder,
15
- )
13
+ from uipath_langchain._cli._runtime._context import LangGraphRuntimeContext
16
14
  from uipath_langchain._cli._runtime._runtime import LangGraphRuntime
17
15
  from uipath_langchain._cli._utils._graph import LangGraphConfig
18
16
 
@@ -20,37 +18,44 @@ from uipath_langchain._cli._utils._graph import LangGraphConfig
20
18
  def langgraph_eval_middleware(
21
19
  entrypoint: Optional[str], eval_set: Optional[str], eval_ids: List[str], **kwargs
22
20
  ) -> 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
- )
21
+ # Add default env variables
22
+ env["UIPATH_REQUESTING_PRODUCT"] = "uipath-python-sdk"
23
+ env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
24
+
25
+ config = LangGraphConfig()
26
+ if not config.exists:
27
+ return MiddlewareResult(
28
+ should_continue=True
29
+ ) # Continue with normal flow if no langgraph.json
30
+
31
+ eval_context = UiPathEvalContext.with_defaults(**kwargs)
32
+ eval_context.eval_set = eval_set or EvalHelpers.auto_discover_eval_set()
33
+ eval_context.eval_ids = eval_ids
32
34
 
33
35
  try:
36
+ runtime_entrypoint = entrypoint or auto_discover_entrypoint()
37
+
38
+ def generate_runtime_context(
39
+ context_entrypoint: str, langgraph_config: LangGraphConfig, **context_kwargs
40
+ ) -> LangGraphRuntimeContext:
41
+ context = LangGraphRuntimeContext.with_defaults(**context_kwargs)
42
+ context.langgraph_config = langgraph_config
43
+ context.entrypoint = context_entrypoint
44
+ return context
45
+
34
46
  runtime_factory = UiPathRuntimeFactory(
35
- LangGraphRuntime, LangGraphRuntimeContext
47
+ LangGraphRuntime,
48
+ LangGraphRuntimeContext,
49
+ context_generator=lambda **context_kwargs: generate_runtime_context(
50
+ context_entrypoint=runtime_entrypoint,
51
+ langgraph_config=config,
52
+ **context_kwargs,
53
+ ),
36
54
  )
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
55
 
49
56
  async def execute():
50
- async with UiPathEvalRuntime[
51
- LangGraphRuntime, LangGraphRuntimeContext
52
- ].from_eval_context(
53
- factory=runtime_factory, context=generate_eval_context(context)
57
+ async with UiPathEvalRuntime.from_eval_context(
58
+ factory=runtime_factory, context=eval_context
54
59
  ) as eval_runtime:
55
60
  await eval_runtime.execute()
56
61
 
@@ -3,21 +3,20 @@ import os
3
3
  from os import environ as env
4
4
  from typing import Optional
5
5
 
6
- from dotenv import load_dotenv
7
6
  from uipath._cli.middlewares import MiddlewareResult
8
7
 
9
- from ._runtime._context import LangGraphRuntimeContextBuilder
10
8
  from ._runtime._exception import LangGraphRuntimeError
11
- from ._runtime._runtime import LangGraphRuntime
9
+ from ._runtime._runtime import ( # type: ignore[attr-defined]
10
+ LangGraphRuntime,
11
+ LangGraphRuntimeContext,
12
+ )
12
13
  from ._utils._graph import LangGraphConfig
13
14
 
14
- load_dotenv()
15
-
16
15
 
17
16
  def langgraph_run_middleware(
18
17
  entrypoint: Optional[str], input: Optional[str], resume: bool, **kwargs
19
18
  ) -> MiddlewareResult:
20
- """Middleware to handle langgraph execution"""
19
+ """Middleware to handle LangGraph execution"""
21
20
  config = LangGraphConfig()
22
21
  if not config.exists:
23
22
  return MiddlewareResult(
@@ -29,14 +28,11 @@ def langgraph_run_middleware(
29
28
  env["UIPATH_REQUESTING_PRODUCT"] = "uipath-python-sdk"
30
29
  env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
31
30
 
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()
31
+ context = LangGraphRuntimeContext.with_defaults(**kwargs)
32
+ context.langgraph_config = config
33
+ context.entrypoint = entrypoint
34
+ context.input = input
35
+ context.resume = resume
40
36
 
41
37
  async def execute():
42
38
  async with LangGraphRuntime.from_context(context) as runtime:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath-langchain
3
- Version: 0.0.128
3
+ Version: 0.0.129
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.44
28
+ Requires-Dist: uipath<2.2.0,>=2.1.46
29
29
  Provides-Extra: langchain
30
30
  Description-Content-Type: text/markdown
31
31
 
@@ -2,16 +2,16 @@ uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,
2
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
+ uipath_langchain/_cli/cli_eval.py,sha256=eGhvenAKJDdt9zIYWO7k01zJ7T1tGte7a6zz06iO6cw,2539
6
6
  uipath_langchain/_cli/cli_init.py,sha256=xhxJ8tuMSrVUNHvltgyPpOrvgMA-wq9shHeYYwvHILs,8199
7
7
  uipath_langchain/_cli/cli_new.py,sha256=dL8-Rri6u67ZZdbb4nT38A5xD_Q3fVnG0UK9VSeKaqg,2563
8
- uipath_langchain/_cli/cli_run.py,sha256=GJ8t1wZSRG644G5rL_u6GdPSKBI4Muj075Y9YlJSk3c,2202
9
- uipath_langchain/_cli/_runtime/_context.py,sha256=jY3CZY2gynJO19LOp8HK0qle7cJAUmiYIVFnpEga7K8,5800
8
+ uipath_langchain/_cli/cli_run.py,sha256=FT4ilVCBNSYllB-wS6__0E0fWKlrQEhO9N74wNHPffs,2056
9
+ uipath_langchain/_cli/_runtime/_context.py,sha256=yyzYJDmk2fkH4T5gm4cLGRyXtjLESrpzHBT9euqluTA,817
10
10
  uipath_langchain/_cli/_runtime/_conversation.py,sha256=S1KTx_q-La7ikPRT3nBcIp8t-J9CF0QB0DCduQIIB28,11149
11
11
  uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJs_xF0OQXCCOvbYM,546
12
12
  uipath_langchain/_cli/_runtime/_input.py,sha256=3IKrZR9xmxYg6l_1TbFpaLOWPDvK8d3nSKIHPGEEGzE,5715
13
13
  uipath_langchain/_cli/_runtime/_output.py,sha256=yJOZPWv2FRUJWv1NRs9JmpB4QMTDXu8jrxoaKrfJvzw,9078
14
- uipath_langchain/_cli/_runtime/_runtime.py,sha256=9X_8YEny238V1sTb4cjkpd6J69DYQWo6eYVH9kA9gEQ,15383
14
+ uipath_langchain/_cli/_runtime/_runtime.py,sha256=ai-r6cYp4YbJqGhxWGvL68BHtJGhYhAZF-MEhKT7ceY,14955
15
15
  uipath_langchain/_cli/_templates/langgraph.json.template,sha256=eeh391Gta_hoRgaNaZ58nW1LNvCVXA7hlAH6l7Veous,107
16
16
  uipath_langchain/_cli/_templates/main.py.template,sha256=nMJQIYPlRk90iANfNVpkJ2EQX20Dxsyq92-BucEz_UM,1189
17
17
  uipath_langchain/_cli/_utils/_graph.py,sha256=JPShHNl0UQvl4AdjLIqLpNt_JAjpWH9WWF22Gs47Xew,7445
@@ -33,8 +33,8 @@ uipath_langchain/tracers/_instrument_traceable.py,sha256=0e841zVzcPWjOGtmBx0GeHb
33
33
  uipath_langchain/tracers/_utils.py,sha256=JOT1tKMdvqjMDtj2WbmbOWMeMlTXBWavxWpogX7KlRA,1543
34
34
  uipath_langchain/vectorstores/__init__.py,sha256=w8qs1P548ud1aIcVA_QhBgf_jZDrRMK5Lono78yA8cs,114
35
35
  uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=TncIXG-YsUlO0R5ZYzWsM-Dj1SVCZbzmo2LraVxXelc,9559
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,,
36
+ uipath_langchain-0.0.129.dist-info/METADATA,sha256=w_AyKGzo76g4G8qXMmZfMiikhaB1-QMJ-qn7G-GDvwA,4235
37
+ uipath_langchain-0.0.129.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ uipath_langchain-0.0.129.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
39
+ uipath_langchain-0.0.129.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
40
+ uipath_langchain-0.0.129.dist-info/RECORD,,