@@ -100,6 +100,7 @@ def __init__(
100100 opentelemetry_tracer_provider : Optional [TracerProvider ] = None ,
101101 opentelemetry_tracer : Optional [Tracer ] = None ,
102102 use_local_files : bool = False ,
103+ files_directory : str = "humanloop" ,
103104 ):
104105 """
105106 Extends the base client with custom evaluation utilities and
@@ -120,7 +121,7 @@ def __init__(
120121 )
121122
122123 self .use_local_files = use_local_files
123- self .sync_client = SyncClient (client = self )
124+ self ._sync_client = SyncClient (client = self , base_dir = files_directory )
124125 eval_client = ExtendedEvalsClient (client_wrapper = self ._client_wrapper )
125126 eval_client .client = self
126127 self .evaluations = eval_client
@@ -359,20 +360,26 @@ def agent():
359360 attributes = attributes ,
360361 )
361362
362- def pull (self ) -> List [str ]:
363+ def pull (self ,
364+ environment : str | None = None ,
365+ path : str | None = None
366+ ) -> List [str ]:
363367 """Pull prompt and agent files from Humanloop to local filesystem.
364368
365369 This method will:
366370 1. Fetch all prompt and agent files from your Humanloop workspace
367- 2. Save them to the local filesystem in a 'humanloop/' directory
371+ 2. Save them to the local filesystem using the client's files_directory (set during initialization)
368372 3. Maintain the same directory structure as in Humanloop
369373 4. Add appropriate file extensions (.prompt or .agent)
370374
375+ By default, the operation will overwrite existing files with the latest version from Humanlooop
376+ but will not delete local files that don't exist in the remote workspace.
377+
371378 Currently only supports syncing prompt and agent files. Other file types will be skipped.
372379
373380 The files will be saved with the following structure:
374381 ```
375- humanloop /
382+ {files_directory} /
376383 ├── prompts/
377384 │ ├── my_prompt.prompt
378385 │ └── nested/
@@ -381,11 +388,16 @@ def pull(self) -> List[str]:
381388 └── my_agent.agent
382389 ```
383390
384- :return: List of successfully processed file paths
391+ :param environment: The environment to pull the files from.
392+ :param path: The path to the files to pull on the Humanloop workspace. Can be a directory or a specific file.
393+ :return: List of successfully processed file paths.
385394 """
386- return self .sync_client .pull ()
387-
395+ return self ._sync_client .pull (
396+ environment = environment ,
397+ path = path
398+ )
388399
400+
389401class AsyncHumanloop (AsyncBaseHumanloop ):
390402 """
391403 See docstring of AsyncBaseHumanloop.
0 commit comments