Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "uipath-langchain"
version = "0.8.11"
version = "0.8.12"
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"uipath>=2.10.0, <2.11.0",
"uipath-core>=0.5.2, <0.6.0",
"uipath-platform>=0.0.8, <0.1.0",
"uipath-platform==0.0.17",
"uipath-runtime>=0.9.1, <0.10.0",
"langgraph>=1.0.0, <2.0.0",
"langchain-core>=1.2.11, <2.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/uipath_langchain/agent/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class AgentRuntimeErrorCode(str, Enum):
# State
STATE_ERROR = "STATE_ERROR"

# Context Grounding
EPHEMERAL_INDEX_INGESTION_FAILED = "EPHEMERAL_INDEX_FAILED"
DEEP_RAG_FAILED = "DEEP_RAG_FAILED"

LLM_INVALID_RESPONSE = "LLM_INVALID_RESPONSE"
TOOL_INVALID_WRAPPER_STATE = "TOOL_INVALID_WRAPPER_STATE"

Expand Down
31 changes: 27 additions & 4 deletions src/uipath_langchain/agent/tools/context_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
)
from uipath.eval.mocks import mockable
from uipath.platform import UiPath
from uipath.platform.common import CreateBatchTransform, CreateDeepRag, UiPathConfig
from uipath.platform.common import CreateBatchTransform, CreateDeepRagRaw, UiPathConfig
from uipath.platform.context_grounding import (
BatchTransformOutputColumn,
CitationMode,
DeepRagContent,
DeepRagStatus,
)
from uipath.runtime.errors import UiPathErrorCategory

from uipath_langchain._utils import get_execution_folder_path
from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode
from uipath_langchain.agent.exceptions import (
AgentRuntimeError,
AgentRuntimeErrorCode,
AgentStartupError,
AgentStartupErrorCode,
)
from uipath_langchain.agent.react.jsonschema_pydantic_converter import (
create_model as create_model_from_schema,
)
Expand Down Expand Up @@ -261,7 +267,7 @@ async def context_tool_fn(

@durable_interrupt
async def create_deep_rag():
return CreateDeepRag(
return CreateDeepRagRaw(
name=f"task-{uuid.uuid4()}",
index_name=index_name,
prompt=actual_prompt,
Expand All @@ -270,7 +276,24 @@ async def create_deep_rag():
glob_pattern=glob_pattern,
)

return await create_deep_rag()
result = await create_deep_rag()

if result.last_deep_rag_status == DeepRagStatus.FAILED:
raise AgentRuntimeError(
code=AgentRuntimeErrorCode.DEEP_RAG_FAILED,
title="Deep RAG task failed",
detail=str(result.failure_reason)
if result.failure_reason
else "Deep RAG task failed.",
category=UiPathErrorCategory.USER,
)

if result.content:
content = result.content.model_dump()
content["deepRagId"] = result.id
return content

return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}

return StructuredToolWithArgumentProperties(
name=tool_name,
Expand Down
45 changes: 40 additions & 5 deletions src/uipath_langchain/agent/tools/internal_tools/deeprag_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@
)
from uipath.eval.mocks import mockable
from uipath.platform import UiPath
from uipath.platform.common import CreateDeepRag, WaitEphemeralIndex
from uipath.platform.common import CreateDeepRagRaw, WaitEphemeralIndexRaw
from uipath.platform.context_grounding import (
CitationMode,
DeepRagStatus,
EphemeralIndexUsage,
IndexStatus,
)
from uipath.platform.context_grounding.context_grounding_index import (
ContextGroundingIndex,
)
from uipath.runtime.errors import UiPathErrorCategory

from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode
from uipath_langchain.agent.exceptions import (
AgentRuntimeError,
AgentRuntimeErrorCode,
AgentStartupError,
AgentStartupErrorCode,
)
from uipath_langchain.agent.react.jsonschema_pydantic_converter import create_model
from uipath_langchain.agent.react.types import AgentGraphState
from uipath_langchain.agent.tools.durable_interrupt import (
Expand Down Expand Up @@ -125,7 +132,7 @@ async def create_ephemeral_index():
)
)
if ephemeral_index.in_progress_ingestion():
return WaitEphemeralIndex(index=ephemeral_index)
return WaitEphemeralIndexRaw(index=ephemeral_index)
return ReadyEphemeralIndex(index=ephemeral_index)

index_result = await create_ephemeral_index()
Expand All @@ -134,9 +141,22 @@ async def create_ephemeral_index():
else:
ephemeral_index = index_result

if ephemeral_index.last_ingestion_status == IndexStatus.FAILED:
detail = (
f"Attachment ingestion failed. Please check all your attachments are valid. Error: {ephemeral_index.last_ingestion_failure_reason}"
if ephemeral_index.last_ingestion_failure_reason
else "Ephemeral index ingestion failed."
)
raise AgentRuntimeError(
code=AgentRuntimeErrorCode.EPHEMERAL_INDEX_INGESTION_FAILED,
title="Ephemeral index ingestion failed",
detail=detail,
category=UiPathErrorCategory.USER,
)

@durable_interrupt
async def create_deeprag():
return CreateDeepRag(
return CreateDeepRagRaw(
name=f"task-{uuid.uuid4()}",
index_name=ephemeral_index.name,
index_id=ephemeral_index.id,
Expand All @@ -147,7 +167,22 @@ async def create_deeprag():

result = await create_deeprag()

return result
if result.last_deep_rag_status == DeepRagStatus.FAILED:
raise AgentRuntimeError(
code=AgentRuntimeErrorCode.DEEP_RAG_FAILED,
title="Deep RAG task failed",
detail=str(result.failure_reason)
if result.failure_reason
else "Deep RAG task failed.",
category=UiPathErrorCategory.USER,
)

if result.content:
content = result.content.model_dump()
content["deepRagId"] = result.id
return content

return {"status": result.last_deep_rag_status, "__internal": "NO_CONTENT"}

return await invoke_deeprag(**kwargs)

Expand Down
Loading
Loading