lib/hugging_face/base_api.rb in hugging-face-0.3.4 vs lib/hugging_face/base_api.rb in hugging-face-0.3.5

- old
+ new

@@ -18,12 +18,15 @@ def build_connection(url) Faraday.new(url, headers: @headers) end - def request(connection:, input:) - response = connection.post { |req| req.body = input.to_json } - + def request(connection:, input:, params: nil) + response = connection.post { |req| + req.body = input.to_json + req.params = params if params + } + if response.success? return parse_response response else raise ServiceUnavailable.new response.body if response.status == HTTP_SERVICE_UNAVAILABLE raise Error.new response.body