Skip to content

Commit 2d41733

Browse files
add batch rag
1 parent e56638e commit 2d41733

3 files changed

Lines changed: 66 additions & 12 deletions

File tree

src/uipath/agent/models/agent.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class AgentInternalToolType(str, Enum):
6363

6464
ANALYZE_FILES = "analyze-attachments"
6565
DEEP_RAG = "deep-rag"
66+
BATCH_TRANSFORM = "batch-transform"
6667

6768

6869
class AgentEscalationRecipientType(str, Enum):
@@ -127,13 +128,26 @@ class CitationMode(str, Enum):
127128
SKIP = "Skip"
128129

129130

130-
class FileExtension(str, Enum):
131-
"""File extension enumeration."""
131+
class DeepRagFileExtension(str, Enum):
132+
"""File extension enumeration for DeepRAG."""
132133

133134
PDF = "pdf"
134135
TXT = "txt"
135136

136137

138+
class BatchTransformFileExtension(str, Enum):
139+
"""File extension enumeration for Batch Transform."""
140+
141+
CSV = "csv"
142+
143+
144+
class BatchTransformWebSearchGrounding(str, Enum):
145+
"""Batch Transform web search grounding enumeration."""
146+
147+
ENABLED = "Enabled"
148+
DISABLED = "Disabled"
149+
150+
137151
class BaseCfg(BaseModel):
138152
"""Base configuration model with common settings."""
139153

@@ -269,7 +283,19 @@ class DeepRagCitationModeSetting(BaseCfg):
269283
class DeepRagFileExtensionSetting(BaseCfg):
270284
"""DeepRAG file extension setting model."""
271285

272-
value: FileExtension = Field(...)
286+
value: DeepRagFileExtension = Field(...)
287+
288+
289+
class BatchTransformFileExtensionSetting(BaseCfg):
290+
"""Batch Transform file extension setting model."""
291+
292+
value: BatchTransformFileExtension = Field(...)
293+
294+
295+
class BatchTransformWebSearchGroundingSetting(BaseCfg):
296+
"""DeepRAG file extension setting model."""
297+
298+
value: BatchTransformWebSearchGrounding = Field(...)
273299

274300

275301
class AgentContextOutputColumn(BaseCfg):
@@ -549,10 +575,20 @@ class AgentInternalDeepRagToolProperties(BaseResourceProperties):
549575
settings: AgentInternalDeepRagSettings = Field(..., alias="settings")
550576

551577

578+
class AgentInternalBatchTransformToolProperties(BaseResourceProperties):
579+
"""Agent internal Batch Tranform tool properties model."""
580+
581+
tool_type: Literal[AgentInternalToolType.BATCH_TRANSFORM] = Field(
582+
alias="toolType", default=AgentInternalToolType.BATCH_TRANSFORM, frozen=True
583+
)
584+
settings: AgentInternalBatchTransformSettings = Field(..., alias="settings")
585+
586+
552587
AgentInternalToolProperties = Annotated[
553588
Union[
554589
AgentInternalAnalyzeFilesToolProperties,
555590
AgentInternalDeepRagToolProperties,
591+
AgentInternalBatchTransformToolProperties,
556592
],
557593
Field(discriminator="tool_type"),
558594
]
@@ -562,12 +598,27 @@ class AgentInternalDeepRagSettings(BaseCfg):
562598
"""Agent internal DeepRAG tool settings model."""
563599

564600
context_type: str = Field(..., alias="contextType")
565-
query: AgentContextQuerySetting = Field(None)
601+
query: AgentContextQuerySetting = Field(...)
566602
folder_path_prefix: AgentContextQuerySetting = Field(None, alias="folderPathPrefix")
567603
citation_mode: DeepRagCitationModeSetting = Field(..., alias="citationMode")
568604
file_extension: DeepRagFileExtensionSetting = Field(..., alias="fileExtension")
569605

570606

