Class: HuggingFace::EndpointsApi
- Defined in:
- lib/hugging_face/endpoints_api.rb
Constant Summary
Constants inherited from BaseApi
BaseApi::HTTP_SERVICE_UNAVAILABLE, BaseApi::JSON_CONTENT_TYPE
Instance Method Summary collapse
Methods inherited from BaseApi
Constructor Details
This class inherits a constructor from HuggingFace::BaseApi
Instance Method Details
#request(endpoint_url:, input:, params: nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hugging_face/endpoints_api.rb', line 4 def request(endpoint_url:, input:, params: nil) retries = 0 endpoint_connection = build_connection endpoint_url begin return super(connection: endpoint_connection, input: { inputs: input }, params: params ) rescue ServiceUnavailable => exception if retries < MAX_RETRY logger.debug('Service unavailable, retrying...') retries += 1 sleep 5 retry else raise exception end end end |