uipath-langchain 0.0.140__py3-none-any.whl → 0.0.142__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/_context.py +1 -7
- uipath_langchain/_cli/_runtime/_input.py +125 -117
- uipath_langchain/_cli/_runtime/_output.py +111 -197
- uipath_langchain/_cli/_runtime/_runtime.py +376 -150
- uipath_langchain/_cli/cli_debug.py +95 -0
- uipath_langchain/_cli/cli_init.py +134 -2
- uipath_langchain/_cli/cli_run.py +30 -17
- uipath_langchain/_resources/AGENTS.md +21 -0
- uipath_langchain/_resources/REQUIRED_STRUCTURE.md +92 -0
- uipath_langchain/middlewares.py +2 -0
- uipath_langchain/py.typed +0 -0
- uipath_langchain/tools/preconfigured.py +2 -2
- {uipath_langchain-0.0.140.dist-info → uipath_langchain-0.0.142.dist-info}/METADATA +2 -2
- {uipath_langchain-0.0.140.dist-info → uipath_langchain-0.0.142.dist-info}/RECORD +17 -13
- {uipath_langchain-0.0.140.dist-info → uipath_langchain-0.0.142.dist-info}/WHEEL +0 -0
- {uipath_langchain-0.0.140.dist-info → uipath_langchain-0.0.142.dist-info}/entry_points.txt +0 -0
- {uipath_langchain-0.0.140.dist-info → uipath_langchain-0.0.142.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from openinference.instrumentation.langchain import (
|
|
6
|
+
LangChainInstrumentor,
|
|
7
|
+
get_current_span,
|
|
8
|
+
)
|
|
9
|
+
from uipath._cli._debug._bridge import UiPathDebugBridge, get_debug_bridge
|
|
10
|
+
from uipath._cli._debug._runtime import UiPathDebugRuntime
|
|
11
|
+
from uipath._cli._runtime._contracts import (
|
|
12
|
+
UiPathRuntimeFactory,
|
|
13
|
+
)
|
|
14
|
+
from uipath._cli.middlewares import MiddlewareResult
|
|
15
|
+
|
|
16
|
+
from .._tracing import LangChainExporter, _instrument_traceable_attributes
|
|
17
|
+
from ._runtime._exception import LangGraphRuntimeError
|
|
18
|
+
from ._runtime._runtime import ( # type: ignore[attr-defined]
|
|
19
|
+
LangGraphRuntimeContext,
|
|
20
|
+
LangGraphScriptRuntime,
|
|
21
|
+
)
|
|
22
|
+
from ._utils._graph import LangGraphConfig
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def langgraph_debug_middleware(
|
|
26
|
+
entrypoint: Optional[str], input: Optional[str], resume: bool, **kwargs
|
|
27
|
+
) -> MiddlewareResult:
|
|
28
|
+
"""Middleware to handle LangGraph execution"""
|
|
29
|
+
config = LangGraphConfig()
|
|
30
|
+
if not config.exists:
|
|
31
|
+
return MiddlewareResult(
|
|
32
|
+
should_continue=True
|
|
33
|
+
) # Continue with normal flow if no langgraph.json
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
|
|
37
|
+
async def execute():
|
|
38
|
+
context = LangGraphRuntimeContext.with_defaults(**kwargs)
|
|
39
|
+
context.entrypoint = entrypoint
|
|
40
|
+
context.input = input
|
|
41
|
+
context.resume = resume
|
|
42
|
+
context.execution_id = context.job_id or "default"
|
|
43
|
+
|
|
44
|
+
_instrument_traceable_attributes()
|
|
45
|
+
|
|
46
|
+
def generate_runtime(
|
|
47
|
+
ctx: LangGraphRuntimeContext,
|
|
48
|
+
) -> LangGraphScriptRuntime:
|
|
49
|
+
runtime = LangGraphScriptRuntime(ctx, ctx.entrypoint)
|
|
50
|
+
# If not resuming and no job id, delete the previous state file
|
|
51
|
+
if not ctx.resume and ctx.job_id is None:
|
|
52
|
+
if os.path.exists(runtime.state_file_path):
|
|
53
|
+
os.remove(runtime.state_file_path)
|
|
54
|
+
return runtime
|
|
55
|
+
|
|
56
|
+
runtime_factory = UiPathRuntimeFactory(
|
|
57
|
+
LangGraphScriptRuntime,
|
|
58
|
+
LangGraphRuntimeContext,
|
|
59
|
+
runtime_generator=generate_runtime,
|
|
60
|
+
context_generator=lambda: context,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
if context.job_id:
|
|
64
|
+
runtime_factory.add_span_exporter(LangChainExporter())
|
|
65
|
+
|
|
66
|
+
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
|
|
67
|
+
|
|
68
|
+
debug_bridge: UiPathDebugBridge = get_debug_bridge(context)
|
|
69
|
+
|
|
70
|
+
async with UiPathDebugRuntime.from_debug_context(
|
|
71
|
+
factory=runtime_factory,
|
|
72
|
+
context=context,
|
|
73
|
+
debug_bridge=debug_bridge,
|
|
74
|
+
) as debug_runtime:
|
|
75
|
+
await debug_runtime.execute()
|
|
76
|
+
|
|
77
|
+
asyncio.run(execute())
|
|
78
|
+
|
|
79
|
+
return MiddlewareResult(
|
|
80
|
+
should_continue=False,
|
|
81
|
+
error_message=None,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
except LangGraphRuntimeError as e:
|
|
85
|
+
return MiddlewareResult(
|
|
86
|
+
should_continue=False,
|
|
87
|
+
error_message=e.error_info.detail,
|
|
88
|
+
should_include_stacktrace=True,
|
|
89
|
+
)
|
|
90
|
+
except Exception as e:
|
|
91
|
+
return MiddlewareResult(
|
|
92
|
+
should_continue=False,
|
|
93
|
+
error_message=f"Error: {str(e)}",
|
|
94
|
+
should_include_stacktrace=True,
|
|
95
|
+
)
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import importlib.resources
|
|
2
3
|
import json
|
|
3
4
|
import os
|
|
5
|
+
import shutil
|
|
4
6
|
import uuid
|
|
7
|
+
from collections.abc import Generator
|
|
8
|
+
from enum import Enum
|
|
5
9
|
from typing import Any, Callable, Dict, overload
|
|
6
10
|
|
|
11
|
+
import click
|
|
7
12
|
from langgraph.graph.state import CompiledStateGraph
|
|
8
13
|
from uipath._cli._utils._console import ConsoleLogger
|
|
9
14
|
from uipath._cli._utils._parse_ast import generate_bindings_json # type: ignore
|
|
@@ -14,6 +19,14 @@ from ._utils._graph import LangGraphConfig
|
|
|
14
19
|
console = ConsoleLogger()
|
|
15
20
|
|
|
16
21
|
|
|
22
|
+
class FileOperationStatus(str, Enum):
|
|
23
|
+
"""Status of a file operation."""
|
|
24
|
+
|
|
25
|
+
CREATED = "created"
|
|
26
|
+
UPDATED = "updated"
|
|
27
|
+
SKIPPED = "skipped"
|
|
28
|
+
|
|
29
|
+
|
|
17
30
|
def resolve_refs(schema, root=None):
|
|
18
31
|
"""Recursively resolves $ref references in a JSON schema."""
|
|
19
32
|
if root is None:
|
|
@@ -96,6 +109,120 @@ def generate_schema_from_graph(
|
|
|
96
109
|
return schema
|
|
97
110
|
|
|
98
111
|
|
|
112
|
+
def generate_agent_md_file(
|
|
113
|
+
target_directory: str,
|
|
114
|
+
file_name: str,
|
|
115
|
+
resource_name: str,
|
|
116
|
+
no_agents_md_override: bool,
|
|
117
|
+
) -> tuple[str, FileOperationStatus] | None:
|
|
118
|
+
"""Generate an agent-specific file from the packaged resource.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
target_directory: The directory where the file should be created.
|
|
122
|
+
file_name: The name of the file should be created.
|
|
123
|
+
resource_name: The name of the resource folder where should be the file.
|
|
124
|
+
no_agents_md_override: Whether to override existing files.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
A tuple of (file_name, status) where status is a FileOperationStatus:
|
|
128
|
+
- CREATED: File was created
|
|
129
|
+
- UPDATED: File was overwritten
|
|
130
|
+
- SKIPPED: File exists and no_agents_md_override is True
|
|
131
|
+
Returns None if an error occurred.
|
|
132
|
+
"""
|
|
133
|
+
target_path = os.path.join(target_directory, file_name)
|
|
134
|
+
will_override = os.path.exists(target_path)
|
|
135
|
+
|
|
136
|
+
if will_override and no_agents_md_override:
|
|
137
|
+
return file_name, FileOperationStatus.SKIPPED
|
|
138
|
+
try:
|
|
139
|
+
source_path = importlib.resources.files(resource_name).joinpath(file_name)
|
|
140
|
+
|
|
141
|
+
with importlib.resources.as_file(source_path) as s_path:
|
|
142
|
+
shutil.copy(s_path, target_path)
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
file_name,
|
|
146
|
+
FileOperationStatus.UPDATED
|
|
147
|
+
if will_override
|
|
148
|
+
else FileOperationStatus.CREATED,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
except Exception as e:
|
|
152
|
+
console.warning(f"Could not create {file_name}: {e}")
|
|
153
|
+
return None
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def generate_specific_agents_md_files(
|
|
157
|
+
target_directory: str, no_agents_md_override: bool
|
|
158
|
+
) -> Generator[tuple[str, FileOperationStatus], None, None]:
|
|
159
|
+
"""Generate agent-specific files from the packaged resource.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
target_directory: The directory where the files should be created.
|
|
163
|
+
no_agents_md_override: Whether to override existing files.
|
|
164
|
+
|
|
165
|
+
Yields:
|
|
166
|
+
Tuple of (file_name, status) for each file operation, where status is a FileOperationStatus:
|
|
167
|
+
- CREATED: File was created
|
|
168
|
+
- UPDATED: File was overwritten
|
|
169
|
+
- SKIPPED: File exists and was not overwritten
|
|
170
|
+
"""
|
|
171
|
+
agent_dir = os.path.join(target_directory, ".agent")
|
|
172
|
+
os.makedirs(agent_dir, exist_ok=True)
|
|
173
|
+
|
|
174
|
+
file_configs = [
|
|
175
|
+
(target_directory, "CLAUDE.md", "uipath._resources"),
|
|
176
|
+
(agent_dir, "CLI_REFERENCE.md", "uipath._resources"),
|
|
177
|
+
(agent_dir, "SDK_REFERENCE.md", "uipath._resources"),
|
|
178
|
+
(target_directory, "AGENTS.md", "uipath_langchain._resources"),
|
|
179
|
+
(agent_dir, "REQUIRED_STRUCTURE.md", "uipath_langchain._resources"),
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
for directory, file_name, resource_name in file_configs:
|
|
183
|
+
result = generate_agent_md_file(
|
|
184
|
+
directory, file_name, resource_name, no_agents_md_override
|
|
185
|
+
)
|
|
186
|
+
if result:
|
|
187
|
+
yield result
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def generate_agents_md_files(options: dict[str, Any]) -> None:
|
|
191
|
+
"""Generate agent MD files and log categorized summary.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
options: Options dictionary
|
|
195
|
+
"""
|
|
196
|
+
current_directory = os.getcwd()
|
|
197
|
+
no_agents_md_override = options.get("no_agents_md_override", False)
|
|
198
|
+
|
|
199
|
+
created_files = []
|
|
200
|
+
updated_files = []
|
|
201
|
+
skipped_files = []
|
|
202
|
+
|
|
203
|
+
for file_name, status in generate_specific_agents_md_files(
|
|
204
|
+
current_directory, no_agents_md_override
|
|
205
|
+
):
|
|
206
|
+
if status == FileOperationStatus.CREATED:
|
|
207
|
+
created_files.append(file_name)
|
|
208
|
+
elif status == FileOperationStatus.UPDATED:
|
|
209
|
+
updated_files.append(file_name)
|
|
210
|
+
elif status == FileOperationStatus.SKIPPED:
|
|
211
|
+
skipped_files.append(file_name)
|
|
212
|
+
|
|
213
|
+
if created_files:
|
|
214
|
+
files_str = ", ".join(click.style(f, fg="cyan") for f in created_files)
|
|
215
|
+
console.success(f"Created: {files_str}")
|
|
216
|
+
|
|
217
|
+
if updated_files:
|
|
218
|
+
files_str = ", ".join(click.style(f, fg="cyan") for f in updated_files)
|
|
219
|
+
console.success(f"Updated: {files_str}")
|
|
220
|
+
|
|
221
|
+
if skipped_files:
|
|
222
|
+
files_str = ", ".join(click.style(f, fg="yellow") for f in skipped_files)
|
|
223
|
+
console.info(f"Skipped (already exist): {files_str}")
|
|
224
|
+
|
|
225
|
+
|
|
99
226
|
async def langgraph_init_middleware_async(
|
|
100
227
|
entrypoint: str,
|
|
101
228
|
options: dict[str, Any] | None = None,
|
|
@@ -185,7 +312,9 @@ async def langgraph_init_middleware_async(
|
|
|
185
312
|
try:
|
|
186
313
|
with open(mermaid_file_path, "w") as f:
|
|
187
314
|
f.write(mermaid_content)
|
|
188
|
-
console.success(
|
|
315
|
+
console.success(
|
|
316
|
+
f"Created {click.style(mermaid_file_path, fg='cyan')} file."
|
|
317
|
+
)
|
|
189
318
|
except Exception as write_error:
|
|
190
319
|
console.error(
|
|
191
320
|
f"Error writing mermaid file for '{graph_name}': {str(write_error)}"
|
|
@@ -194,7 +323,10 @@ async def langgraph_init_middleware_async(
|
|
|
194
323
|
should_continue=False,
|
|
195
324
|
should_include_stacktrace=True,
|
|
196
325
|
)
|
|
197
|
-
console.success(f"
|
|
326
|
+
console.success(f"Created {click.style(config_path, fg='cyan')} file.")
|
|
327
|
+
|
|
328
|
+
generate_agents_md_files(options)
|
|
329
|
+
|
|
198
330
|
return MiddlewareResult(should_continue=False)
|
|
199
331
|
|
|
200
332
|
except Exception as e:
|
uipath_langchain/_cli/cli_run.py
CHANGED
|
@@ -6,10 +6,13 @@ from openinference.instrumentation.langchain import (
|
|
|
6
6
|
LangChainInstrumentor,
|
|
7
7
|
get_current_span,
|
|
8
8
|
)
|
|
9
|
+
from uipath._cli._debug._bridge import ConsoleDebugBridge, UiPathDebugBridge
|
|
9
10
|
from uipath._cli._runtime._contracts import (
|
|
10
11
|
UiPathRuntimeFactory,
|
|
12
|
+
UiPathRuntimeResult,
|
|
11
13
|
)
|
|
12
14
|
from uipath._cli.middlewares import MiddlewareResult
|
|
15
|
+
from uipath._events._events import UiPathAgentStateEvent
|
|
13
16
|
|
|
14
17
|
from .._tracing import LangChainExporter, _instrument_traceable_attributes
|
|
15
18
|
from ._runtime._exception import LangGraphRuntimeError
|
|
@@ -31,34 +34,44 @@ def langgraph_run_middleware(
|
|
|
31
34
|
) # Continue with normal flow if no langgraph.json
|
|
32
35
|
|
|
33
36
|
try:
|
|
34
|
-
context = LangGraphRuntimeContext.with_defaults(**kwargs)
|
|
35
|
-
context.entrypoint = entrypoint
|
|
36
|
-
context.input = input
|
|
37
|
-
context.resume = resume
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
async def execute():
|
|
39
|
+
context = LangGraphRuntimeContext.with_defaults(**kwargs)
|
|
40
|
+
context.entrypoint = entrypoint
|
|
41
|
+
context.input = input
|
|
42
|
+
context.resume = resume
|
|
43
|
+
context.execution_id = context.job_id or "default"
|
|
44
|
+
_instrument_traceable_attributes()
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
def generate_runtime(
|
|
47
|
+
ctx: LangGraphRuntimeContext,
|
|
48
|
+
) -> LangGraphScriptRuntime:
|
|
49
|
+
runtime = LangGraphScriptRuntime(ctx, ctx.entrypoint)
|
|
50
|
+
# If not resuming and no job id, delete the previous state file
|
|
51
|
+
if not ctx.resume and ctx.job_id is None:
|
|
52
|
+
if os.path.exists(runtime.state_file_path):
|
|
53
|
+
os.remove(runtime.state_file_path)
|
|
54
|
+
return runtime
|
|
48
55
|
|
|
49
|
-
async def execute():
|
|
50
56
|
runtime_factory = UiPathRuntimeFactory(
|
|
51
57
|
LangGraphScriptRuntime,
|
|
52
58
|
LangGraphRuntimeContext,
|
|
53
59
|
runtime_generator=generate_runtime,
|
|
54
60
|
)
|
|
55
61
|
|
|
56
|
-
if context.job_id:
|
|
57
|
-
runtime_factory.add_span_exporter(LangChainExporter())
|
|
58
|
-
|
|
59
62
|
runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
if context.job_id:
|
|
65
|
+
runtime_factory.add_span_exporter(LangChainExporter())
|
|
66
|
+
await runtime_factory.execute(context)
|
|
67
|
+
else:
|
|
68
|
+
debug_bridge: UiPathDebugBridge = ConsoleDebugBridge()
|
|
69
|
+
await debug_bridge.emit_execution_started(context.execution_id)
|
|
70
|
+
async for event in runtime_factory.stream(context):
|
|
71
|
+
if isinstance(event, UiPathRuntimeResult):
|
|
72
|
+
await debug_bridge.emit_execution_completed(event)
|
|
73
|
+
elif isinstance(event, UiPathAgentStateEvent):
|
|
74
|
+
await debug_bridge.emit_state_update(event)
|
|
62
75
|
|
|
63
76
|
asyncio.run(execute())
|
|
64
77
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Agent Code Patterns Reference
|
|
2
|
+
|
|
3
|
+
This document provides practical code patterns for building UiPath coded agents using LangGraph and the UiPath Python SDK.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Documentation Structure
|
|
8
|
+
|
|
9
|
+
This documentation is split into multiple files for efficient context loading. Load only the files you need:
|
|
10
|
+
|
|
11
|
+
1. **@.agent/REQUIRED_STRUCTURE.md** - Agent structure patterns and templates
|
|
12
|
+
- **When to load:** Creating a new agent or understanding required patterns
|
|
13
|
+
- **Contains:** Required Pydantic models (Input, State, Output), LLM initialization patterns, standard agent template
|
|
14
|
+
|
|
15
|
+
2. **@.agent/SDK_REFERENCE.md** - Complete SDK API reference
|
|
16
|
+
- **When to load:** Calling UiPath SDK methods, working with services (actions, assets, jobs, etc.)
|
|
17
|
+
- **Contains:** All SDK services and methods with full signatures and type annotations
|
|
18
|
+
|
|
19
|
+
3. **@.agent/CLI_REFERENCE.md** - CLI commands documentation
|
|
20
|
+
- **When to load:** Working with `uipath init`, `uipath run`, or `uipath eval` commands
|
|
21
|
+
- **Contains:** Command syntax, options, usage examples, and workflows
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
## Required Agent Structure
|
|
2
|
+
|
|
3
|
+
**IMPORTANT**: All UiPath coded agents MUST follow this standard structure unless explicitly specified otherwise by the user.
|
|
4
|
+
|
|
5
|
+
### Required Components
|
|
6
|
+
|
|
7
|
+
Every agent implementation MUST include these three Pydantic models:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from pydantic import BaseModel
|
|
11
|
+
|
|
12
|
+
class Input(BaseModel):
|
|
13
|
+
"""Define input fields that the agent accepts"""
|
|
14
|
+
# Add your input fields here
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
class State(BaseModel):
|
|
18
|
+
"""Define the agent's internal state that flows between nodes"""
|
|
19
|
+
# Add your state fields here
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
class Output(BaseModel):
|
|
23
|
+
"""Define output fields that the agent returns"""
|
|
24
|
+
# Add your output fields here
|
|
25
|
+
pass
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Required LLM Initialization
|
|
29
|
+
|
|
30
|
+
Unless the user explicitly requests a different LLM provider, always use `UiPathChat`:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from uipath_langchain.chat import UiPathChat
|
|
34
|
+
|
|
35
|
+
llm = UiPathChat(model="gpt-4o-2024-08-06", temperature=0.7)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Alternative LLMs** (only use if explicitly requested):
|
|
39
|
+
- `ChatOpenAI` from `langchain_openai`
|
|
40
|
+
- `ChatAnthropic` from `langchain_anthropic`
|
|
41
|
+
- Other LangChain-compatible LLMs
|
|
42
|
+
|
|
43
|
+
### Standard Agent Template
|
|
44
|
+
|
|
45
|
+
Every agent should follow this basic structure:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from langchain_core.messages import SystemMessage, HumanMessage
|
|
49
|
+
from langgraph.graph import START, StateGraph, END
|
|
50
|
+
from uipath_langchain.chat import UiPathChat
|
|
51
|
+
from pydantic import BaseModel
|
|
52
|
+
|
|
53
|
+
# 1. Define Input, State, and Output models
|
|
54
|
+
class Input(BaseModel):
|
|
55
|
+
field: str
|
|
56
|
+
|
|
57
|
+
class State(BaseModel):
|
|
58
|
+
field: str
|
|
59
|
+
result: str = ""
|
|
60
|
+
|
|
61
|
+
class Output(BaseModel):
|
|
62
|
+
result: str
|
|
63
|
+
|
|
64
|
+
# 2. Initialize UiPathChat LLM
|
|
65
|
+
llm = UiPathChat(model="gpt-4o-2024-08-06", temperature=0.7)
|
|
66
|
+
|
|
67
|
+
# 3. Define agent nodes (async functions)
|
|
68
|
+
async def process_node(state: State) -> State:
|
|
69
|
+
response = await llm.ainvoke([HumanMessage(state.field)])
|
|
70
|
+
return State(field=state.field, result=response.content)
|
|
71
|
+
|
|
72
|
+
async def output_node(state: State) -> Output:
|
|
73
|
+
return Output(result=state.result)
|
|
74
|
+
|
|
75
|
+
# 4. Build the graph
|
|
76
|
+
builder = StateGraph(State, input=Input, output=Output)
|
|
77
|
+
builder.add_node("process", process_node)
|
|
78
|
+
builder.add_node("output", output_node)
|
|
79
|
+
builder.add_edge(START, "process")
|
|
80
|
+
builder.add_edge("process", "output")
|
|
81
|
+
builder.add_edge("output", END)
|
|
82
|
+
|
|
83
|
+
# 5. Compile the graph
|
|
84
|
+
graph = builder.compile()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Key Rules**:
|
|
88
|
+
1. Always use async/await for all node functions
|
|
89
|
+
2. All nodes (except output) must accept and return `State`
|
|
90
|
+
3. The final output node must return `Output`
|
|
91
|
+
4. Use `StateGraph(State, input=Input, output=Output)` for initialization
|
|
92
|
+
5. Always compile with `graph = builder.compile()`
|
uipath_langchain/middlewares.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from uipath._cli.middlewares import Middlewares
|
|
2
2
|
|
|
3
|
+
from ._cli.cli_debug import langgraph_debug_middleware
|
|
3
4
|
from ._cli.cli_dev import langgraph_dev_middleware
|
|
4
5
|
from ._cli.cli_eval import langgraph_eval_middleware
|
|
5
6
|
from ._cli.cli_init import langgraph_init_middleware
|
|
@@ -14,3 +15,4 @@ def register_middleware():
|
|
|
14
15
|
Middlewares.register("new", langgraph_new_middleware)
|
|
15
16
|
Middlewares.register("dev", langgraph_dev_middleware)
|
|
16
17
|
Middlewares.register("eval", langgraph_eval_middleware)
|
|
18
|
+
Middlewares.register("debug", langgraph_debug_middleware)
|
|
File without changes
|
|
@@ -11,13 +11,13 @@ from langgraph.types import interrupt
|
|
|
11
11
|
from pydantic import BaseModel
|
|
12
12
|
from uipath import UiPath
|
|
13
13
|
from uipath.agent.models.agent import (
|
|
14
|
-
AgentDefinition,
|
|
15
14
|
AgentEscalationChannel,
|
|
16
15
|
AgentEscalationResourceConfig,
|
|
17
16
|
AgentIntegrationToolParameter,
|
|
18
17
|
AgentIntegrationToolResourceConfig,
|
|
19
18
|
AgentProcessToolResourceConfig,
|
|
20
19
|
AgentResourceConfig,
|
|
20
|
+
LowCodeAgentDefinition,
|
|
21
21
|
)
|
|
22
22
|
from uipath.models import CreateAction, InvokeProcess
|
|
23
23
|
from uipath.models.connections import ConnectionTokenType
|
|
@@ -208,7 +208,7 @@ def create_resource_tool(
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
def safe_extract_tools(
|
|
211
|
-
agent_definition:
|
|
211
|
+
agent_definition: LowCodeAgentDefinition, cache: Optional[BaseCache] = None
|
|
212
212
|
) -> list[BaseTool]:
|
|
213
213
|
tools = []
|
|
214
214
|
for resource in agent_definition.resources:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uipath-langchain
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.142
|
|
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
|
|
@@ -26,7 +26,7 @@ Requires-Dist: openai>=1.65.5
|
|
|
26
26
|
Requires-Dist: openinference-instrumentation-langchain>=0.1.50
|
|
27
27
|
Requires-Dist: pydantic-settings>=2.6.0
|
|
28
28
|
Requires-Dist: python-dotenv>=1.0.1
|
|
29
|
-
Requires-Dist: uipath<2.2.0,>=2.1.
|
|
29
|
+
Requires-Dist: uipath<2.2.0,>=2.1.101
|
|
30
30
|
Provides-Extra: langchain
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,80
|
|
2
|
-
uipath_langchain/middlewares.py,sha256=
|
|
2
|
+
uipath_langchain/middlewares.py,sha256=x3U_tmDIyMXPLzq6n-oNRAnpAF6pKa9wfkPYwE-oUfo,848
|
|
3
|
+
uipath_langchain/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
4
|
uipath_langchain/_cli/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
|
|
5
|
+
uipath_langchain/_cli/cli_debug.py,sha256=RQqBVne3OdXYPvgl5f7kIrV5zztA8W8LMXWex7oOQeU,3221
|
|
4
6
|
uipath_langchain/_cli/cli_dev.py,sha256=l3XFHrh-0OUFJq3zLMKuzedJAluGQBIZQTHP1KWOmpw,1725
|
|
5
7
|
uipath_langchain/_cli/cli_eval.py,sha256=r8mGlKh-ymxfKrvrU4n0Hg3pQv36c_NhTNR_eokyQEM,3650
|
|
6
|
-
uipath_langchain/_cli/cli_init.py,sha256=
|
|
8
|
+
uipath_langchain/_cli/cli_init.py,sha256=B-Ht1lz4HNlpYELZU7DLNhSrhGJbsaCdU9UMO2iHUgM,12654
|
|
7
9
|
uipath_langchain/_cli/cli_new.py,sha256=KKLxCzz7cDQ__rRr_a496IHWlSQXhmrBNgmKHnXAnTY,2336
|
|
8
|
-
uipath_langchain/_cli/cli_run.py,sha256
|
|
9
|
-
uipath_langchain/_cli/_runtime/_context.py,sha256=
|
|
10
|
+
uipath_langchain/_cli/cli_run.py,sha256=-k7QsfHWRQUAvVB6l533SCC9Xcxm7NSWq_oR0iy6THY,3426
|
|
11
|
+
uipath_langchain/_cli/_runtime/_context.py,sha256=mjmGEogKiO8tUV878BgV9rFIeA9MCmEH6hgs5W_dm4g,328
|
|
10
12
|
uipath_langchain/_cli/_runtime/_conversation.py,sha256=ayghRqhyLeVUZg1WHnpeOYtPNhRwDOl4z8OSYiJkWSU,11529
|
|
11
13
|
uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJs_xF0OQXCCOvbYM,546
|
|
12
14
|
uipath_langchain/_cli/_runtime/_graph_resolver.py,sha256=5SmYr3KJ_Iy13QtN8XPOOmoSrdysDGlLsgfiebHDXfs,5296
|
|
13
|
-
uipath_langchain/_cli/_runtime/_input.py,sha256=
|
|
14
|
-
uipath_langchain/_cli/_runtime/_output.py,sha256=
|
|
15
|
-
uipath_langchain/_cli/_runtime/_runtime.py,sha256=
|
|
15
|
+
uipath_langchain/_cli/_runtime/_input.py,sha256=MTupo0p4F1vCTQi_KPZYJ2Um1X3QCmm8GeqC32HZbks,5724
|
|
16
|
+
uipath_langchain/_cli/_runtime/_output.py,sha256=DOIxc9BKYtESOr9sLaBeppskWfUPse8B2PUDOFin0oU,4829
|
|
17
|
+
uipath_langchain/_cli/_runtime/_runtime.py,sha256=ImDBluxga_WbIm9lnljjm7jGl1tZBPy5hUrXYOCcOIE,18262
|
|
16
18
|
uipath_langchain/_cli/_templates/langgraph.json.template,sha256=eeh391Gta_hoRgaNaZ58nW1LNvCVXA7hlAH6l7Veous,107
|
|
17
19
|
uipath_langchain/_cli/_templates/main.py.template,sha256=GpSblGH2hwS9ibqQmX2iB2nsmOA5zDfEEF4ChLiMxbQ,875
|
|
18
20
|
uipath_langchain/_cli/_utils/_graph.py,sha256=nMJWy8FmaD9rqPUY2lHc5uVpUzbXD1RO12uJnhe0kdo,6803
|
|
21
|
+
uipath_langchain/_resources/AGENTS.md,sha256=5VmIfaQ6H91VxInnxFmJklURXeWIIQpGQTYBEmvvoVA,1060
|
|
22
|
+
uipath_langchain/_resources/REQUIRED_STRUCTURE.md,sha256=BRmWWFtM0qNXj5uumALVxq9h6pifJDGh5NzuyctuH1Q,2569
|
|
19
23
|
uipath_langchain/_tracing/__init__.py,sha256=UqrLc_WimpzKY82M0LJsgJ-HFQUQFjOmOlD1XQ8V-R4,181
|
|
20
24
|
uipath_langchain/_tracing/_instrument_traceable.py,sha256=8f9FyAKWE6kH1N8ErbpwqZHAzNjGwbLjQn7jdX5yAgA,4343
|
|
21
25
|
uipath_langchain/_tracing/_oteladapter.py,sha256=PD0gsC39ZNvrm0gsfnt1ti6DEy56sBA9sIoxaAbHFFM,8887
|
|
@@ -31,11 +35,11 @@ uipath_langchain/embeddings/embeddings.py,sha256=45gKyb6HVKigwE-0CXeZcAk33c0mtea
|
|
|
31
35
|
uipath_langchain/retrievers/__init__.py,sha256=rOn7PyyHgZ4pMnXWPkGqmuBmx8eGuo-Oyndo7Wm9IUU,108
|
|
32
36
|
uipath_langchain/retrievers/context_grounding_retriever.py,sha256=YLCIwy89LhLnNqcM0YJ5mZoeNyCs5UiKD3Wly8gnW1E,2239
|
|
33
37
|
uipath_langchain/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
uipath_langchain/tools/preconfigured.py,sha256=
|
|
38
|
+
uipath_langchain/tools/preconfigured.py,sha256=SyvrLrM1kezZxVVytgScVO8nBfVYfFGobWjY7erzsYU,7490
|
|
35
39
|
uipath_langchain/vectorstores/__init__.py,sha256=w8qs1P548ud1aIcVA_QhBgf_jZDrRMK5Lono78yA8cs,114
|
|
36
40
|
uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=TncIXG-YsUlO0R5ZYzWsM-Dj1SVCZbzmo2LraVxXelc,9559
|
|
37
|
-
uipath_langchain-0.0.
|
|
38
|
-
uipath_langchain-0.0.
|
|
39
|
-
uipath_langchain-0.0.
|
|
40
|
-
uipath_langchain-0.0.
|
|
41
|
-
uipath_langchain-0.0.
|
|
41
|
+
uipath_langchain-0.0.142.dist-info/METADATA,sha256=tvJ8KYbN0xmVw3LNm-y7LfazY0wBVPTCswXlNkulGmw,4276
|
|
42
|
+
uipath_langchain-0.0.142.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
43
|
+
uipath_langchain-0.0.142.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
|
|
44
|
+
uipath_langchain-0.0.142.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
|
|
45
|
+
uipath_langchain-0.0.142.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|