607+
class AgentInternalBatchTransformSettings(BaseCfg):
608+
"""Agent internal DeepRAG tool settings model."""
609+
610+
context_type: str = Field(..., alias="contextType")
611+
query: AgentContextQuerySetting = Field(...)
612+
folder_path_prefix: AgentContextQuerySetting = Field(None, alias="folderPathPrefix")
613+
file_extension: BatchTransformFileExtensionSetting = Field(
614+
..., alias="fileExtension"
615+
)
616+
output_columns: List[AgentContextOutputColumn] = Field(..., alias="outputColumns")
617+
web_search_grounding: BatchTransformWebSearchGroundingSetting = Field(
618+
..., alias="folderPathPrefix"
619+
)
620+
621+
571622
class AgentIntegrationToolResourceConfig(BaseAgentToolResourceConfig):
572623
"""Agent integration tool resource configuration model."""
573624

src/uipath/platform/context_grounding/_context_grounding_service.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ def start_deep_rag(
842842
prompt: Annotated[str, Field(max_length=250000)],
843843
glob_pattern: Annotated[str, Field(max_length=512, default="*")] = "**",
844844
citation_mode: CitationMode = CitationMode.SKIP,
845+
index_id: Annotated[str, Field(max_length=512)] | None = None,
845846
folder_key: str | None = None,
846847
folder_path: str | None = None,
847848
) -> DeepRagCreationResponse:
@@ -855,18 +856,20 @@ def start_deep_rag(
855856
citation_mode (CitationMode): The citation mode to use. Defaults to SKIP.
856857
folder_key (str, optional): The folder key where the index resides. Defaults to None.
857858
folder_path (str, optional): The folder path where the index resides. Defaults to None.
859+
index_id (str): The id of the context index to search in, used in place of name if present
858860
859861
Returns:
860862
DeepRagCreationResponse: The Deep RAG task creation response.
861863
"""
862-
index = self.retrieve(
863-
index_name, folder_key=folder_key, folder_path=folder_path
864-
)
865-
if index and index.in_progress_ingestion():
866-
raise IngestionInProgressException(index_name=index_name)
864+
if not index_id:
865+
index = self.retrieve(
866+
index_name, folder_key=folder_key, folder_path=folder_path
867+
)
868+
if index and index.in_progress_ingestion():
869+
raise IngestionInProgressException(index_name=index_name)
867870

868871
spec = self._deep_rag_creation_spec(
869-
index_id=index.id,
872+
index_id=index_id,
870873
name=name,
871874
glob_pattern=glob_pattern,
872875
prompt=prompt,
@@ -891,10 +894,10 @@ async def start_deep_rag_async(
891894
self,
892895
name: str,
893896
index_name: Annotated[str, Field(max_length=512)],
894-
index_id: Annotated[str, Field(max_length=512)],
895897
prompt: Annotated[str, Field(max_length=250000)],
896898
glob_pattern: Annotated[str, Field(max_length=512, default="*")] = "**",
897899
citation_mode: CitationMode = CitationMode.SKIP,
900+
index_id: Annotated[str, Field(max_length=512)] | None = None,
898901
folder_key: str | None = None,
899902
folder_path: str | None = None,
900903
) -> DeepRagCreationResponse:
@@ -909,6 +912,7 @@ async def start_deep_rag_async(
909912
citation_mode (CitationMode): The citation mode to use. Defaults to SKIP.
910913
folder_key (str, optional): The folder key where the index resides. Defaults to None.
911914
folder_path (str, optional): The folder path where the index resides. Defaults to None.
915+
index_id (str): The id of the context index to search in, used in place of name if present
912916
913917
Returns:
914918
DeepRagCreationResponse: The Deep RAG task creation response.

tests/sdk/services/test_context_grounding_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,6 @@ async def test_create_ephemeral_index_async(
18381838
)
18391839

18401840
attachment_ids = [str(uuid.uuid4()), str(uuid.uuid4())]
1841-
18421841
index = await service.create_ephemeral_index_async(
18431842
usage="DeepRAG",
18441843
attachments=attachment_ids,

0 commit comments

Comments
 (0)