Skip to content

Commit 9ee9795

Browse files
committed
feat: add agent extraction tool
1 parent 7a9bbb5 commit 9ee9795

4 files changed

Lines changed: 77 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ description = "Python SDK that enables developers to build and deploy LangGraph
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath>=2.4.0, <2.5.0",
9-
"uipath-runtime>=0.4.0, <0.5.0",
8+
"uipath-runtime>=0.4.0, <0.5.0",
109
"langgraph>=1.0.0, <2.0.0",
1110
"langchain-core>=1.2.5, <2.0.0",
1211
"aiosqlite==0.21.0",
@@ -21,6 +20,7 @@ dependencies = [
2120
"jsonpath-ng>=1.7.0",
2221
"mcp==1.24.0",
2322
"langchain-mcp-adapters==0.2.1",
23+
"uipath==2.4.11.dev1010893714",
2424
]
2525

2626
classifiers = [
@@ -115,3 +115,6 @@ name = "testpypi"
115115
url = "https://test.pypi.org/simple/"
116116
publish-url = "https://test.pypi.org/legacy/"
117117
explicit = true
118+
119+
[tool.uv.sources]
120+
uipath = { index = "testpypi" }

src/uipath_langchain/agent/tools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .tool_factory import (
99
create_tools_from_resources,
1010
)
11+
from .extraction_tool import create_ixp_extraction_tool
1112
from .tool_node import ToolWrapperMixin, UiPathToolNode, create_tool_node
1213

1314
__all__ = [
@@ -18,6 +19,7 @@
1819
"create_integration_tool",
1920
"create_escalation_tool",
2021
"create_mcp_tools",
22+
"create_ixp_extraction_tool",
2123
"UiPathToolNode",
2224
"ToolWrapperMixin",
2325
]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""Process tool creation for UiPath process execution."""
2+
3+
from typing import Any
4+
5+
from langchain_core.tools import StructuredTool
6+
from langgraph.types import interrupt
7+
from uipath.agent.models.agent import AgentIxpExtractionResourceConfig
8+
from uipath.eval.mocks import mockable
9+
from uipath.platform.common import DocumentExtraction
10+
from uipath.platform.attachments import Attachment
11+
from uipath.platform.documents import ExtractionResponseIXP
12+
13+
from .structured_tool_with_output_type import StructuredToolWithOutputType
14+
from .utils import sanitize_tool_name
15+
16+
17+
def create_ixp_extraction_tool(resource: AgentIxpExtractionResourceConfig) -> StructuredTool:
18+
"""Uses interrupt() to suspend graph execution until data is extracted (handled by runtime)."""
19+
tool_name: str = sanitize_tool_name(resource.name)
20+
project_name = resource.properties.project_name
21+
version_tag = resource.properties.version_tag
22+
23+
@mockable(
24+
name=resource.name,
25+
description=resource.description,
26+
input_schema=Attachment.model_json_schema(),
27+
output_schema=ExtractionResponseIXP.model_json_schema(),
28+
example_calls=resource.properties.example_calls,
29+
)
30+
async def escalation_tool_fn(attachment: Attachment):
31+
# current workaround. DocumentExtraction model should support attachment_id and use the
32+
# start_ixp_extraction_from_attachment sdk method once support is added
33+
from uipath.platform import UiPath
34+
uipath = UiPath()
35+
attachment_local_file_path = await uipath.attachments.download_async(
36+
key=attachment.id,
37+
destination_path=attachment.full_name
38+
)
39+
return interrupt(
40+
DocumentExtraction(
41+
project_name=project_name,
42+
tag=version_tag,
43+
file_path=attachment_local_file_path,
44+
)
45+
)
46+
47+
tool = StructuredToolWithOutputType(
48+
name=tool_name,
49+
description=resource.description,
50+
args_schema=Attachment,
51+
coroutine=escalation_tool_fn,
52+
output_type=ExtractionResponseIXP,
53+
)
54+
55+
return tool

uv.lock

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)