@@ -598,20 +598,29 @@ async def create_index_async(
598598 @resource_override (resource_type = "index" )
599599 @traced (name = "contextgrounding_create_ephemeral_index" , run_type = "uipath" )
600600 def create_ephemeral_index (
601- self , usage : EphemeralIndexUsage , attachments : List [str ]
601+ self ,
602+ usage : EphemeralIndexUsage ,
603+ attachments : List [str ],
604+ folder_key : str | None = None ,
605+ folder_path : str | None = None ,
602606 ) -> ContextGroundingIndex :
603607 """Create a new ephemeral context grounding index.
604608
605609 Args:
606610 usage (EphemeralIndexUsage): The task type for the ephemeral index (DeepRAG or BatchRAG)
607611 attachments (list[str]): The list of attachments ids from which the ephemeral index will be created
612+ folder_key (Optional[str]): The folder key to scope the ephemeral index to.
613+ folder_path (Optional[str]): The folder path to scope the ephemeral index to (resolved to a key if folder_key is not provided).
608614
609615 Returns:
610616 ContextGroundingIndex: The created index information.
611617 """
618+ if folder_key is not None or folder_path is not None :
619+ folder_key = self ._resolve_folder_key (folder_key , folder_path )
612620 spec = self ._create_ephemeral_spec (
613621 usage ,
614622 attachments ,
623+ folder_key = folder_key ,
615624 )
616625
617626 response = self .request (
@@ -626,20 +635,29 @@ def create_ephemeral_index(
626635 @resource_override (resource_type = "index" )
627636 @traced (name = "contextgrounding_create_ephemeral_index" , run_type = "uipath" )
628637 async def create_ephemeral_index_async (
629- self , usage : EphemeralIndexUsage , attachments : List [str ]
638+ self ,
639+ usage : EphemeralIndexUsage ,
640+ attachments : List [str ],
641+ folder_key : str | None = None ,
642+ folder_path : str | None = None ,
630643 ) -> ContextGroundingIndex :
631644 """Create a new ephemeral context grounding index.
632645
633646 Args:
634647 usage (EphemeralIndexUsage): The task type for the ephemeral index (DeepRAG or BatchRAG)
635648 attachments (list[str]): The list of attachments ids from which the ephemeral index will be created
649+ folder_key (Optional[str]): The folder key to scope the ephemeral index to.
650+ folder_path (Optional[str]): The folder path to scope the ephemeral index to (resolved to a key if folder_key is not provided).
636651
637652 Returns:
638653 ContextGroundingIndex: The created index information.
639654 """
655+ if folder_key is not None or folder_path is not None :
656+ folder_key = self ._resolve_folder_key (folder_key , folder_path )
640657 spec = self ._create_ephemeral_spec (
641658 usage ,
642659 attachments ,
660+ folder_key = folder_key ,
643661 )
644662
645663 response = await self .request_async (
@@ -1991,12 +2009,14 @@ def _create_ephemeral_spec(
19912009 self ,
19922010 usage : str ,
19932011 attachments : List [str ],
2012+ folder_key : str | None = None ,
19942013 ) -> RequestSpec :
19952014 """Create request spec for ephemeral index creation.
19962015
19972016 Args:
19982017 usage (str): The task in which the ephemeral index will be used for
19992018 attachments (list[str]): The list of attachments ids from which the ephemeral index will be created
2019+ folder_key (Optional[str]): The folder key to scope the ephemeral index to.
20002020
20012021 Returns:
20022022 RequestSpec for the create index request
@@ -2012,7 +2032,7 @@ def _create_ephemeral_spec(
20122032 method = "POST" ,
20132033 endpoint = Endpoint ("/ecs_/v2/indexes/createephemeral" ),
20142034 json = payload .model_dump (by_alias = True , exclude_none = True ),
2015- headers = {},
2035+ headers = {** header_folder ( folder_key , None ) },
20162036 )
20172037
20182038 def _build_data_source (self , source : SourceConfig ) -> Dict [str , Any ]:
0 commit comments