uipath-langchain 0.0.85__py3-none-any.whl → 0.0.87__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.

Files changed (30) hide show
  1. uipath_langchain/_cli/_runtime/_context.py +1 -1
  2. uipath_langchain/_cli/_runtime/_escalation.py +3 -3
  3. uipath_langchain/_cli/_runtime/_exception.py +1 -1
  4. uipath_langchain/_cli/_runtime/_input.py +3 -3
  5. uipath_langchain/_cli/_runtime/_output.py +34 -11
  6. uipath_langchain/_cli/_runtime/_runtime.py +1 -1
  7. uipath_langchain/_cli/cli_init.py +2 -2
  8. uipath_langchain/_cli/cli_run.py +2 -2
  9. uipath_langchain/middlewares.py +1 -1
  10. uipath_langchain/retrievers/context_grounding_retriever.py +30 -4
  11. uipath_langchain/tracers/AsyncUiPathTracer.py +2 -2
  12. uipath_langchain/tracers/UiPathTracer.py +1 -1
  13. uipath_langchain/tracers/_events.py +33 -33
  14. uipath_langchain/tracers/_instrument_traceable.py +285 -285
  15. uipath_langchain/tracers/_utils.py +52 -52
  16. uipath_langchain/utils/__init__.py +3 -0
  17. uipath_langchain/utils/_request_mixin.py +488 -0
  18. uipath_langchain/utils/_settings.py +91 -0
  19. uipath_langchain/utils/_sleep_policy.py +41 -0
  20. uipath_langchain/vectorstores/context_grounding_vectorstore.py +265 -0
  21. uipath_langchain-0.0.87.dist-info/METADATA +137 -0
  22. uipath_langchain-0.0.87.dist-info/RECORD +40 -0
  23. {uipath_langchain-0.0.85.dist-info → uipath_langchain-0.0.87.dist-info}/entry_points.txt +1 -1
  24. uipath_langchain-0.0.87.dist-info/licenses/LICENSE +21 -0
  25. uipath_langchain/_utils/tests/cached_embeddings/text-embedding-3-large5034ec3c-85c9-54b8-ac89-5e0cbcf99e3b +0 -3
  26. uipath_langchain/_utils/tests/cached_embeddings/text-embedding-3-largec48857ed-1302-5954-9e24-69fa9b45e457 +0 -3
  27. uipath_langchain/_utils/tests/tests_uipath_cache.db +0 -3
  28. uipath_langchain-0.0.85.dist-info/METADATA +0 -29
  29. uipath_langchain-0.0.85.dist-info/RECORD +0 -37
  30. {uipath_langchain-0.0.85.dist-info → uipath_langchain-0.0.87.dist-info}/WHEEL +0 -0
@@ -2,7 +2,7 @@ from typing import Any, Optional, Union
2
2
 
3
3
  from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
4
4
  from langgraph.graph import StateGraph
5
- from uipath_sdk._cli._runtime._contracts import UiPathRuntimeContext
5
+ from uipath._cli._runtime._contracts import UiPathRuntimeContext
6
6
 
7
7
  from .._utils._graph import LangGraphConfig
8
8
 
@@ -3,8 +3,8 @@ import logging
3
3
  from pathlib import Path
4
4
  from typing import Any, Dict, Optional, Union
5
5
 
6
- from uipath_sdk import UiPathSDK
7
- from uipath_sdk._models.actions import Action
6
+ from uipath import UiPath
7
+ from uipath._models.actions import Action
8
8
 
9
9
  logger = logging.getLogger(__name__)
10
10
 
@@ -230,7 +230,7 @@ class Escalation:
230
230
  return None
231
231
 
232
232
  try:
