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

@@ -4,9 +4,11 @@ import os
4
4
  import uuid
5
5
  from typing import Any, Dict
6
6
 
7
+ import click
7
8
  from langgraph.graph.state import CompiledStateGraph
8
9
  from uipath._cli._utils._parse_ast import generate_bindings_json # type: ignore
9
10
  from uipath._cli.middlewares import MiddlewareResult
11
+ from uipath._cli.spinner import Spinner
10
12
 
11
13
  from ._utils._graph import LangGraphConfig
12
14
 
@@ -32,6 +34,25 @@ def resolve_refs(schema, root=None):
32
34
  return schema
33
35
 
34
36
 
37
+ def process_nullable_types(
38
+ schema: Dict[str, Any] | list[Any] | Any,
39
+ ) -> Dict[str, Any] | list[Any]:
40
+ """Process the schema to handle nullable types by removing anyOf with null and keeping the base type."""
41
+ if isinstance(schema, dict):
42
+ if "anyOf" in schema and len(schema["anyOf"]) == 2:
43
+ types = [t.get("type") for t in schema["anyOf"]]
44
+ if "null" in types:
45
+ non_null_type = next(
46
+ t for t in schema["anyOf"] if t.get("type") != "null"
47
+ )
48
+ return non_null_type
49
+
50
+ return {k: process_nullable_types(v) for k, v in schema.items()}
51
+ elif isinstance(schema, list):
52
+ return [process_nullable_types(item) for item in schema]
53
+ return schema
54
+
55
+
35
56
  def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
36
57
  """Extract input/output schema from a LangGraph graph"""
