uipath-langchain 0.0.89__py3-none-any.whl → 0.0.91__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.
- uipath_langchain/_cli/_runtime/_input.py +7 -5
- uipath_langchain/_cli/_runtime/_output.py +31 -2
- uipath_langchain/_cli/_runtime/_runtime.py +10 -2
- uipath_langchain/_utils/__init__.py +2 -2
- uipath_langchain/tracers/__init__.py +2 -2
- uipath_langchain/tracers/_instrument_traceable.py +272 -151
- {uipath_langchain-0.0.89.dist-info → uipath_langchain-0.0.91.dist-info}/METADATA +2 -2
- {uipath_langchain-0.0.89.dist-info → uipath_langchain-0.0.91.dist-info}/RECORD +11 -11
- {uipath_langchain-0.0.89.dist-info → uipath_langchain-0.0.91.dist-info}/WHEEL +0 -0
- {uipath_langchain-0.0.89.dist-info → uipath_langchain-0.0.91.dist-info}/entry_points.txt +0 -0
- {uipath_langchain-0.0.89.dist-info → uipath_langchain-0.0.91.dist-info}/licenses/LICENSE +0 -0
|
@@ -58,10 +58,12 @@ class LangGraphInputProcessor:
|
|
|
58
58
|
if not trigger:
|
|
59
59
|
return Command(resume=self.context.input_json)
|
|
60
60
|
|
|
61
|
-
type, key = trigger
|
|
61
|
+
type, key, folder_path, folder_key, payload = trigger
|
|
62
62
|
logger.debug(f"ResumeTrigger: {type} {key}")
|
|
63
63
|
if type == UiPathResumeTriggerType.ACTION.value and key:
|
|
64
|
-
action = self.uipath.actions.
|
|
64
|
+
action = await self.uipath.actions.retrieve_async(
|
|
65
|
+
key, app_folder_key=folder_key, app_folder_path=folder_path
|
|
66
|
+
)
|
|
65
67
|
logger.debug(f"Action: {action}")
|
|
66
68
|
if action.data is None:
|
|
67
69
|
return Command(resume={})
|
|
@@ -95,7 +97,7 @@ class LangGraphInputProcessor:
|
|
|
95
97
|
return Command(resume=try_convert_to_json_format(job.output_arguments))
|
|
96
98
|
return Command(resume=self.context.input_json)
|
|
97
99
|
|
|
98
|
-
async def _get_latest_trigger(self) -> Optional[tuple[str, str]]:
|
|
100
|
+
async def _get_latest_trigger(self) -> Optional[tuple[str, str, str, str, str]]:
|
|
99
101
|
"""Fetch the most recent trigger from the database."""
|
|
100
102
|
if self.context.memory is None:
|
|
101
103
|
return None
|
|
@@ -106,7 +108,7 @@ class LangGraphInputProcessor:
|
|
|
106
108
|
self.context.memory.conn.cursor() as cur,
|
|
107
109
|
):
|
|
108
110
|
await cur.execute(f"""
|
|
109
|
-
SELECT type, key
|
|
111
|
+
SELECT type, key, folder_path, folder_key, payload
|
|
110
112
|
FROM {self.context.resume_triggers_table}
|
|
111
113
|
ORDER BY timestamp DESC
|
|
112
114
|
LIMIT 1
|
|
@@ -114,7 +116,7 @@ class LangGraphInputProcessor:
|
|
|
114
116
|
result = await cur.fetchone()
|
|
115
117
|
if result is None:
|
|
116
118
|
return None
|
|
117
|
-
return cast(tuple[str, str], tuple(result))
|
|
119
|
+
return cast(tuple[str, str, str, str, str], tuple(result))
|
|
118
120
|
except Exception as e:
|
|
119
121
|
raise LangGraphRuntimeError(
|
|
120
122
|
"DB_QUERY_FAILED",
|
|
@@ -232,6 +232,9 @@ class LangGraphOutputProcessor:
|
|
|
232
232
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
233
233
|
type TEXT NOT NULL,
|
|
234
234
|
key TEXT,
|
|
235
|
+
folder_key TEXT,
|
|
236
|
+
folder_path TEXT,
|
|
237
|
+
payload TEXT,
|
|
235
238
|
timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%S', 'now', 'utc'))
|
|
236
239
|
)
|
|
237
240
|
""")
|
|
@@ -280,6 +283,12 @@ class LangGraphOutputProcessor:
|
|
|
280
283
|
app_name=self.interrupt_value.app_name
|
|
281
284
|
if self.interrupt_value.app_name
|
|
282
285
|
else "",
|
|
286
|
+
app_folder_path=self.interrupt_value.app_folder_path
|
|
287
|
+
if self.interrupt_value.app_folder_path
|
|
288
|
+
else "",
|
|
289
|
+
app_folder_key=self.interrupt_value.app_folder_key
|
|
290
|
+
if self.interrupt_value.app_folder_key
|
|
291
|
+
else "",
|
|
283
292
|
app_key=self.interrupt_value.app_key
|
|
284
293
|
if self.interrupt_value.app_key
|
|
285
294
|
else "",
|
|
@@ -295,11 +304,25 @@ class LangGraphOutputProcessor:
|
|
|
295
304
|
self._resume_trigger = UiPathResumeTrigger(
|
|
296
305
|
trigger_type=UiPathResumeTriggerType.ACTION,
|
|
297
306
|
item_key=action.key,
|
|
307
|
+
payload=self.interrupt_value.model_dump_json(),
|
|
308
|
+
folder_path=self.interrupt_value.app_folder_path
|
|
309
|
+
if self.interrupt_value.app_folder_path
|
|
310
|
+
else None,
|
|
311
|
+
folder_key=self.interrupt_value.app_folder_key
|
|
312
|
+
if self.interrupt_value.app_folder_key
|
|
313
|
+
else None,
|
|
298
314
|
)
|
|
299
315
|
elif isinstance(self.interrupt_value, WaitAction):
|
|
300
316
|
self._resume_trigger = UiPathResumeTrigger(
|
|
301
317
|
triggerType=UiPathResumeTriggerType.ACTION,
|
|
302
318
|
itemKey=self.interrupt_value.action.key,
|
|
319
|
+
payload=self.interrupt_value.model_dump_json(),
|
|
320
|
+
folder_path=self.interrupt_value.app_folder_path
|
|
321
|
+
if self.interrupt_value.app_folder_path
|
|
322
|
+
else None,
|
|
323
|
+
folder_key=self.interrupt_value.app_folder_key
|
|
324
|
+
if self.interrupt_value.app_folder_key
|
|
325
|
+
else None,
|
|
303
326
|
)
|
|
304
327
|
|
|
305
328
|
except Exception as e:
|
|
@@ -324,8 +347,14 @@ class LangGraphOutputProcessor:
|
|
|
324
347
|
try:
|
|
325
348
|
logger.debug(f"ResumeTrigger: {trigger_type} {trigger_key}")
|
|
326
349
|
await cur.execute(
|
|
327
|
-
f"INSERT INTO {self.context.resume_triggers_table} (type, key) VALUES (?, ?)",
|
|
328
|
-
(
|
|
350
|
+
f"INSERT INTO {self.context.resume_triggers_table} (type, key, payload, folder_path, folder_key) VALUES (?, ?, ?, ?, ?)",
|
|
351
|
+
(
|
|
352
|
+
trigger_type,
|
|
353
|
+
trigger_key,
|
|
354
|
+
self.resume_trigger.payload,
|
|
355
|
+
self.resume_trigger.folder_path,
|
|
356
|
+
self.resume_trigger.folder_key,
|
|
357
|
+
),
|
|
329
358
|
)
|
|
330
359
|
await self.context.memory.conn.commit()
|
|
331
360
|
except Exception as e:
|
|
@@ -15,7 +15,7 @@ from uipath._cli._runtime._contracts import (
|
|
|
15
15
|
UiPathRuntimeResult,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from ..._utils import
|
|
18
|
+
from ..._utils import _instrument_traceable_attributes
|
|
19
19
|
from ...tracers import AsyncUiPathTracer
|
|
20
20
|
from ._context import LangGraphRuntimeContext
|
|
21
21
|
from ._exception import LangGraphRuntimeError
|
|
@@ -45,7 +45,7 @@ class LangGraphRuntime(UiPathBaseRuntime):
|
|
|
45
45
|
Raises:
|
|
46
46
|
LangGraphRuntimeError: If execution fails
|
|
47
47
|
"""
|
|
48
|
-
|
|
48
|
+
_instrument_traceable_attributes()
|
|
49
49
|
|
|
50
50
|
await self.validate()
|
|
51
51
|
|
|
@@ -94,6 +94,14 @@ class LangGraphRuntime(UiPathBaseRuntime):
|
|
|
94
94
|
"callbacks": callbacks,
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
recursion_limit = os.environ.get("LANGCHAIN_RECURSION_LIMIT", None)
|
|
98
|
+
max_concurrency = os.environ.get("LANGCHAIN_MAX_CONCURRENCY", None)
|
|
99
|
+
|
|
100
|
+
if recursion_limit is not None:
|
|
101
|
+
graph_config["recursion_limit"] = int(recursion_limit)
|
|
102
|
+
if max_concurrency is not None:
|
|
103
|
+
graph_config["max_concurrency"] = int(max_concurrency)
|
|
104
|
+
|
|
97
105
|
# Stream the output at debug time
|
|
98
106
|
if self.context.job_id is None:
|
|
99
107
|
# Get final chunk while streaming
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ..tracers._instrument_traceable import
|
|
1
|
+
from ..tracers._instrument_traceable import _instrument_traceable_attributes
|
|
2
2
|
from ._request_mixin import UiPathRequestMixin
|
|
3
3
|
|
|
4
|
-
__all__ = ["UiPathRequestMixin", "
|
|
4
|
+
__all__ = ["UiPathRequestMixin", "_instrument_traceable_attributes"]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from ._instrument_traceable import
|
|
1
|
+
from ._instrument_traceable import _instrument_traceable_attributes
|
|
2
2
|
from .AsyncUiPathTracer import AsyncUiPathTracer
|
|
3
3
|
from .UiPathTracer import UiPathTracer
|
|
4
4
|
|
|
5
|
-
__all__ = ["AsyncUiPathTracer", "UiPathTracer", "
|
|
5
|
+
__all__ = ["AsyncUiPathTracer", "UiPathTracer", "_instrument_traceable_attributes"]
|
|
@@ -4,9 +4,10 @@ import inspect
|
|
|
4
4
|
import logging
|
|
5
5
|
import sys
|
|
6
6
|
import uuid
|
|
7
|
-
from typing import Any, Dict, List, Literal, Optional
|
|
7
|
+
from typing import Any, Callable, Dict, List, Literal, Optional
|
|
8
8
|
|
|
9
9
|
from langchain_core.callbacks import dispatch_custom_event
|
|
10
|
+
from uipath.tracing import TracedDecoratorRegistry
|
|
10
11
|
|
|
11
12
|
from ._events import CustomTraceEvents, FunctionCallEventData
|
|
12
13
|
|
|
@@ -82,26 +83,228 @@ def format_args_for_trace(
|
|
|
82
83
|
return {"args": args, "kwargs": kwargs}
|
|
83
84
|
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
def _create_traced_wrapper(
|
|
87
|
+
func: Callable[..., Any],
|
|
88
|
+
wrapper_func: Optional[Callable[..., Any]] = None,
|
|
89
|
+
func_name: Optional[str] = None,
|
|
90
|
+
run_type: Optional[str] = None,
|
|
91
|
+
span_type: Optional[str] = None,
|
|
92
|
+
tags: Optional[List[str]] = None,
|
|
93
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
94
|
+
input_processor: Optional[Callable[..., Any]] = None,
|
|
95
|
+
output_processor: Optional[Callable[..., Any]] = None,
|
|
96
|
+
):
|
|
97
|
+
"""Create a traced wrapper based on function type."""
|
|
98
|
+
# Use function name if not provided
|
|
99
|
+
actual_func_name = func_name or func.__name__
|
|
100
|
+
# Function to actually call (the wrapped function or original)
|
|
101
|
+
target_func = wrapper_func or func
|
|
102
|
+
# Ensure we have metadata
|
|
103
|
+
actual_metadata = metadata or {}
|
|
104
|
+
|
|
105
|
+
# Define all wrapper functions
|
|
106
|
+
|
|
107
|
+
@functools.wraps(target_func)
|
|
108
|
+
async def async_gen_wrapper(*args, **kwargs):
|
|
109
|
+
try:
|
|
110
|
+
call_uuid = str(uuid.uuid4())
|
|
111
|
+
|
|
112
|
+
# Get inputs and process them if needed
|
|
113
|
+
inputs = format_args_for_trace(inspect.signature(func), *args, **kwargs)
|
|
114
|
+
if input_processor is not None:
|
|
115
|
+
inputs = input_processor(inputs)
|
|
116
|
+
|
|
117
|
+
# Add span_type to metadata if provided
|
|
118
|
+
if span_type:
|
|
119
|
+
actual_metadata["span_type"] = (
|
|
120
|
+
span_type or "function_call_generator_async"
|
|
121
|
+
)
|
|
98
122
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
dispatch_trace_event(
|
|
124
|
+
actual_func_name,
|
|
125
|
+
inputs,
|
|
126
|
+
"call",
|
|
127
|
+
call_uuid,
|
|
128
|
+
run_type=run_type, # type: ignore
|
|
129
|
+
tags=tags,
|
|
130
|
+
metadata=actual_metadata,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
outputs = []
|
|
134
|
+
async_gen = target_func(*args, **kwargs)
|
|
135
|
+
async for item in async_gen:
|
|
136
|
+
outputs.append(item)
|
|
137
|
+
yield item
|
|
138
|
+
|
|
139
|
+
# Process output if needed
|
|
140
|
+
output_to_record = outputs
|
|
141
|
+
if output_processor is not None:
|
|
142
|
+
output_to_record = output_processor(outputs)
|
|
143
|
+
|
|
144
|
+
dispatch_trace_event(
|
|
145
|
+
actual_func_name,
|
|
146
|
+
inputs,
|
|
147
|
+
"completion",
|
|
148
|
+
call_uuid,
|
|
149
|
+
result=output_to_record,
|
|
150
|
+
)
|
|
151
|
+
except Exception as e:
|
|
152
|
+
dispatch_trace_event(
|
|
153
|
+
actual_func_name, inputs, "completion", call_uuid, exception=e
|
|
154
|
+
)
|
|
155
|
+
raise
|
|
156
|
+
|
|
157
|
+
@functools.wraps(target_func)
|
|
158
|
+
def gen_wrapper(*args, **kwargs):
|
|
159
|
+
try:
|
|
160
|
+
call_uuid = str(uuid.uuid4())
|
|
161
|
+
|
|
162
|
+
# Get inputs and process them if needed
|
|
163
|
+
inputs = format_args_for_trace(inspect.signature(func), *args, **kwargs)
|
|
164
|
+
if input_processor is not None:
|
|
165
|
+
inputs = input_processor(inputs)
|
|
166
|
+
|
|
167
|
+
# Add span_type to metadata if provided
|
|
168
|
+
if span_type:
|
|
169
|
+
actual_metadata["span_type"] = (
|
|
170
|
+
span_type or "function_call_generator_sync"
|
|
171
|
+
)
|
|
103
172
|
|
|
104
|
-
|
|
173
|
+
dispatch_trace_event(
|
|
174
|
+
actual_func_name,
|
|
175
|
+
inputs,
|
|
176
|
+
"call",
|
|
177
|
+
call_uuid,
|
|
178
|
+
run_type=run_type, # type: ignore
|
|
179
|
+
tags=tags,
|
|
180
|
+
metadata=actual_metadata,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
outputs = []
|
|
184
|
+
gen = target_func(*args, **kwargs)
|
|
185
|
+
for item in gen:
|
|
186
|
+
outputs.append(item)
|
|
187
|
+
yield item
|
|
188
|
+
|
|
189
|
+
# Process output if needed
|
|
190
|
+
output_to_record = outputs
|
|
191
|
+
if output_processor is not None:
|
|
192
|
+
output_to_record = output_processor(outputs)
|
|
193
|
+
|
|
194
|
+
dispatch_trace_event(
|
|
195
|
+
actual_func_name,
|
|
196
|
+
inputs,
|
|
197
|
+
"completion",
|
|
198
|
+
call_uuid,
|
|
199
|
+
result=output_to_record,
|
|
200
|
+
)
|
|
201
|
+
except Exception as e:
|
|
202
|
+
dispatch_trace_event(
|
|
203
|
+
actual_func_name, inputs, "completion", call_uuid, exception=e
|
|
204
|
+
)
|
|
205
|
+
raise
|
|
206
|
+
|
|
207
|
+
@functools.wraps(target_func)
|
|
208
|
+
async def async_wrapper(*args, **kwargs):
|
|
209
|
+
try:
|
|
210
|
+
call_uuid = str(uuid.uuid4())
|
|
211
|
+
|
|
212
|
+
# Get inputs and process them if needed
|
|
213
|
+
inputs = format_args_for_trace(inspect.signature(func), *args, **kwargs)
|
|
214
|
+
if input_processor is not None:
|
|
215
|
+
inputs = input_processor(inputs)
|
|
216
|
+
|
|
217
|
+
# Add span_type to metadata if provided
|
|
218
|
+
if span_type:
|
|
219
|
+
actual_metadata["span_type"] = span_type or "function_call_async"
|
|
220
|
+
|
|
221
|
+
dispatch_trace_event(
|
|
222
|
+
actual_func_name,
|
|
223
|
+
inputs,
|
|
224
|
+
"call",
|
|
225
|
+
call_uuid,
|
|
226
|
+
run_type=run_type, # type: ignore
|
|
227
|
+
tags=tags,
|
|
228
|
+
metadata=actual_metadata,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
result = await target_func(*args, **kwargs)
|
|
232
|
+
|
|
233
|
+
# Process output if needed
|
|
234
|
+
output_to_record = result
|
|
235
|
+
if output_processor is not None:
|
|
236
|
+
output_to_record = output_processor(result)
|
|
237
|
+
|
|
238
|
+
dispatch_trace_event(
|
|
239
|
+
actual_func_name,
|
|
240
|
+
inputs,
|
|
241
|
+
"completion",
|
|
242
|
+
call_uuid,
|
|
243
|
+
result=output_to_record,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
return result
|
|
247
|
+
except Exception as e:
|
|
248
|
+
dispatch_trace_event(
|
|
249
|
+
actual_func_name, inputs, "completion", call_uuid, exception=e
|
|
250
|
+
)
|
|
251
|
+
raise
|
|
252
|
+
|
|
253
|
+
@functools.wraps(target_func)
|
|
254
|
+
def sync_wrapper(*args, **kwargs):
|
|
255
|
+
try:
|
|
256
|
+
call_uuid = str(uuid.uuid4())
|
|
257
|
+
|
|
258
|
+
# Get inputs and process them if needed
|
|
259
|
+
inputs = format_args_for_trace(inspect.signature(func), *args, **kwargs)
|
|
260
|
+
if input_processor is not None:
|
|
261
|
+
inputs = input_processor(inputs)
|
|
262
|
+
|
|
263
|
+
# Add span_type to metadata if provided
|
|
264
|
+
if span_type:
|
|
265
|
+
actual_metadata["span_type"] = span_type or "function_call_sync"
|
|
266
|
+
|
|
267
|
+
dispatch_trace_event(
|
|
268
|
+
actual_func_name,
|
|
269
|
+
inputs,
|
|
270
|
+
"call",
|
|
271
|
+
call_uuid,
|
|
272
|
+
run_type=run_type, # type: ignore
|
|
273
|
+
tags=tags,
|
|
274
|
+
metadata=actual_metadata,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
result = target_func(*args, **kwargs)
|
|
278
|
+
|
|
279
|
+
# Process output if needed
|
|
280
|
+
output_to_record = result
|
|
281
|
+
if output_processor is not None:
|
|
282
|
+
output_to_record = output_processor(result)
|
|
283
|
+
|
|
284
|
+
dispatch_trace_event(
|
|
285
|
+
actual_func_name,
|
|
286
|
+
inputs,
|
|
287
|
+
"completion",
|
|
288
|
+
call_uuid,
|
|
289
|
+
result=output_to_record,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
return result
|
|
293
|
+
except Exception as e:
|
|
294
|
+
dispatch_trace_event(
|
|
295
|
+
actual_func_name, inputs, "completion", call_uuid, exception=e
|
|
296
|
+
)
|
|
297
|
+
raise
|
|
298
|
+
|
|
299
|
+
# Return the appropriate wrapper based on the function type
|
|
300
|
+
if inspect.isasyncgenfunction(target_func):
|
|
301
|
+
return async_gen_wrapper
|
|
302
|
+
elif inspect.isgeneratorfunction(target_func):
|
|
303
|
+
return gen_wrapper
|
|
304
|
+
elif inspect.iscoroutinefunction(target_func):
|
|
305
|
+
return async_wrapper
|
|
306
|
+
else:
|
|
307
|
+
return sync_wrapper
|
|
105
308
|
|
|
106
309
|
|
|
107
310
|
def _create_appropriate_wrapper(
|
|
@@ -115,154 +318,72 @@ def _create_appropriate_wrapper(
|
|
|
115
318
|
metadata = decorator_kwargs.get("metadata", None)
|
|
116
319
|
run_type = decorator_kwargs.get("run_type", None)
|
|
117
320
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
inputs = format_args_for_trace(
|
|
127
|
-
inspect.signature(original_func), *args, **kwargs
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
dispatch_trace_event(
|
|
131
|
-
func_name,
|
|
132
|
-
inputs,
|
|
133
|
-
"call",
|
|
134
|
-
call_uuid,
|
|
135
|
-
run_type=run_type,
|
|
136
|
-
tags=tags,
|
|
137
|
-
metadata=metadata,
|
|
138
|
-
)
|
|
139
|
-
async_gen = wrapped_func(*args, **kwargs)
|
|
140
|
-
|
|
141
|
-
results = []
|
|
142
|
-
|
|
143
|
-
async for item in async_gen:
|
|
144
|
-
results.append(item)
|
|
145
|
-
yield item
|
|
146
|
-
|
|
147
|
-
dispatch_trace_event(
|
|
148
|
-
func_name, inputs, "completion", call_uuid, results
|
|
149
|
-
)
|
|
150
|
-
except Exception as e:
|
|
151
|
-
dispatch_trace_event(
|
|
152
|
-
func_name, inputs, "completion", call_uuid, exception=e
|
|
153
|
-
)
|
|
154
|
-
raise
|
|
155
|
-
|
|
156
|
-
return async_gen_wrapper
|
|
157
|
-
|
|
158
|
-
# Sync generator function
|
|
159
|
-
elif inspect.isgeneratorfunction(wrapped_func):
|
|
160
|
-
|
|
161
|
-
@functools.wraps(wrapped_func)
|
|
162
|
-
def gen_wrapper(*args, **kwargs):
|
|
163
|
-
try:
|
|
164
|
-
call_uuid = str(uuid.uuid4())
|
|
165
|
-
|
|
166
|
-
inputs = format_args_for_trace(
|
|
167
|
-
inspect.signature(original_func), *args, **kwargs
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
results = []
|
|
171
|
-
|
|
172
|
-
dispatch_trace_event(
|
|
173
|
-
func_name,
|
|
174
|
-
inputs,
|
|
175
|
-
"call",
|
|
176
|
-
call_uuid,
|
|
177
|
-
run_type=run_type,
|
|
178
|
-
tags=tags,
|
|
179
|
-
metadata=metadata,
|
|
180
|
-
)
|
|
181
|
-
gen = wrapped_func(*args, **kwargs)
|
|
182
|
-
for item in gen:
|
|
183
|
-
results.append(item)
|
|
184
|
-
yield item
|
|
185
|
-
dispatch_trace_event(
|
|
186
|
-
func_name, inputs, "completion", call_uuid, results
|
|
187
|
-
)
|
|
188
|
-
except Exception as e:
|
|
189
|
-
dispatch_trace_event(
|
|
190
|
-
func_name, inputs, "completion", call_uuid, exception=e
|
|
191
|
-
)
|
|
192
|
-
raise
|
|
193
|
-
|
|
194
|
-
return gen_wrapper
|
|
321
|
+
return _create_traced_wrapper(
|
|
322
|
+
func=original_func,
|
|
323
|
+
wrapper_func=wrapped_func,
|
|
324
|
+
func_name=func_name,
|
|
325
|
+
run_type=run_type,
|
|
326
|
+
tags=tags,
|
|
327
|
+
metadata=metadata,
|
|
328
|
+
)
|
|
195
329
|
|
|
196
|
-
# Async function
|
|
197
|
-
elif inspect.iscoroutinefunction(wrapped_func):
|
|
198
330
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
331
|
+
def _uipath_traced(
|
|
332
|
+
run_type: Optional[str] = None,
|
|
333
|
+
span_type: Optional[str] = None,
|
|
334
|
+
input_processor: Optional[Callable[..., Any]] = None,
|
|
335
|
+
output_processor: Optional[Callable[..., Any]] = None,
|
|
336
|
+
):
|
|
337
|
+
"""Decorator factory that creates traced functions using dispatch_trace_event."""
|
|
338
|
+
|
|
339
|
+
def decorator(func):
|
|
340
|
+
return _create_traced_wrapper(
|
|
341
|
+
func=func,
|
|
342
|
+
run_type=run_type,
|
|
343
|
+
span_type=span_type,
|
|
344
|
+
input_processor=input_processor,
|
|
345
|
+
output_processor=output_processor,
|
|
346
|
+
)
|
|
203
347
|
|
|
204
|
-
|
|
205
|
-
inspect.signature(original_func), *args, **kwargs
|
|
206
|
-
)
|
|
348
|
+
return decorator
|
|
207
349
|
|
|
208
|
-
dispatch_trace_event(
|
|
209
|
-
func_name,
|
|
210
|
-
inputs,
|
|
211
|
-
"call",
|
|
212
|
-
call_uuid,
|
|
213
|
-
run_type=run_type,
|
|
214
|
-
tags=tags,
|
|
215
|
-
metadata=metadata,
|
|
216
|
-
)
|
|
217
|
-
result = await wrapped_func(*args, **kwargs)
|
|
218
|
-
dispatch_trace_event(func_name, inputs, "completion", call_uuid, result)
|
|
219
|
-
return result
|
|
220
|
-
except Exception as e:
|
|
221
|
-
dispatch_trace_event(
|
|
222
|
-
func_name, inputs, "completion", call_uuid, exception=e
|
|
223
|
-
)
|
|
224
|
-
raise
|
|
225
350
|
|
|
226
|
-
|
|
351
|
+
# Create patched version of traceable
|
|
352
|
+
def patched_traceable(*decorator_args, **decorator_kwargs):
|
|
353
|
+
# Handle the case when @traceable is used directly as decorator without arguments
|
|
354
|
+
if (
|
|
355
|
+
len(decorator_args) == 1
|
|
356
|
+
and callable(decorator_args[0])
|
|
357
|
+
and not decorator_kwargs
|
|
358
|
+
):
|
|
359
|
+
func = decorator_args[0]
|
|
360
|
+
return _create_appropriate_wrapper(func, original_traceable(func), {})
|
|
227
361
|
|
|
228
|
-
#
|
|
229
|
-
|
|
362
|
+
# Handle the case when @traceable(args) is used with parameters
|
|
363
|
+
original_decorated = original_traceable(*decorator_args, **decorator_kwargs)
|
|
230
364
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
365
|
+
def uipath_trace_decorator(func):
|
|
366
|
+
# Apply the original decorator with its arguments
|
|
367
|
+
wrapped_func = original_decorated(func)
|
|
368
|
+
return _create_appropriate_wrapper(func, wrapped_func, decorator_kwargs)
|
|
235
369
|
|
|
236
|
-
|
|
237
|
-
inspect.signature(original_func), *args, **kwargs
|
|
238
|
-
)
|
|
370
|
+
return uipath_trace_decorator
|
|
239
371
|
|
|
240
|
-
dispatch_trace_event(
|
|
241
|
-
func_name,
|
|
242
|
-
inputs,
|
|
243
|
-
"call",
|
|
244
|
-
call_uuid,
|
|
245
|
-
run_type=run_type,
|
|
246
|
-
tags=tags,
|
|
247
|
-
metadata=metadata,
|
|
248
|
-
)
|
|
249
|
-
result = wrapped_func(*args, **kwargs)
|
|
250
|
-
dispatch_trace_event(func_name, inputs, "completion", call_uuid, result)
|
|
251
|
-
return result
|
|
252
|
-
except Exception as e:
|
|
253
|
-
dispatch_trace_event(
|
|
254
|
-
func_name, inputs, "completion", call_uuid, exception=e
|
|
255
|
-
)
|
|
256
|
-
raise
|
|
257
372
|
|
|
258
|
-
|
|
373
|
+
# Register the UIPath traced decorator
|
|
374
|
+
def register_uipath_tracing():
|
|
375
|
+
"""Register the UIPath tracing decorator with TracedDecoratorRegistry."""
|
|
376
|
+
TracedDecoratorRegistry.register_decorator("uipath", _uipath_traced)
|
|
259
377
|
|
|
260
378
|
|
|
261
379
|
# Apply the patch
|
|
262
|
-
def
|
|
380
|
+
def _instrument_traceable_attributes():
|
|
263
381
|
"""Apply the patch to langsmith module at import time."""
|
|
264
382
|
global original_langsmith, original_traceable
|
|
265
383
|
|
|
384
|
+
# Register our custom tracing decorator
|
|
385
|
+
register_uipath_tracing()
|
|
386
|
+
|
|
266
387
|
# Import the original module if not already done
|
|
267
388
|
if original_langsmith is None:
|
|
268
389
|
# Temporarily remove our custom module from sys.modules
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath-langchain
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.91
|
|
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.
|
|
28
|
+
Requires-Dist: uipath<2.1.0,>=2.0.13
|
|
29
29
|
Provides-Extra: langchain
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
@@ -6,11 +6,11 @@ uipath_langchain/_cli/cli_run.py,sha256=zMn2P1gB1ogM8_EmZsIhqNpeI9Oc02Z5Gj-oni7e
|
|
|
6
6
|
uipath_langchain/_cli/_runtime/_context.py,sha256=wr4aNn06ReIXmetEZ6b6AnpAt64p13anQ2trZ5Bzgio,807
|
|
7
7
|
uipath_langchain/_cli/_runtime/_escalation.py,sha256=oA5NvZvCo8ngELFJRyhZNM69DxVHrshhMY6CUk_cukQ,8055
|
|
8
8
|
uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJs_xF0OQXCCOvbYM,546
|
|
9
|
-
uipath_langchain/_cli/_runtime/_input.py,sha256=
|
|
10
|
-
uipath_langchain/_cli/_runtime/_output.py,sha256=
|
|
11
|
-
uipath_langchain/_cli/_runtime/_runtime.py,sha256=
|
|
9
|
+
uipath_langchain/_cli/_runtime/_input.py,sha256=gKzPaGW-EzgeAskWJjbCWnfZRLu_BM7lCXkq0XkVGLU,5614
|
|
10
|
+
uipath_langchain/_cli/_runtime/_output.py,sha256=WQSrsvGaaclZ6GLWEh6Nk1Mz1iGaIB45PgIX3DS3AN4,16130
|
|
11
|
+
uipath_langchain/_cli/_runtime/_runtime.py,sha256=wj6e6tQdP2GjuSM-6G6Ug-FMqwOHwfUq-DGbd1gMfIg,11825
|
|
12
12
|
uipath_langchain/_cli/_utils/_graph.py,sha256=WLBSJfPc3_C07SqJhePRe17JIc5wcBvEqLviMcNOdTA,6950
|
|
13
|
-
uipath_langchain/_utils/__init__.py,sha256=
|
|
13
|
+
uipath_langchain/_utils/__init__.py,sha256=WoY66enCygRXTh6v5B1UrRcFCnQYuPJ8oqDkwomXzLc,194
|
|
14
14
|
uipath_langchain/_utils/_request_mixin.py,sha256=t_1HWBxqEl-wsSk9ubmIM-8vs9BlNy4ZVBxtDxktn6U,18489
|
|
15
15
|
uipath_langchain/_utils/_settings.py,sha256=MhwEVj4gVRSar0RBf2w2hTjO-5Qm-HpCuufqN3gSWjA,3390
|
|
16
16
|
uipath_langchain/_utils/_sleep_policy.py,sha256=e9pHdjmcCj4CVoFM1jMyZFelH11YatsgWfpyrfXzKBQ,1251
|
|
@@ -24,17 +24,17 @@ uipath_langchain/retrievers/__init__.py,sha256=rOn7PyyHgZ4pMnXWPkGqmuBmx8eGuo-Oy
|
|
|
24
24
|
uipath_langchain/retrievers/context_grounding_retriever.py,sha256=CeVSMEz5xTQIladkzDLeQXGC1_ycW72gb0RB41JZeYA,2000
|
|
25
25
|
uipath_langchain/tracers/AsyncUiPathTracer.py,sha256=8eGWZ56iJcmhtRQU4cHuZYt6aJXqc8RB2OL_BCMp-Ow,10463
|
|
26
26
|
uipath_langchain/tracers/UiPathTracer.py,sha256=V5g1nlB0TI1wYvUIkfCEcAdhy4thqeMBmjflWtxc-_M,5601
|
|
27
|
-
uipath_langchain/tracers/__init__.py,sha256=
|
|
27
|
+
uipath_langchain/tracers/__init__.py,sha256=eKTSVS7R7PMk9qtzn036gdFmxUQxfExnCprI073EPOg,241
|
|
28
28
|
uipath_langchain/tracers/_events.py,sha256=CJri76SSdu7rGJIkXurJ2C5sQahfSK4E5UWwWYdEAtE,922
|
|
29
|
-
uipath_langchain/tracers/_instrument_traceable.py,sha256=
|
|
29
|
+
uipath_langchain/tracers/_instrument_traceable.py,sha256=ouFefzXLjfEQFaBQOXSsYWkkJ8Nfv73MKhIZg4qalhw,13152
|
|
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.
|
|
37
|
-
uipath_langchain-0.0.
|
|
38
|
-
uipath_langchain-0.0.
|
|
39
|
-
uipath_langchain-0.0.
|
|
40
|
-
uipath_langchain-0.0.
|
|
36
|
+
uipath_langchain-0.0.91.dist-info/METADATA,sha256=kmtrEsEsF9xA0UWzMG-tTCQJp4-uZUIOiWEltcmvuxA,3819
|
|
37
|
+
uipath_langchain-0.0.91.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
38
|
+
uipath_langchain-0.0.91.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
|
|
39
|
+
uipath_langchain-0.0.91.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
|
|
40
|
+
uipath_langchain-0.0.91.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|