233
- uipath = UiPathSDK()
233
+ uipath = UiPath()
234
234
  action = uipath.actions.create(
235
235
  title=self._config.get("title", "Default escalation"),
236
236
  app_name=self._config.get("appName"),
@@ -1,6 +1,6 @@
1
1
  from typing import Optional
2
2
 
3
- from uipath_sdk._cli._runtime._contracts import UiPathErrorCategory, UiPathRuntimeError
3
+ from uipath._cli._runtime._contracts import UiPathErrorCategory, UiPathRuntimeError
4
4
 
5
5
 
6
6
  class LangGraphRuntimeError(UiPathRuntimeError):
@@ -3,8 +3,8 @@ import logging
3
3
  from typing import Any, Optional, cast
4
4
 
5
5
  from langgraph.types import Command
6
- from uipath_sdk import UiPathSDK
7
- from uipath_sdk._cli._runtime._contracts import (
6
+ from uipath import UiPath
7
+ from uipath._cli._runtime._contracts import (
8
8
  UiPathErrorCategory,
9
9
  UiPathResumeTriggerType,
10
10
  UiPathRuntimeStatus,
@@ -39,7 +39,7 @@ class LangGraphInputProcessor:
39
39
  """
40
40
  self.context = context
41
41
  self.escalation = Escalation(self.context.config_path)
42
- self.uipath = UiPathSDK()
42
+ self.uipath = UiPath()
43
43
 
44
44
  async def process(self) -> Any:
45
45
  """
@@ -6,8 +6,8 @@ from functools import cached_property
6
6
  from typing import Any, Dict, Optional, Union, cast
7
7
 
8
8
  from langgraph.types import Interrupt, StateSnapshot
9
- from uipath_sdk import UiPathSDK
10
- from uipath_sdk._cli._runtime._contracts import (
9
+ from uipath import UiPath
10
+ from uipath._cli._runtime._contracts import (
11
11
  UiPathApiTrigger,
12
12
  UiPathErrorCategory,
13
13
  UiPathResumeTrigger,
@@ -15,8 +15,8 @@ from uipath_sdk._cli._runtime._contracts import (
15
15
  UiPathRuntimeResult,
16
16
  UiPathRuntimeStatus,
17
17
  )
18
- from uipath_sdk._models import CreateAction, InvokeProcess, WaitAction, WaitJob
19
- from uipath_sdk._models.actions import Action
18
+ from uipath._models import CreateAction, InvokeProcess, WaitAction, WaitJob
19
+ from uipath._models.actions import Action
20
20
 
21
21
  from ._context import LangGraphRuntimeContext
22
22
  from ._escalation import Escalation
@@ -145,11 +145,9 @@ class LangGraphOutputProcessor:
145
145
  try:
146
146
  if self.context.output is None:
147
147
  return {}
148
- if hasattr(self.context.output, "dict"):
149
- return self.context.output.dict()
150
- elif hasattr(self.context.output, "to_dict"):
151
- return self.context.output.to_dict()
152
- return dict(self.context.output)
148
+
149
+ return self._serialize_object(self.context.output)
150
+
153
151
  except Exception as e:
154
152
  raise LangGraphRuntimeError(
155
153
  "OUTPUT_SERIALIZATION_FAILED",
@@ -158,6 +156,31 @@ class LangGraphOutputProcessor:
158
156
  UiPathErrorCategory.SYSTEM,
159
157
  ) from e
160
158
 
159
+ def _serialize_object(self, obj):
160
+ """Recursively serializes an object and all its nested components."""
161
+ # Handle Pydantic models
162
+ if hasattr(obj, "dict"):
163
+ return self._serialize_object(obj.dict())
164
+ elif hasattr(obj, "model_dump"):
165
+ return self._serialize_object(obj.model_dump(by_alias=True))
166
+ elif hasattr(obj, "to_dict"):
167
+ return self._serialize_object(obj.to_dict())
168
+ # Handle dictionaries
169
+ elif isinstance(obj, dict):
170
+ return {k: self._serialize_object(v) for k, v in obj.items()}
171
+ # Handle lists
172
+ elif isinstance(obj, list):
173
+ return [self._serialize_object(item) for item in obj]
174
+ # Handle other iterable objects (convert to dict first)
175
+ elif hasattr(obj, "__iter__") and not isinstance(obj, (str, bytes)):
176
+ try:
177
+ return self._serialize_object(dict(obj))
178
+ except (TypeError, ValueError):
179
+ return obj
180
+ # Return primitive types as is
181
+ else:
182
+ return obj
183
+
161
184
  async def process(self) -> UiPathRuntimeResult:
162
185
  """
163
186
  Process the output and prepare the final execution result.
@@ -233,7 +256,7 @@ class LangGraphOutputProcessor:
233
256
  )
234
257
  return
235
258
  if isinstance(self.interrupt_info, InterruptInfo):
236
- uipath_sdk = UiPathSDK()
259
+ uipath_sdk = UiPath()
237
260
  if self.interrupt_info.type is UiPathResumeTriggerType.JOB:
238
261
  if isinstance(self.interrupt_value, InvokeProcess):
239
262
  job = await uipath_sdk.processes.invoke_async(
@@ -243,7 +266,7 @@ class LangGraphOutputProcessor:
243
266
  if job:
244
267
  self._resume_trigger = UiPathResumeTrigger(
245
268
  trigger_type=UiPathResumeTriggerType.JOB,
246
- item_key=job.Key,
269
+ item_key=job.key,
247
270
  )
248
271
  elif isinstance(self.interrupt_value, WaitJob):
249
272
  self._resume_trigger = UiPathResumeTrigger(
@@ -8,7 +8,7 @@ from langchain_core.tracers.langchain import wait_for_all_tracers
8
8
  from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
9
9
  from langgraph.errors import EmptyInputError, GraphRecursionError, InvalidUpdateError
10
10
  from langgraph.graph.state import CompiledStateGraph
11
- from uipath_sdk._cli._runtime._contracts import (
11
+ from uipath._cli._runtime._contracts import (
12
12
  UiPathBaseRuntime,
13
13
  UiPathErrorCategory,
14
14
  UiPathRuntimeResult,
@@ -5,8 +5,8 @@ import uuid
5
5
  from typing import Any, Dict
6
6
 
7
7
  from langgraph.graph.state import CompiledStateGraph
8
- from uipath_sdk._cli._utils._parse_ast import generate_bindings_json # type: ignore
9
- from uipath_sdk._cli.middlewares import MiddlewareResult
8
+ from uipath._cli._utils._parse_ast import generate_bindings_json # type: ignore
9
+ from uipath._cli.middlewares import MiddlewareResult
10
10
 
11
11
  from ._utils._graph import LangGraphConfig
12
12
 
@@ -4,8 +4,8 @@ from os import environ as env
4
4
  from typing import Optional
5
5
 
6
6
  from dotenv import load_dotenv
7
- from uipath_sdk._cli._runtime._contracts import UiPathTraceContext
8
- from uipath_sdk._cli.middlewares import MiddlewareResult
7
+ from uipath._cli._runtime._contracts import UiPathTraceContext
8
+ from uipath._cli.middlewares import MiddlewareResult
9
9
 
10
10
  from ._runtime._context import LangGraphRuntimeContext
11
11
  from ._runtime._exception import LangGraphRuntimeError
@@ -1,4 +1,4 @@
1
- from uipath_sdk._cli.middlewares import Middlewares
1
+ from uipath._cli.middlewares import Middlewares
2
2
 
3
3
  from ._cli.cli_init import langgraph_init_middleware
4
4
  from ._cli.cli_run import langgraph_run_middleware
@@ -1,14 +1,17 @@
1
1
  from typing import List, Optional
2
2
 
3
- from langchain_core.callbacks import CallbackManagerForRetrieverRun
3
+ from langchain_core.callbacks import (
4
+ AsyncCallbackManagerForRetrieverRun,
5
+ CallbackManagerForRetrieverRun,
6
+ )
4
7
  from langchain_core.documents import Document
5
8
  from langchain_core.retrievers import BaseRetriever
6
- from uipath_sdk import UiPathSDK
9
+ from uipath import UiPath
7
10
 
8
11
 
9
12
  class ContextGroundingRetriever(BaseRetriever):
10
13
  index_name: str
11
- uipath_sdk: Optional[UiPathSDK] = None
14
+ uipath_sdk: Optional[UiPath] = None
12
15
  number_of_results: Optional[int] = 10
13
16
 
14
17
  def _get_relevant_documents(
@@ -16,7 +19,7 @@ class ContextGroundingRetriever(BaseRetriever):
16
19
  ) -> List[Document]:
17
20
  """Sync implementations for retriever calls context_grounding API to search the requested index."""
18
21
 
19
- sdk = self.uipath_sdk if self.uipath_sdk is not None else UiPathSDK()
22
+ sdk = self.uipath_sdk if self.uipath_sdk is not None else UiPath()
20
23
  results = sdk.context_grounding.search(
21
24
  self.index_name,
22
25
  query,
@@ -33,3 +36,26 @@ class ContextGroundingRetriever(BaseRetriever):
33
36
  )
34
37
  for x in results
35
38
  ]
39
+
40
+ async def _aget_relevant_documents(
41
+ self, query: str, *, run_manager: AsyncCallbackManagerForRetrieverRun
42
+ ) -> List[Document]:
43
+ """Async implementations for retriever calls context_grounding API to search the requested index."""
44
+
45
+ sdk = self.uipath_sdk if self.uipath_sdk is not None else UiPath()
46
+ results = await sdk.context_grounding.search_async(
47
+ self.index_name,
48
+ query,
49
+ self.number_of_results if self.number_of_results is not None else 10,
50
+ )
51
+
52
+ return [
53
+ Document(
54
+ page_content=x.content,
55
+ metadata={
56
+ "source": x.source,
57
+ "page_number": x.page_number,
58
+ },
59
+ )
60
+ for x in results
61
+ ]
@@ -12,7 +12,7 @@ import httpx
12
12
  from langchain_core.tracers.base import AsyncBaseTracer
13
13
  from langchain_core.tracers.schemas import Run
14
14
  from pydantic import PydanticDeprecationWarning
15
- from uipath_sdk._cli._runtime._contracts import UiPathTraceContext
15
+ from uipath._cli._runtime._contracts import UiPathTraceContext
16
16
 
17
17
  from ._events import CustomTraceEvents, FunctionCallEventData
18
18
  from ._utils import _setup_tracer_httpx_logging, _simple_serialize_defaults
@@ -118,7 +118,7 @@ class AsyncUiPathTracer(AsyncBaseTracer):
118
118
  trace_data = {
119
119
  "id": self.context.trace_id,
120
120
  "name": re.sub(
121
- "[!@#$<>\.]", "", run_name
121
+ r"[!@#$<>\.]", "", run_name
122
122
  ), # if we use these characters the Agents UI throws some error (but llmops backend seems fine)
123
123
  "referenceId": self.context.reference_id,
124
124
  "attributes": "{}",
@@ -74,7 +74,7 @@ class UiPathTracer(BaseTracer):
74
74
  trace_data = {
75
75
  "id": self.trace_parent,
76
76
  "name": re.sub(
77
- "[!@#$<>\.]", "", run_name
77
+ r"[!@#$<>\.]", "", run_name
78
78
  ), # if we use these characters the Agents UI throws some error (but llmops backend seems fine)
79
79
  "referenceId": self.referenceId,
80
80
  "attributes": "{}",
@@ -1,33 +1,33 @@
1
- from typing import Any, Dict, List, Literal, Optional
2
-
3
- RUN_TYPE_T = Literal[
4
- "tool", "chain", "llm", "retriever", "embedding", "prompt", "parser"
5
- ]
6
-
7
-
8
- class CustomTraceEvents:
9
- UIPATH_TRACE_FUNCTION_CALL = "__uipath_trace_function_call"
10
-
11
-
12
- class FunctionCallEventData:
13
- def __init__(
14
- self,
15
- function_name: str,
16
- event_type: str,
17
- inputs: Dict[str, Any],
18
- call_uuid: str,
19
- output: Any,
20
- error: Optional[str] = None,
21
- run_type: Optional[RUN_TYPE_T] = None,
22
- tags: Optional[List[str]] = None,
23
- metadata: Optional[Dict[str, Any]] = None,
24
- ):
25
- self.function_name = function_name
26
- self.event_type = event_type
27
- self.inputs = inputs
28
- self.call_uuid = call_uuid
29
- self.output = output
30
- self.error = error
31
- self.run_type = run_type or "chain"
32
- self.tags = tags
33
- self.metadata = metadata
1
+ from typing import Any, Dict, List, Literal, Optional
2
+
3
+ RUN_TYPE_T = Literal[
4
+ "tool", "chain", "llm", "retriever", "embedding", "prompt", "parser"
5
+ ]
6
+
7
+
8
+ class CustomTraceEvents:
9
+ UIPATH_TRACE_FUNCTION_CALL = "__uipath_trace_function_call"
10
+
11
+
12
+ class FunctionCallEventData:
13
+ def __init__(
14
+ self,
15
+ function_name: str,
16
+ event_type: str,
17
+ inputs: Dict[str, Any],
18
+ call_uuid: str,
19
+ output: Any,
20
+ error: Optional[str] = None,
21
+ run_type: Optional[RUN_TYPE_T] = None,
22
+ tags: Optional[List[str]] = None,
23
+ metadata: Optional[Dict[str, Any]] = None,
24
+ ):
25
+ self.function_name = function_name
26
+ self.event_type = event_type
27
+ self.inputs = inputs
28
+ self.call_uuid = call_uuid
29
+ self.output = output
30
+ self.error = error
31
+ self.run_type = run_type or "chain"
32
+ self.tags = tags
33
+ self.metadata = metadata