@@ -16,12 +16,32 @@ def __init__(
1616 polling_interval : float = 2.0 ,
1717 timeout : float = 300.0 ,
1818 ):
19+ """Initialize the GatewayClient with the base Gateway URL and optional parameters.
20+
21+ Args:
22+ base_url (str): The base URL of the Gateway service.
23+ default_model (str, optional): The default model to use for tasks. Defaults to None.
24+ polling_interval (float, optional): The interval in seconds to poll for task completion.
25+ Defaults to 2.0 seconds, with a minimum of 0.5 and maximum of 3.0 seconds.
26+ timeout (float, optional): The client polling timeout while waiting for task completion.
27+ Defaults to 300.0 seconds. A TimeoutError in this case should rarely indicate that
28+ something went wrong, but rather that the task is taking longer than expected (e.g.
29+ common with long running tasks like training).
30+ """
1931 self .base_url = base_url .rstrip ("/" )
2032 self .default_model = default_model
2133 self .polling_interval = polling_interval
2234 self .timeout = timeout
2335 self ._client = None
2436
37+ @property
38+ def polling_interval (self ):
39+ return self ._polling_interval
40+
41+ @polling_interval .setter
42+ def polling_interval (self , value : float ):
43+ self ._polling_interval = max (0.5 , min (value , 3.0 ))
44+
2545 async def __aenter__ (self ):
2646 self ._client = httpx .AsyncClient ()
2747 return self
@@ -274,6 +294,34 @@ def __init__(self, *args, **kwargs):
274294 asyncio .set_event_loop (self ._loop )
275295 self ._loop .run_until_complete (self ._client .__aenter__ ())
276296
297+ @property
298+ def base_url (self ):
299+ return self ._client .base_url
300+
301+ @property
302+ def default_model (self ):
303+ return self ._client .default_model
304+
305+ @default_model .setter
306+ def default_model (self , value : str ):
307+ self ._client .default_model = value
308+
309+ @property
310+ def polling_interval (self ):
311+ return self ._client .polling_interval
312+
313+ @polling_interval .setter
314+ def polling_interval (self , value : float ):
315+ self ._client .polling_interval = value
316+
317+ @property
318+ def timeout (self ):
319+ return self ._client .timeout
320+
321+ @timeout .setter
322+ def timeout (self , value : float ):
323+ self ._client .timeout = value
324+
277325 def __del__ (self ):
278326 try :
279327 if hasattr (self , "_client" ) and self ._client and self ._client ._client is not None :
0 commit comments