Skip to content

Commit 914c353

Browse files
feat: use CreateDeepRagRaw and WaitEphemeralIndexRaw
1 parent 9a58c20 commit 914c353

7 files changed

Lines changed: 904 additions & 454 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.0, <2.11.0",
99
"uipath-core>=0.5.2, <0.6.0",
10-
"uipath-platform>=0.0.8, <0.1.0",
10+
"uipath-platform==0.0.17",
1111
"uipath-runtime>=0.9.1, <0.10.0",
1212
"langgraph>=1.0.0, <2.0.0",
1313
"langchain-core>=1.2.11, <2.0.0",

src/uipath_langchain/agent/exceptions/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class AgentRuntimeErrorCode(str, Enum):
4545
# State
4646
STATE_ERROR = "STATE_ERROR"
4747

48+
# Context Grounding
49+
EPHEMERAL_INDEX_INGESTION_FAILED = "EPHEMERAL_INDEX_FAILED"
50+
DEEP_RAG_FAILED = "DEEP_RAG_FAILED"
51+
4852
LLM_INVALID_RESPONSE = "LLM_INVALID_RESPONSE"
4953
TOOL_INVALID_WRAPPER_STATE = "TOOL_INVALID_WRAPPER_STATE"
5054

src/uipath_langchain/agent/tools/context_tool.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@
1313
)
1414
from uipath.eval.mocks import mockable
1515
from uipath.platform import UiPath
16-
from uipath.platform.common import CreateBatchTransform, CreateDeepRag, UiPathConfig
16+
from uipath.platform.common import CreateBatchTransform, CreateDeepRagRaw, UiPathConfig
1717
from uipath.platform.context_grounding import (
1818
BatchTransformOutputColumn,
1919
CitationMode,
2020
DeepRagContent,
21+
DeepRagStatus,
2122
)
2223
from uipath.runtime.errors import UiPathErrorCategory
2324

2425
from uipath_langchain._utils import get_execution_folder_path
25-
from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode
26+
from uipath_langchain.agent.exceptions import (
27+
AgentRuntimeError,
28+
AgentRuntimeErrorCode,
29+
AgentStartupError,
30+
AgentStartupErrorCode,
31+
)
2632
from uipath_langchain.agent.react.jsonschema_pydantic_converter import (
2733
create_model as create_model_from_schema,
2834
)
@@ -200,7 +206,7 @@ async def context_tool_fn(query: Optional[str] = None) -> dict[str, Any]:
200206

201207
@durable_interrupt
202208
async def create_deep_rag():
203-
return CreateDeepRag(
209+
return CreateDeepRagRaw(
204210
name=f"task-{uuid.uuid4()}",
205211
index_name=index_name,
206212
prompt=actual_prompt,
@@ -209,7 +215,22 @@ async def create_deep_rag():
209215
glob_pattern=glob_pattern,
210216
)
211217

212-
return await create_deep_rag()
218+
result = await create_deep_rag()
219+
220+
if result.last_deep_rag_status == DeepRagStatus.FAILED:
221+
raise AgentRuntimeError(
222+
code=AgentRuntimeErrorCode.DEEP_RAG_FAILED,
223+
title="Deep RAG task failed",
224+
detail=str(result.failure_reason) if result.failure_reason else "Deep RAG task failed.",
225+
category=UiPathErrorCategory.USER,
226+
)
227+
228+
if result.content:
229+
content = result.content.model_dump()
230+
content["deepRagId"] = result.id
231+
return content
232+
233+
return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}
213234

214235
return StructuredToolWithOutputType(
215236
name=tool_name,

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

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,24 @@
1212
)
1313
from uipath.eval.mocks import mockable
1414
from uipath.platform import UiPath
15-
from uipath.platform.common import CreateDeepRag, WaitEphemeralIndex
15+
from uipath.platform.common import CreateDeepRagRaw, WaitEphemeralIndexRaw
1616
from uipath.platform.context_grounding import (
1717
CitationMode,
18+
DeepRagStatus,
1819
EphemeralIndexUsage,
20+
IndexStatus,
1921
)
2022
from uipath.platform.context_grounding.context_grounding_index import (
2123
ContextGroundingIndex,
2224
)
2325
from uipath.runtime.errors import UiPathErrorCategory
2426

25-
from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode
27+
from uipath_langchain.agent.exceptions import (
28+
AgentRuntimeError,
29+
AgentRuntimeErrorCode,
30+
AgentStartupError,
31+
AgentStartupErrorCode,
32+
)
2633
from uipath_langchain.agent.react.jsonschema_pydantic_converter import create_model
2734
from uipath_langchain.agent.react.types import AgentGraphState
2835
from uipath_langchain.agent.tools.durable_interrupt import (
@@ -125,7 +132,7 @@ async def create_ephemeral_index():
125132
)
126133
)
127134
if ephemeral_index.in_progress_ingestion():
128-
return WaitEphemeralIndex(index=ephemeral_index)
135+
return WaitEphemeralIndexRaw(index=ephemeral_index)
129136
return ReadyEphemeralIndex(index=ephemeral_index)
130137

131138
index_result = await create_ephemeral_index()
@@ -134,9 +141,22 @@ async def create_ephemeral_index():
134141
else:
135142
ephemeral_index = index_result
136143

144+
if ephemeral_index.last_ingestion_status == IndexStatus.FAILED:
145+
detail = (
146+
f"Attachment ingestion failed. Please check all your attachments are valid. Error: {ephemeral_index.last_ingestion_failure_reason}"
147+
if ephemeral_index.last_ingestion_failure_reason
148+
else "Ephemeral index ingestion failed."
149+
)
150+
raise AgentRuntimeError(
151+
code=AgentRuntimeErrorCode.EPHEMERAL_INDEX_INGESTION_FAILED,
152+
title="Ephemeral index ingestion failed",
153+
detail=detail,
154+
category=UiPathErrorCategory.USER,
155+
)
156+
137157
@durable_interrupt
138158
async def create_deeprag():
139-
return CreateDeepRag(
159+
return CreateDeepRagRaw(
140160
name=f"task-{uuid.uuid4()}",
141161
index_name=ephemeral_index.name,
142162
index_id=ephemeral_index.id,
@@ -147,7 +167,20 @@ async def create_deeprag():
147167

148168
result = await create_deeprag()
149169

150-
return result
170+
if result.last_deep_rag_status == DeepRagStatus.FAILED:
171+
raise AgentRuntimeError(
172+
code=AgentRuntimeErrorCode.DEEP_RAG_FAILED,
173+
title="Deep RAG task failed",
174+
detail=str(result.failure_reason) if result.failure_reason else "Deep RAG task failed.",
175+
category=UiPathErrorCategory.USER,
176+
)
177+
178+
if result.content:
179+
content = result.content.model_dump()
180+
content["deepRagId"] = result.id
181+
return content
182+
183+
return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}
151184

152185
return await invoke_deeprag(**kwargs)
153186

0 commit comments

Comments
 (0)