Skip to content

Commit bfb4d37

Browse files
authored
feat: send current job folder_path on ephemeral index creation [ECS-1745] (#775)
1 parent c5368a6 commit bfb4d37

6 files changed

Lines changed: 110 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ requires-python = ">=3.11"
77
dependencies = [
88
"uipath>=2.10.49, <2.11.0",
99
"uipath-core>=0.5.2, <0.6.0",
10-
"uipath-platform>=0.1.29, <0.2.0",
10+
"uipath-platform>=0.1.30, <0.2.0",
1111
"uipath-runtime>=0.10.0, <0.11.0",
1212
"langgraph>=1.0.0, <2.0.0",
1313
"langchain-core>=1.2.11, <2.0.0",

src/uipath_langchain/agent/tools/internal_tools/batch_transform_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
from uipath.runtime.errors import UiPathErrorCategory
2727

28+
from uipath_langchain._utils import get_execution_folder_path
2829
from uipath_langchain._utils.durable_interrupt import (
2930
SkipInterruptValue,
3031
durable_interrupt,
@@ -137,6 +138,7 @@ async def create_ephemeral_index():
137138
await uipath.context_grounding.create_ephemeral_index_async(
138139
usage=EphemeralIndexUsage.BATCH_RAG,
139140
attachments=[attachment_id],
141+
folder_path=get_execution_folder_path(),
140142
)
141143
)
142144
if ephemeral_index.in_progress_ingestion():

src/uipath_langchain/agent/tools/internal_tools/deeprag_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from uipath.runtime.errors import UiPathErrorCategory
2323

24+
from uipath_langchain._utils import get_execution_folder_path
2425
from uipath_langchain._utils.durable_interrupt import (
2526
SkipInterruptValue,
2627
durable_interrupt,
@@ -118,6 +119,7 @@ async def create_ephemeral_index():
118119
await uipath.context_grounding.create_ephemeral_index_async(
119120
usage=EphemeralIndexUsage.DEEP_RAG,
120121
attachments=[attachment_id],
122+
folder_path=get_execution_folder_path(),
121123
)
122124
)
123125
if ephemeral_index.in_progress_ingestion():

tests/agent/tools/internal_tools/test_batch_transform_tool.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for batch_transform_tool.py module."""
22

3+
import os
34
import uuid
45
from unittest.mock import AsyncMock, Mock, patch
56

@@ -547,6 +548,57 @@ async def test_create_batch_transform_tool_custom_destination_path(
547548
job_key="test-job-key",
548549
)
549550

551+
@patch(
552+
"uipath_langchain.agent.wrappers.job_attachment_wrapper.get_job_attachment_wrapper"
553+
)
554+
@patch("uipath_langchain.agent.tools.internal_tools.batch_transform_tool.UiPath")
555+
@patch("uipath_langchain._utils.durable_interrupt.decorator.interrupt")
556+
@patch(
557+
"uipath_langchain.agent.tools.internal_tools.batch_transform_tool.mockable",
558+
lambda **kwargs: lambda f: f,
559+
)
560+
@patch.dict(os.environ, {"UIPATH_FOLDER_PATH": "/Shared/TestFolder"})
561+
async def test_create_ephemeral_index_passes_folder_path(
562+
self,
563+
mock_interrupt,
564+
mock_uipath_class,
565+
mock_get_wrapper,
566+
resource_config_static,
567+
mock_llm,
568+
):
569+
"""Test that create_ephemeral_index_async receives folder_path from the execution environment."""
570+
mock_uipath = AsyncMock()
571+
mock_uipath_class.return_value = mock_uipath
572+
mock_uipath_config = Mock()
573+
mock_uipath_config.job_key = "test-job-key"
574+
575+
mock_index = ContextGroundingIndex(
576+
id=str(uuid.uuid4()),
577+
name="ephemeral-batch-folder",
578+
last_ingestion_status="Successful",
579+
)
580+
mock_uipath.context_grounding.create_ephemeral_index_async = AsyncMock(
581+
return_value=mock_index
582+
)
583+
mock_interrupt.side_effect = [{"file_path": "output.csv"}]
584+
mock_uipath.jobs.create_attachment_async = AsyncMock(return_value=uuid.uuid4())
585+
586+
mock_wrapper = Mock()
587+
mock_get_wrapper.return_value = mock_wrapper
588+
589+
tool = create_batch_transform_tool(resource_config_static, mock_llm)
590+
mock_attachment = MockAttachment(
591+
ID=str(uuid.uuid4()), FullName="data.csv", MimeType="text/csv"
592+
)
593+
594+
assert tool.coroutine is not None
595+
await tool.coroutine(attachment=mock_attachment)
596+
597+
call_kwargs = (
598+
mock_uipath.context_grounding.create_ephemeral_index_async.call_args.kwargs
599+
)
600+
assert call_kwargs["folder_path"] == "/Shared/TestFolder"
601+
550602
@patch(
551603
"uipath_langchain.agent.wrappers.job_attachment_wrapper.get_job_attachment_wrapper"
552604
)

tests/agent/tools/internal_tools/test_deeprag_tool.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for deeprag_tool.py module."""
22

3+
import os
34
import uuid
45
from unittest.mock import AsyncMock, Mock, patch
56

@@ -368,3 +369,51 @@ class AttachmentWithoutID(BaseModel):
368369
assert tool.coroutine is not None
369370
with pytest.raises(ValueError, match="Attachment ID is required"):
370371
await tool.coroutine(attachment=mock_attachment)
372+
373+
@patch(
374+
"uipath_langchain.agent.wrappers.job_attachment_wrapper.get_job_attachment_wrapper"
375+
)
376+
@patch("uipath_langchain.agent.tools.internal_tools.deeprag_tool.UiPath")
377+
@patch("uipath_langchain._utils.durable_interrupt.decorator.interrupt")
378+
@patch(
379+
"uipath_langchain.agent.tools.internal_tools.deeprag_tool.mockable",
380+
lambda **kwargs: lambda f: f,
381+
)
382+
@patch.dict(os.environ, {"UIPATH_FOLDER_PATH": "/Shared/TestFolder"})
383+
async def test_create_ephemeral_index_passes_folder_path(
384+
self,
385+
mock_interrupt,
386+
mock_uipath_class,
387+
mock_get_wrapper,
388+
resource_config_static,
389+
mock_llm,
390+
):
391+
"""Test that create_ephemeral_index_async receives folder_path from the execution environment."""
392+
mock_uipath = AsyncMock()
393+
mock_uipath_class.return_value = mock_uipath
394+
395+
mock_index = ContextGroundingIndex(
396+
id=str(uuid.uuid4()),
397+
name="ephemeral-index-folder",
398+
last_ingestion_status="Successful",
399+
)
400+
mock_uipath.context_grounding.create_ephemeral_index_async = AsyncMock(
401+
return_value=mock_index
402+
)
403+
mock_interrupt.side_effect = [{"text": "result"}]
404+
405+
mock_wrapper = Mock()
406+
mock_get_wrapper.return_value = mock_wrapper
407+
408+
tool = create_deeprag_tool(resource_config_static, mock_llm)
409+
mock_attachment = MockAttachment(
410+
ID=str(uuid.uuid4()), FullName="test.pdf", MimeType="application/pdf"
411+
)
412+
413+
assert tool.coroutine is not None
414+
await tool.coroutine(attachment=mock_attachment)
415+
416+
call_kwargs = (
417+
mock_uipath.context_grounding.create_ephemeral_index_async.call_args.kwargs
418+
)
419+
assert call_kwargs["folder_path"] == "/Shared/TestFolder"

uv.lock

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

0 commit comments

Comments
 (0)