2525
2626from uipath_langchain .agent .react .jsonschema_pydantic_converter import create_model
2727from uipath_langchain .agent .react .types import AgentGraphState
28+ from uipath_langchain .agent .tools .internal_tools .schema_utils import (
29+ add_query_field_to_schema ,
30+ )
2831from uipath_langchain .agent .tools .static_args import handle_static_args
2932from uipath_langchain .agent .tools .structured_tool_with_argument_properties import (
3033 StructuredToolWithArgumentProperties ,
@@ -53,11 +56,9 @@ def create_batch_transform_tool(
5356 output_columns_setting = settings .output_columns
5457 web_search_grounding_setting = settings .web_search_grounding
5558
56- # Check if query is dynamic or static
5759 is_query_static = query_setting and query_setting .variant == "static"
5860 static_query = query_setting .value if is_query_static else None
5961
60- # Get static values for other settings
6162 static_folder_path_prefix = None
6263 if folder_path_prefix_setting :
6364 static_folder_path_prefix = getattr (folder_path_prefix_setting , "value" , None )
@@ -67,7 +68,6 @@ def create_batch_transform_tool(
6768 value = getattr (web_search_grounding_setting , "value" , None )
6869 static_web_search = value == "Enabled" if value else False
6970
70- # Convert output columns to BatchTransformOutputColumn
7171 batch_transform_output_columns = [
7272 BatchTransformOutputColumn (name = col .name , description = col .description or "" )
7373 for col in output_columns_setting
@@ -76,18 +76,11 @@ def create_batch_transform_tool(
7676 # Use resource input schema and add query field if dynamic
7777 input_schema = dict (resource .input_schema )
7878 if not is_query_static :
79- if "properties" not in input_schema :
80- input_schema ["properties" ] = {}
81- input_schema ["properties" ]["query" ] = {
82- "type" : "string" ,
83- "description" : query_setting .description
84- if query_setting and query_setting .description
85- else "The query to create a batch transform off of" ,
86- }
87- if "required" not in input_schema :
88- input_schema ["required" ] = []
89- if "query" not in input_schema ["required" ]:
90- input_schema ["required" ].append ("query" )
79+ add_query_field_to_schema (
80+ input_schema ,
81+ query_description = query_setting .description if query_setting else None ,
82+ default_description = "Describe the task: what to research, what to synthesize." ,
83+ )
9184
9285 # Create input model from modified schema
9386 input_model = create_model (input_schema )
@@ -101,7 +94,6 @@ def create_batch_transform_tool(
10194 example_calls = [], # Examples cannot be provided for internal tools
10295 )
10396 async def batch_transform_tool_fn (** kwargs : Any ) -> dict [str , Any ]:
104- # Get query - dynamic from kwargs or static from settings
10597 query = kwargs .get ("query" ) if not is_query_static else static_query
10698 if not query :
10799 raise ValueError ("Query is required for Batch Transform tool" )
@@ -113,27 +105,22 @@ async def batch_transform_tool_fn(**kwargs: Any) -> dict[str, Any]:
113105 if not attachment :
114106 raise ValueError ("Attachment is required for Batch Transform tool" )
115107
116- # Extract attachment ID using getattr (works for Pydantic models)
117108 attachment_id = getattr (attachment , "ID" , None )
118109 if not attachment_id :
119110 raise ValueError ("Attachment ID is required" )
120111
121- # Get destination path, default to output.csv if not provided
122112 destination_path = kwargs .get ("destination_path" , "output.csv" )
123113
124- # Create ephemeral index directly via SDK
125114 uipath = UiPath ()
126115 ephemeral_index = await uipath .context_grounding .create_ephemeral_index_async (
127116 usage = EphemeralIndexUsage .BATCH_RAG ,
128117 attachments = [attachment_id ],
129118 )
130119
131- # Wait for index ingestion only if in progress
132120 if ephemeral_index .in_progress_ingestion ():
133121 ephemeral_index_dict = interrupt (WaitEphemeralIndex (index = ephemeral_index ))
134122 ephemeral_index = ContextGroundingIndex (** ephemeral_index_dict )
135123
136- # Create Batch Transform request using interrupt
137124 return interrupt (
138125 CreateBatchTransform (
139126 name = f"task-{ uuid .uuid4 ()} " ,
@@ -144,7 +131,7 @@ async def batch_transform_tool_fn(**kwargs: Any) -> dict[str, Any]:
144131 storage_bucket_folder_path_prefix = static_folder_path_prefix ,
145132 enable_web_search_grounding = static_web_search ,
146133 destination_path = destination_path ,
147- is_ephemeral = True ,
134+ is_ephemeral_index = True ,
148135 )
149136 )
150137
0 commit comments