160
160
from launch .request_validation import validate_task_request
161
161
162
162
DEFAULT_NETWORK_TIMEOUT_SEC = 120
163
+ DEFAULT_LLM_COMPLETIONS_TIMEOUT = 300
163
164
164
165
logger = logging .getLogger (__name__ )
165
166
logging .basicConfig ()
@@ -2911,6 +2912,7 @@ def completions_sync(
2911
2912
temperature : float ,
2912
2913
stop_sequences : Optional [List [str ]] = None ,
2913
2914
return_token_log_probs : Optional [bool ] = False ,
2915
+ timeout : float = DEFAULT_LLM_COMPLETIONS_TIMEOUT ,
2914
2916
) -> CompletionSyncV1Response :
2915
2917
"""
2916
2918
Run prompt completion on a sync LLM endpoint. Will fail if the endpoint is not sync.
@@ -2945,6 +2947,7 @@ def completions_sync(
2945
2947
body = request ,
2946
2948
query_params = query_params ,
2947
2949
skip_deserialization = True ,
2950
+ timeout = timeout ,
2948
2951
)
2949
2952
resp = json .loads (response .response .data )
2950
2953
return resp
@@ -2957,6 +2960,7 @@ def completions_stream(
2957
2960
temperature : float ,
2958
2961
stop_sequences : Optional [List [str ]] = None ,
2959
2962
return_token_log_probs : Optional [bool ] = False ,
2963
+ timeout : float = DEFAULT_LLM_COMPLETIONS_TIMEOUT ,
2960
2964
) -> Iterable [CompletionStreamV1Response ]:
2961
2965
"""
2962
2966
Run prompt completion on an LLM endpoint in streaming fashion. Will fail if endpoint does not support streaming.
@@ -2989,6 +2993,7 @@ def completions_stream(
2989
2993
json = request ,
2990
2994
auth = (self .configuration .username , self .configuration .password ),
2991
2995
stream = True ,
2996
+ timeout = timeout ,
2992
2997
)
2993
2998
sse_client = sseclient .SSEClient (response )
2994
2999
events = sse_client .events ()
0 commit comments