1515from humanloop .evaluators .client import EvaluatorsClient
1616from humanloop .flows .client import FlowsClient
1717from humanloop .prompts .client import PromptsClient
18- from humanloop .sync .sync_client import SyncClient
18+ from humanloop .sync .file_syncer import FileSyncer
1919from humanloop .tools .client import ToolsClient
2020from humanloop .types import FileType
2121from humanloop .types .agent_call_response import AgentCallResponse
@@ -66,7 +66,7 @@ def _get_file_type_from_client(
6666
6767def _handle_tracing_context (kwargs : Dict [str , Any ], client : T ) -> Dict [str , Any ]:
6868 """Handle tracing context for both log and call methods."""
69- trace_id = get_trace_id ()
69+ trace_id = get_trace_id ()
7070 if trace_id is not None :
7171 if "flow" in str (type (client ).__name__ ).lower ():
7272 context = get_decorator_context ()
@@ -92,7 +92,7 @@ def _handle_tracing_context(kwargs: Dict[str, Any], client: T) -> Dict[str, Any]
9292def _handle_local_files (
9393 kwargs : Dict [str , Any ],
9494 client : T ,
95- sync_client : SyncClient ,
95+ file_syncer : FileSyncer ,
9696) -> Dict [str , Any ]:
9797 """Load prompt/agent file content from local filesystem into API request.
9898
@@ -103,7 +103,7 @@ def _handle_local_files(
103103 Args:
104104 kwargs: API call arguments
105105 client: Client instance making the call
106- sync_client: SyncClient handling local file operations
106+ file_syncer: FileSyncer handling local file operations
107107
108108 Returns:
109109 Updated kwargs with file content in prompt/agent field
@@ -126,7 +126,7 @@ def _handle_local_files(
126126 )
127127
128128 # Then check for file extensions
129- if sync_client .is_file (path ):
129+ if file_syncer .is_file (path ):
130130 # Extract the path without extension to suggest correct format in the error message
131131 path_without_extension = str (Path (path ).with_suffix ("" ))
132132
@@ -147,7 +147,7 @@ def _handle_local_files(
147147 )
148148
149149 file_type = _get_file_type_from_client (client )
150- if file_type not in SyncClient .SERIALIZABLE_FILE_TYPES :
150+ if file_type not in FileSyncer .SERIALIZABLE_FILE_TYPES :
151151 raise HumanloopRuntimeError (f"Local files are not supported for `{ file_type .capitalize ()} ` files: '{ path } '." )
152152
153153 # If file_type is already specified in kwargs (prompt or agent), it means user provided a Prompt- or AgentKernelRequestParams object
@@ -159,7 +159,7 @@ def _handle_local_files(
159159 return kwargs
160160
161161 try :
162- file_content = sync_client .get_file_content (path , file_type ) # type: ignore[arg-type] # file_type was checked above
162+ file_content = file_syncer .get_file_content (path , file_type ) # type: ignore[arg-type] # file_type was checked above
163163 kwargs [file_type ] = file_content
164164
165165 return kwargs
@@ -175,7 +175,7 @@ def _handle_evaluation_context(kwargs: Dict[str, Any]) -> tuple[Dict[str, Any],
175175 return kwargs , None
176176
177177
178- def _overload_log (self : T , sync_client : Optional [SyncClient ], use_local_files : bool , ** kwargs ) -> LogResponseType :
178+ def _overload_log (self : T , file_syncer : Optional [FileSyncer ], use_local_files : bool , ** kwargs ) -> LogResponseType :
179179 try :
180180 # Special handling for flows - prevent direct log usage
181181 if type (self ) is FlowsClient and get_trace_id () is not None :
@@ -191,18 +191,18 @@ def _overload_log(self: T, sync_client: Optional[SyncClient], use_local_files: b
191191
192192 # Handle loading files from local filesystem when using Prompts and Agents clients
193193 # This enables users to define prompts/agents in local files rather than fetching from the Humanloop API
194- if use_local_files and _get_file_type_from_client (self ) in SyncClient .SERIALIZABLE_FILE_TYPES :
195- # Developer note: sync_client should always be provided during SDK initialization when
194+ if use_local_files and _get_file_type_from_client (self ) in FileSyncer .SERIALIZABLE_FILE_TYPES :
195+ # Developer note: file_syncer should always be provided during SDK initialization when
196196 # use_local_files=True. If we hit this error, there's likely an initialization issue
197- # in Humanloop.__init__ where the sync_client wasn't properly created or passed to the
197+ # in Humanloop.__init__ where the file_syncer wasn't properly created or passed to the
198198 # overload_client function.
199- if sync_client is None :
200- logger .error ("sync_client is None but client has log method and use_local_files=%s" , use_local_files )
199+ if file_syncer is None :
200+ logger .error ("file_syncer is None but client has log method and use_local_files=%s" , use_local_files )
201201 raise HumanloopRuntimeError (
202- "SDK initialization error: sync_client is missing but required for local file operations. "
202+ "SDK initialization error: file_syncer is missing but required for local file operations. "
203203 "This is likely a bug in the SDK initialization - please report this issue to the Humanloop team."
204204 )
205- kwargs = _handle_local_files (kwargs , self , sync_client )
205+ kwargs = _handle_local_files (kwargs , self , file_syncer )
206206
207207 kwargs , eval_callback = _handle_evaluation_context (kwargs )
208208 response = self ._log (** kwargs ) # type: ignore[union-attr] # Use stored original method
@@ -217,15 +217,15 @@ def _overload_log(self: T, sync_client: Optional[SyncClient], use_local_files: b
217217 raise HumanloopRuntimeError from e
218218
219219
220- def _overload_call (self : T , sync_client : Optional [SyncClient ], use_local_files : bool , ** kwargs ) -> CallResponseType :
220+ def _overload_call (self : T , file_syncer : Optional [FileSyncer ], use_local_files : bool , ** kwargs ) -> CallResponseType :
221221 try :
222222 kwargs = _handle_tracing_context (kwargs , self )
223- if use_local_files and _get_file_type_from_client (self ) in SyncClient .SERIALIZABLE_FILE_TYPES :
224- # Same sync_client requirement as in _overload_log - see developer note there
225- if sync_client is None :
226- logger .error ("sync_client is None but client has call method and use_local_files=%s" , use_local_files )
227- raise HumanloopRuntimeError ("sync_client is required for clients that support call operations" )
228- kwargs = _handle_local_files (kwargs , self , sync_client )
223+ if use_local_files and _get_file_type_from_client (self ) in FileSyncer .SERIALIZABLE_FILE_TYPES :
224+ # Same file_syncer requirement as in _overload_log - see developer note there
225+ if file_syncer is None :
226+ logger .error ("file_syncer is None but client has call method and use_local_files=%s" , use_local_files )
227+ raise HumanloopRuntimeError ("file_syncer is required for clients that support call operations" )
228+ kwargs = _handle_local_files (kwargs , self , file_syncer )
229229 return self ._call (** kwargs ) # type: ignore[union-attr] # Use stored original method
230230 except HumanloopRuntimeError :
231231 # Re-raise HumanloopRuntimeError without wrapping to preserve the message
@@ -237,7 +237,7 @@ def _overload_call(self: T, sync_client: Optional[SyncClient], use_local_files:
237237
238238def overload_client (
239239 client : T ,
240- sync_client : Optional [SyncClient ] = None ,
240+ file_syncer : Optional [FileSyncer ] = None ,
241241 use_local_files : bool = False ,
242242) -> T :
243243 """Overloads client methods to add tracing, local file handling, and evaluation context."""
@@ -246,25 +246,25 @@ def overload_client(
246246 # Store original method with type ignore
247247 client ._log = client .log # type: ignore
248248
249- # Create a closure to capture sync_client and use_local_files
249+ # Create a closure to capture file_syncer and use_local_files
250250 def log_wrapper (self : T , ** kwargs ) -> LogResponseType :
251- return _overload_log (self , sync_client , use_local_files , ** kwargs )
251+ return _overload_log (self , file_syncer , use_local_files , ** kwargs )
252252
253253 # Replace the log method with type ignore
254254 client .log = types .MethodType (log_wrapper , client ) # type: ignore
255255
256256 # Overload call method for Prompt and Agent clients
257- if _get_file_type_from_client (client ) in SyncClient .SERIALIZABLE_FILE_TYPES :
258- if sync_client is None and use_local_files :
259- logger .error ("sync_client is None but client has call method and use_local_files=%s" , use_local_files )
260- raise HumanloopRuntimeError ("sync_client is required for clients that support call operations" )
257+ if _get_file_type_from_client (client ) in FileSyncer .SERIALIZABLE_FILE_TYPES :
258+ if file_syncer is None and use_local_files :
259+ logger .error ("file_syncer is None but client has call method and use_local_files=%s" , use_local_files )
260+ raise HumanloopRuntimeError ("file_syncer is required for clients that support call operations" )
261261 if hasattr (client , "call" ) and not hasattr (client , "_call" ):
262262 # Store original method with type ignore
263263 client ._call = client .call # type: ignore
264264
265- # Create a closure to capture sync_client and use_local_files
265+ # Create a closure to capture file_syncer and use_local_files
266266 def call_wrapper (self : T , ** kwargs ) -> CallResponseType :
267- return _overload_call (self , sync_client , use_local_files , ** kwargs )
267+ return _overload_call (self , file_syncer , use_local_files , ** kwargs )
268268
269269 # Replace the call method with type ignore
270270 client .call = types .MethodType (call_wrapper , client ) # type: ignore
0 commit comments