37
58
  schema = {
@@ -42,12 +63,14 @@ def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
42
63
  if hasattr(graph, "input_schema"):
43
64
  if hasattr(graph.input_schema, "model_json_schema"):
44
65
  input_schema = graph.input_schema.model_json_schema()
45
-
46
66
  unpacked_ref_def_properties = resolve_refs(input_schema)
47
67
 
48
- schema["input"]["properties"] = unpacked_ref_def_properties.get(
49
- "properties", {}
68
+ # Process the schema to handle nullable types
69
+ processed_properties = process_nullable_types(
70
+ unpacked_ref_def_properties.get("properties", {})
50
71
  )
72
+
73
+ schema["input"]["properties"] = processed_properties
51
74
  schema["input"]["required"] = unpacked_ref_def_properties.get(
52
75
  "required", []
53
76
  )
@@ -55,11 +78,14 @@ def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
55
78
  if hasattr(graph, "output_schema"):
56
79
  if hasattr(graph.output_schema, "model_json_schema"):
57
80
  output_schema = graph.output_schema.model_json_schema()
58
-
59
81
  unpacked_ref_def_properties = resolve_refs(output_schema)
60
- schema["output"]["properties"] = unpacked_ref_def_properties.get(
61
- "properties", {}
82
+
83
+ # Process the schema to handle nullable types
84
+ processed_properties = process_nullable_types(
85
+ unpacked_ref_def_properties.get("properties", {})
62
86
  )
87
+
88
+ schema["output"]["properties"] = processed_properties
63
89
  schema["output"]["required"] = unpacked_ref_def_properties.get(
64
90
  "required", []
65
91
  )
@@ -69,6 +95,7 @@ def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
69
95
 
70
96
  async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
71
97
  """Middleware to check for langgraph.json and create uipath.json with schemas"""
98
+ spinner = Spinner("Initializing UiPath project...")
72
99
  config = LangGraphConfig()
73
100
  if not config.exists:
74
101
  return MiddlewareResult(
@@ -76,6 +103,7 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
76
103
  ) # Continue with normal flow if no langgraph.json
77
104
 
78
105
  try:
106
+ spinner.start()
79
107
  config.load_config()
80
108
  entrypoints = []
81
109
  all_bindings = {"version": "2.0", "resources": []}
@@ -98,7 +126,6 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
98
126
  mermaids[graph.name] = compiled_graph.get_graph(xray=1).draw_mermaid()
99
127
 
100
128
  try:
101
- print("Generating bindings for ", graph.file_path)
102
129
  # Make sure the file path exists
103
130
  if os.path.exists(graph.file_path):
104
131
  file_bindings = generate_bindings_json(graph.file_path)
@@ -108,7 +135,7 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
108
135
  all_bindings["resources"] = file_bindings["resources"]
109
136
  except Exception as e:
110
137
  print(
111
- f"Warning: Could not generate bindings for {graph.file_path}: {str(e)}"
138
+ f"⚠️ Warning: Could not generate bindings for {graph.file_path}: {str(e)}"
112
139
  )
113
140
 
114
141
  new_entrypoint: dict[str, Any] = {
@@ -121,19 +148,21 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
121
148
  entrypoints.append(new_entrypoint)
122
149
 
123
150
  except Exception as e:
151
+ spinner.stop()
124
152
  print(f"Error during graph load: {e}")
125
153
  return MiddlewareResult(
126
154
  should_continue=False,
127
- error_message=f"Failed to load graph '{graph.name}': {str(e)}",
155
+ error_message=f"Failed to load graph '{graph.name}': {str(e)}",
128
156
  should_include_stacktrace=True,
129
157
  )
130
158
  finally:
131
159
  await graph.cleanup()
132
160
 
133
161
  if entrypoint and not entrypoints:
162
+ spinner.stop()
134
163
  return MiddlewareResult(
135
164
  should_continue=False,
136
- error_message=f"Error: No graph found with name '{entrypoint}'",
165
+ error_message=f"Error: No graph found with name '{entrypoint}'",
137
166
  )
138
167
 
139
168
  uipath_config = {"entryPoints": entrypoints, "bindings": all_bindings}
@@ -149,21 +178,24 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
149
178
  with open(mermaid_file_path, "w") as f:
150
179
  f.write(mermaid_content)
151
180
  except Exception as write_error:
181
+ spinner.stop()
152
182
  return MiddlewareResult(
153
183
  should_continue=False,
154
- error_message=f"Error writing mermaid file for '{graph_name}': {str(write_error)}",
184
+ error_message=f"Error writing mermaid file for '{graph_name}': {str(write_error)}",
155
185
  should_include_stacktrace=True,
156
186
  )
157
-
187
+ spinner.stop()
158
188
  return MiddlewareResult(
159
189
  should_continue=False,
160
- info_message=f"Configuration file {config_path} created successfully.",
190
+ info_message=click.style(" ", fg="green", bold=True)
191
+ + f" Configuration file {config_path} created successfully.",
161
192
  )
162
193
 
163
194
  except Exception as e:
195
+ spinner.stop()
164
196
  return MiddlewareResult(
165
197
  should_continue=False,
166
- error_message=f"Error processing langgraph configuration: {str(e)}",
198
+ error_message=f"Error processing langgraph configuration: {str(e)}",
167
199
  should_include_stacktrace=True,
168
200
  )
169
201
 
@@ -32,19 +32,24 @@ def dispatch_trace_event(
32
32
  metadata: Optional[Dict[str, Any]] = None,
33
33
  ):
34
34
  """Dispatch trace event to our server."""
35
+ try:
36
+ event_data = FunctionCallEventData(
37
+ function_name=func_name,
38
+ event_type=event_type,
39
+ inputs=inputs,
40
+ call_uuid=call_uuid,
41
+ output=result,
42
+ error=str(exception) if exception else None,
43
+ run_type=run_type,
44
+ tags=tags,
45
+ metadata=metadata,
46
+ )
35
47
 
36
- event_data = FunctionCallEventData(
37
- function_name=func_name,
38
- event_type=event_type,
39
- inputs=inputs,
40
- call_uuid=call_uuid,
41
- output=result,
42
- error=str(exception) if exception else None,
43
- run_type=run_type,
44
- tags=tags,
45
- metadata=metadata,
46
- )
47
- dispatch_custom_event(CustomTraceEvents.UIPATH_TRACE_FUNCTION_CALL, event_data)
48
+ dispatch_custom_event(CustomTraceEvents.UIPATH_TRACE_FUNCTION_CALL, event_data)
49
+ except Exception as e:
50
+ logger.debug(
51
+ f"Error dispatching trace event: {e}. Function name: {func_name} Event type: {event_type}"
52
+ )
48
53
 
49
54
 
50
55
  def format_args_for_trace(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath-langchain
3
- Version: 0.0.92
3
+ Version: 0.0.94
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: pydantic-settings>=2.6.0
25
25
  Requires-Dist: python-dotenv>=1.0.1
26
26
  Requires-Dist: requests>=2.23.3
27
27
  Requires-Dist: types-requests>=2.32.0.20241016
28
- Requires-Dist: uipath<2.1.0,>=2.0.14
28
+ Requires-Dist: uipath<2.1.0,>=2.0.23
29
29
  Provides-Extra: langchain
30
30
  Description-Content-Type: text/markdown
31
31
 
@@ -1,7 +1,7 @@
1
1
  uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,80
2
2
  uipath_langchain/middlewares.py,sha256=AkGsj-zqyh9u5AyX79MCL0yKL4YArF-hudAHZs_0K0Y,400
3
3
  uipath_langchain/_cli/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
4
- uipath_langchain/_cli/cli_init.py,sha256=jsMB9p4-ot23wP04gc-TsRHHnbGMYTw7mjA6r1_SqfA,6383
4
+ uipath_langchain/_cli/cli_init.py,sha256=PKkebO0P4Qh1N-LAx_HdypbffbGq5_JSquJY1OMsK6E,7700
5
5
  uipath_langchain/_cli/cli_run.py,sha256=zMn2P1gB1ogM8_EmZsIhqNpeI9Oc02Z5Gj-oni7eUV4,2915
6
6
  uipath_langchain/_cli/_runtime/_context.py,sha256=wr4aNn06ReIXmetEZ6b6AnpAt64p13anQ2trZ5Bzgio,807
7
7
  uipath_langchain/_cli/_runtime/_escalation.py,sha256=oA5NvZvCo8ngELFJRyhZNM69DxVHrshhMY6CUk_cukQ,8055
@@ -26,15 +26,15 @@ uipath_langchain/tracers/AsyncUiPathTracer.py,sha256=8eGWZ56iJcmhtRQU4cHuZYt6aJX
26
26
  uipath_langchain/tracers/UiPathTracer.py,sha256=V5g1nlB0TI1wYvUIkfCEcAdhy4thqeMBmjflWtxc-_M,5601
27
27
  uipath_langchain/tracers/__init__.py,sha256=MwrQh6iuPXMS72S5EX0JdCAX0TKe-l7fIPGV3EG0Ssk,256
28
28
  uipath_langchain/tracers/_events.py,sha256=CJri76SSdu7rGJIkXurJ2C5sQahfSK4E5UWwWYdEAtE,922
29
- uipath_langchain/tracers/_instrument_traceable.py,sha256=MP1xmSRpuzsGePoioiHUU0R7gT-BW6eA-25qKZpLyOk,13182
29
+ uipath_langchain/tracers/_instrument_traceable.py,sha256=DR1r-b1Vso7uA6V5six1NxTmLQWb_-qTWdbIicrbBcM,13401
30
30
  uipath_langchain/tracers/_utils.py,sha256=JOT1tKMdvqjMDtj2WbmbOWMeMlTXBWavxWpogX7KlRA,1543
31
31
  uipath_langchain/utils/__init__.py,sha256=-w-4TD9ZnJDCpj4VIPXhJciukrmDJJbmnOFnhAkAaEU,81
32
32
  uipath_langchain/utils/_request_mixin.py,sha256=WFyTDyAthSci1DRwUwS21I3hLntD7HdVzYc0ZPoi3ys,18296
33
33
  uipath_langchain/utils/_settings.py,sha256=MhwEVj4gVRSar0RBf2w2hTjO-5Qm-HpCuufqN3gSWjA,3390
34
34
  uipath_langchain/utils/_sleep_policy.py,sha256=e9pHdjmcCj4CVoFM1jMyZFelH11YatsgWfpyrfXzKBQ,1251
35
35
  uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=eTa5sX43-ydB1pj9VNHUPbB-hC36fZK_CGrNe5U2Nrw,9393
36
- uipath_langchain-0.0.92.dist-info/METADATA,sha256=gQX7bMt93pOFiHdTXAMZ1J3pBr6-sJuBP1BnybEtNAE,3819
37
- uipath_langchain-0.0.92.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- uipath_langchain-0.0.92.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
39
- uipath_langchain-0.0.92.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
40
- uipath_langchain-0.0.92.dist-info/RECORD,,
36
+ uipath_langchain-0.0.94.dist-info/METADATA,sha256=0K_IaP1-pgZHmR0vDZZa3yhIy1oCbPR-z7mOYMWSepM,3819
37
+ uipath_langchain-0.0.94.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ uipath_langchain-0.0.94.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
39
+ uipath_langchain-0.0.94.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
40
+ uipath_langchain-0.0.94.dist-info/RECORD,,