Skip to content

Commit bb506c3

Browse files
feat: use CreateDeepRagRaw and WaitEphemeralIndexRaw
1 parent ee34d32 commit bb506c3

File tree

7 files changed

+951
-456
lines changed

7 files changed

+951
-456
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.8.11"
3+
version = "0.8.12"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
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: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414
)
1515
from uipath.eval.mocks import mockable
1616
from uipath.platform import UiPath
17-
from uipath.platform.common import CreateBatchTransform, CreateDeepRag, UiPathConfig
17+
from uipath.platform.common import CreateBatchTransform, CreateDeepRagRaw, UiPathConfig
1818
from uipath.platform.context_grounding import (
1919
BatchTransformOutputColumn,
2020
CitationMode,
2121
DeepRagContent,
22+
DeepRagStatus,
2223
)
2324
from uipath.runtime.errors import UiPathErrorCategory
2425

2526
from uipath_langchain._utils import get_execution_folder_path
26-
from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode
27+
from uipath_langchain.agent.exceptions import (
28+
AgentRuntimeError,
29+
AgentRuntimeErrorCode,
30+
AgentStartupError,
31+
AgentStartupErrorCode,
32+
)
2733
from uipath_langchain.agent.react.jsonschema_pydantic_converter import (
2834
create_model as create_model_from_schema,
2935
)
@@ -261,7 +267,7 @@ async def context_tool_fn(
261267

262268
@durable_interrupt
263269
async def create_deep_rag():
264-
return CreateDeepRag(
270+
return CreateDeepRagRaw(
265271
name=f"task-{uuid.uuid4()}",
266272
index_name=index_name,
267273
prompt=actual_prompt,
@@ -270,7 +276,24 @@ async def create_deep_rag():
270276
glob_pattern=glob_pattern,
271277
)
272278

273-
return await create_deep_rag()
279+
result = await create_deep_rag()
280+
281+
if result.last_deep_rag_status == DeepRagStatus.FAILED:
282+
raise AgentRuntimeError(
283+
code=AgentRuntimeErrorCode.DEEP_RAG_FAILED,
284+
title="Deep RAG task failed",
285+
detail=str(result.failure_reason)
286+
if result.failure_reason
287+
else "Deep RAG task failed.",
288+
category=UiPathErrorCategory.USER,
289+
)
290+
291+
if result.content:
292+
content = result.content.model_dump()
293+
content["deepRagId"] = result.id
294+
return content
295+
296+
return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}
274297

275298
return StructuredToolWithArgumentProperties(
276299
name=tool_name,

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

Lines changed: 40 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,22 @@ 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)
175+
if result.failure_reason
176+
else "Deep RAG task failed.",
177+
category=UiPathErrorCategory.USER,
178+
)
179+
180+
if result.content:
181+
content = result.content.model_dump()
182+
content["deepRagId"] = result.id
183+
return content
184+
185+
return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}
151186

152187
return await invoke_deeprag(**kwargs)
153188

0 commit comments

Comments
 (0)