@huggingface/inference 3.15.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +102 -0
  2. package/dist/commonjs/errors.d.ts +46 -0
  3. package/dist/commonjs/errors.d.ts.map +1 -0
  4. package/dist/commonjs/errors.js +70 -0
  5. package/dist/commonjs/index.d.ts +1 -1
  6. package/dist/commonjs/index.d.ts.map +1 -1
  7. package/dist/commonjs/index.js +2 -3
  8. package/dist/commonjs/lib/getInferenceProviderMapping.d.ts.map +1 -1
  9. package/dist/commonjs/lib/getInferenceProviderMapping.js +27 -16
  10. package/dist/commonjs/lib/getProviderHelper.d.ts.map +1 -1
  11. package/dist/commonjs/lib/getProviderHelper.js +4 -3
  12. package/dist/commonjs/lib/makeRequestOptions.d.ts.map +1 -1
  13. package/dist/commonjs/lib/makeRequestOptions.js +12 -11
  14. package/dist/commonjs/package.d.ts +1 -1
  15. package/dist/commonjs/package.d.ts.map +1 -1
  16. package/dist/commonjs/package.js +1 -1
  17. package/dist/commonjs/providers/black-forest-labs.d.ts.map +1 -1
  18. package/dist/commonjs/providers/black-forest-labs.js +4 -4
  19. package/dist/commonjs/providers/fal-ai.d.ts.map +1 -1
  20. package/dist/commonjs/providers/fal-ai.js +29 -17
  21. package/dist/commonjs/providers/featherless-ai.d.ts.map +1 -1
  22. package/dist/commonjs/providers/featherless-ai.js +2 -2
  23. package/dist/commonjs/providers/hf-inference.d.ts.map +1 -1
  24. package/dist/commonjs/providers/hf-inference.js +27 -30
  25. package/dist/commonjs/providers/hyperbolic.d.ts.map +1 -1
  26. package/dist/commonjs/providers/hyperbolic.js +3 -3
  27. package/dist/commonjs/providers/nebius.d.ts.map +1 -1
  28. package/dist/commonjs/providers/nebius.js +2 -2
  29. package/dist/commonjs/providers/novita.d.ts.map +1 -1
  30. package/dist/commonjs/providers/novita.js +12 -8
  31. package/dist/commonjs/providers/nscale.d.ts.map +1 -1
  32. package/dist/commonjs/providers/nscale.js +2 -2
  33. package/dist/commonjs/providers/ovhcloud.d.ts.map +1 -1
  34. package/dist/commonjs/providers/ovhcloud.js +2 -2
  35. package/dist/commonjs/providers/providerHelper.js +3 -3
  36. package/dist/commonjs/providers/replicate.js +4 -4
  37. package/dist/commonjs/providers/sambanova.d.ts +16 -0
  38. package/dist/commonjs/providers/sambanova.d.ts.map +1 -1
  39. package/dist/commonjs/providers/sambanova.js +2 -18
  40. package/dist/commonjs/providers/together.d.ts.map +1 -1
  41. package/dist/commonjs/providers/together.js +3 -3
  42. package/dist/commonjs/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -1
  43. package/dist/commonjs/tasks/audio/automaticSpeechRecognition.js +2 -2
  44. package/dist/commonjs/utils/request.d.ts.map +1 -1
  45. package/dist/commonjs/utils/request.js +77 -12
  46. package/dist/commonjs/vendor/type-fest/basic.d.ts +33 -0
  47. package/dist/commonjs/vendor/type-fest/basic.d.ts.map +1 -0
  48. package/dist/commonjs/vendor/type-fest/basic.js +2 -0
  49. package/dist/esm/errors.d.ts +46 -0
  50. package/dist/esm/errors.d.ts.map +1 -0
  51. package/dist/esm/errors.js +62 -0
  52. package/dist/esm/index.d.ts +1 -1
  53. package/dist/esm/index.d.ts.map +1 -1
  54. package/dist/esm/index.js +1 -1
  55. package/dist/esm/lib/getInferenceProviderMapping.d.ts.map +1 -1
  56. package/dist/esm/lib/getInferenceProviderMapping.js +27 -16
  57. package/dist/esm/lib/getProviderHelper.d.ts.map +1 -1
  58. package/dist/esm/lib/getProviderHelper.js +4 -3
  59. package/dist/esm/lib/makeRequestOptions.d.ts.map +1 -1
  60. package/dist/esm/lib/makeRequestOptions.js +12 -11
  61. package/dist/esm/package.d.ts +1 -1
  62. package/dist/esm/package.d.ts.map +1 -1
  63. package/dist/esm/package.js +1 -1
  64. package/dist/esm/providers/black-forest-labs.d.ts.map +1 -1
  65. package/dist/esm/providers/black-forest-labs.js +4 -4
  66. package/dist/esm/providers/fal-ai.d.ts.map +1 -1
  67. package/dist/esm/providers/fal-ai.js +29 -17
  68. package/dist/esm/providers/featherless-ai.d.ts.map +1 -1
  69. package/dist/esm/providers/featherless-ai.js +2 -2
  70. package/dist/esm/providers/hf-inference.d.ts.map +1 -1
  71. package/dist/esm/providers/hf-inference.js +27 -30
  72. package/dist/esm/providers/hyperbolic.d.ts.map +1 -1
  73. package/dist/esm/providers/hyperbolic.js +3 -3
  74. package/dist/esm/providers/nebius.d.ts.map +1 -1
  75. package/dist/esm/providers/nebius.js +2 -2
  76. package/dist/esm/providers/novita.d.ts.map +1 -1
  77. package/dist/esm/providers/novita.js +12 -8
  78. package/dist/esm/providers/nscale.d.ts.map +1 -1
  79. package/dist/esm/providers/nscale.js +2 -2
  80. package/dist/esm/providers/ovhcloud.d.ts.map +1 -1
  81. package/dist/esm/providers/ovhcloud.js +2 -2
  82. package/dist/esm/providers/providerHelper.js +3 -3
  83. package/dist/esm/providers/replicate.js +4 -4
  84. package/dist/esm/providers/sambanova.d.ts +16 -0
  85. package/dist/esm/providers/sambanova.d.ts.map +1 -1
  86. package/dist/esm/providers/sambanova.js +2 -18
  87. package/dist/esm/providers/together.d.ts.map +1 -1
  88. package/dist/esm/providers/together.js +3 -3
  89. package/dist/esm/tasks/audio/automaticSpeechRecognition.d.ts.map +1 -1
  90. package/dist/esm/tasks/audio/automaticSpeechRecognition.js +2 -2
  91. package/dist/esm/utils/request.d.ts.map +1 -1
  92. package/dist/esm/utils/request.js +77 -12
  93. package/dist/esm/vendor/type-fest/basic.d.ts +33 -0
  94. package/dist/esm/vendor/type-fest/basic.d.ts.map +1 -0
  95. package/dist/esm/vendor/type-fest/basic.js +1 -0
  96. package/package.json +2 -2
  97. package/src/errors.ts +82 -0
  98. package/src/index.ts +1 -1
  99. package/src/lib/getInferenceProviderMapping.ts +42 -22
  100. package/src/lib/getProviderHelper.ts +8 -3
  101. package/src/lib/makeRequestOptions.ts +20 -11
  102. package/src/package.ts +1 -1
  103. package/src/providers/black-forest-labs.ts +14 -4
  104. package/src/providers/fal-ai.ts +59 -23
  105. package/src/providers/featherless-ai.ts +2 -2
  106. package/src/providers/hf-inference.ts +75 -34
  107. package/src/providers/hyperbolic.ts +3 -4
  108. package/src/providers/nebius.ts +2 -2
  109. package/src/providers/novita.ts +30 -8
  110. package/src/providers/nscale.ts +2 -2
  111. package/src/providers/ovhcloud.ts +2 -2
  112. package/src/providers/providerHelper.ts +3 -3
  113. package/src/providers/replicate.ts +4 -4
  114. package/src/providers/sambanova.ts +3 -4
  115. package/src/providers/together.ts +3 -3
  116. package/src/tasks/audio/automaticSpeechRecognition.ts +2 -2
  117. package/src/utils/request.ts +127 -14
  118. package/src/vendor/type-fest/basic.ts +31 -0
  119. package/src/vendor/type-fest/license-cc0 +121 -0
  120. package/src/vendor/type-fest/license-mit +9 -0
  121. package/dist/commonjs/lib/InferenceOutputError.d.ts +0 -4
  122. package/dist/commonjs/lib/InferenceOutputError.d.ts.map +0 -1
  123. package/dist/commonjs/lib/InferenceOutputError.js +0 -10
  124. package/dist/esm/lib/InferenceOutputError.d.ts +0 -4
  125. package/dist/esm/lib/InferenceOutputError.d.ts.map +0 -1
  126. package/dist/esm/lib/InferenceOutputError.js +0 -6
  127. package/src/lib/InferenceOutputError.ts +0 -8
package/README.md CHANGED
@@ -120,6 +120,108 @@ await textGeneration({
120
120
 
121
121
  This will enable tree-shaking by your bundler.
122
122
 
123
+ ### Error handling
124
+
125
+ The inference package provides specific error types to help you handle different error scenarios effectively.
126
+
127
+ #### Error Types
128
+
129
+ The package defines several error types that extend the base `Error` class:
130
+
131
+ - `InferenceClientError`: Base error class for all Hugging Face Inference errors
132
+ - `InferenceClientInputError`: Thrown when there are issues with input parameters
133
+ - `InferenceClientProviderApiError`: Thrown when there are API-level errors from providers
134
+ - `InferenceClientHubApiError`: Thrown when there are API-levels errors from the Hugging Face Hub
135
+ - `InferenceClientProviderOutputError`: Thrown when there are issues with providers' API responses format
136
+
137
+ ### Example Usage
138
+
139
+ ```typescript
140
+ import { InferenceClient } from "@huggingface/inference";
141
+ import {
142
+ InferenceClientError,
143
+ InferenceClientProviderApiError,
144
+ InferenceClientProviderOutputError,
145
+ InferenceClientHubApiError,
146
+ } from "@huggingface/inference";
147
+
148
+ const client = new InferenceClient();
149
+
150
+ try {
151
+ const result = await client.textGeneration({
152
+ model: "gpt2",
153
+ inputs: "Hello, I'm a language model",
154
+ });
155
+ } catch (error) {
156
+ if (error instanceof InferenceClientProviderApiError) {
157
+ // Handle API errors (e.g., rate limits, authentication issues)
158
+ console.error("Provider API Error:", error.message);
159
+ console.error("HTTP Request details:", error.request);
160
+ console.error("HTTP Response details:", error.response);
161
+ if (error instanceof InferenceClientHubApiError) {
162
+ // Handle API errors (e.g., rate limits, authentication issues)
163
+ console.error("Hub API Error:", error.message);
164
+ console.error("HTTP Request details:", error.request);
165
+ console.error("HTTP Response details:", error.response);
166
+ } else if (error instanceof InferenceClientProviderOutputError) {
167
+ // Handle malformed responses from providers
168
+ console.error("Provider Output Error:", error.message);
169
+ } else if (error instanceof InferenceClientInputError) {
170
+ // Handle invalid input parameters
171
+ console.error("Input Error:", error.message);
172
+ } else {
173
+ // Handle unexpected errors
174
+ console.error("Unexpected error:", error);
175
+ }
176
+ }
177
+
178
+ /// Catch all errors from @huggingface/inference
179
+ try {
180
+ const result = await client.textGeneration({
181
+ model: "gpt2",
182
+ inputs: "Hello, I'm a language model",
183
+ });
184
+ } catch (error) {
185
+ if (error instanceof InferenceClientError) {
186
+ // Handle errors from @huggingface/inference
187
+ console.error("Error from InferenceClient:", error);
188
+ } else {
189
+ // Handle unexpected errors
190
+ console.error("Unexpected error:", error);
191
+ }
192
+ }
193
+ ```
194
+
195
+ ### Error Details
196
+
197
+ #### InferenceClientProviderApiError
198
+
199
+ This error occurs when there are issues with the API request when performing inference at the selected provider.
200
+
201
+ It has several properties:
202
+ - `message`: A descriptive error message
203
+ - `request`: Details about the failed request (URL, method, headers)
204
+ - `response`: Response details including status code and body
205
+
206
+ #### InferenceClientHubApiError
207
+
208
+ This error occurs when there are issues with the API request when requesting the Hugging Face Hub API.
209
+
210
+ It has several properties:
211
+ - `message`: A descriptive error message
212
+ - `request`: Details about the failed request (URL, method, headers)
213
+ - `response`: Response details including status code and body
214
+
215
+
216
+ #### InferenceClientProviderOutputError
217
+
218
+ This error occurs when a provider returns a response in an unexpected format.
219
+
220
+ #### InferenceClientInputError
221
+
222
+ This error occurs when input parameters are invalid or missing. The error message describes what's wrong with the input.
223
+
224
+
123
225
  ### Natural Language Processing
124
226
 
125
227
  #### Text Generation
@@ -0,0 +1,46 @@
1
+ import type { JsonObject } from "./vendor/type-fest/basic.js";
2
+ /**
3
+ * Base class for all inference-related errors.
4
+ */
5
+ export declare abstract class InferenceClientError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ export declare class InferenceClientInputError extends InferenceClientError {
9
+ constructor(message: string);
10
+ }
11
+ interface HttpRequest {
12
+ url: string;
13
+ method: string;
14
+ headers?: Record<string, string>;
15
+ body?: JsonObject;
16
+ }
17
+ interface HttpResponse {
18
+ requestId: string;
19
+ status: number;
20
+ body: JsonObject | string;
21
+ }
22
+ declare abstract class InferenceClientHttpRequestError extends InferenceClientError {
23
+ httpRequest: HttpRequest;
24
+ httpResponse: HttpResponse;
25
+ constructor(message: string, httpRequest: HttpRequest, httpResponse: HttpResponse);
26
+ }
27
+ /**
28
+ * Thrown when the HTTP request to the provider fails, e.g. due to API issues or server errors.
29
+ */
30
+ export declare class InferenceClientProviderApiError extends InferenceClientHttpRequestError {
31
+ constructor(message: string, httpRequest: HttpRequest, httpResponse: HttpResponse);
32
+ }
33
+ /**
34
+ * Thrown when the HTTP request to the hub fails, e.g. due to API issues or server errors.
35
+ */
36
+ export declare class InferenceClientHubApiError extends InferenceClientHttpRequestError {
37
+ constructor(message: string, httpRequest: HttpRequest, httpResponse: HttpResponse);
38
+ }
39
+ /**
40
+ * Thrown when the inference output returned by the provider is invalid / does not match the expectations
41
+ */
42
+ export declare class InferenceClientProviderOutputError extends InferenceClientError {
43
+ constructor(message: string);
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;GAEG;AACH,8BAAsB,oBAAqB,SAAQ,KAAK;gBAC3C,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,yBAA0B,SAAQ,oBAAoB;gBACtD,OAAO,EAAE,MAAM;CAI3B;AAED,UAAU,WAAW;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,UAAU,CAAC;CAClB;AAED,UAAU,YAAY;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;CAC1B;AAED,uBAAe,+BAAgC,SAAQ,oBAAoB;IAC1E,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;gBACf,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;CAgBjF;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,+BAA+B;gBACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;CAIjF;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,+BAA+B;gBAClE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;CAIjF;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,oBAAoB;gBAC/D,OAAO,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InferenceClientProviderOutputError = exports.InferenceClientHubApiError = exports.InferenceClientProviderApiError = exports.InferenceClientInputError = exports.InferenceClientError = void 0;
4
+ /**
5
+ * Base class for all inference-related errors.
6
+ */
7
+ class InferenceClientError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "InferenceClientError";
11
+ }
12
+ }
13
+ exports.InferenceClientError = InferenceClientError;
14
+ class InferenceClientInputError extends InferenceClientError {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = "InputError";
18
+ }
19
+ }
20
+ exports.InferenceClientInputError = InferenceClientInputError;
21
+ class InferenceClientHttpRequestError extends InferenceClientError {
22
+ httpRequest;
23
+ httpResponse;
24
+ constructor(message, httpRequest, httpResponse) {
25
+ super(message);
26
+ this.httpRequest = {
27
+ ...httpRequest,
28
+ ...(httpRequest.headers
29
+ ? {
30
+ headers: {
31
+ ...httpRequest.headers,
32
+ ...("Authorization" in httpRequest.headers ? { Authorization: `Bearer [redacted]` } : undefined),
33
+ /// redact authentication in the request headers
34
+ },
35
+ }
36
+ : undefined),
37
+ };
38
+ this.httpResponse = httpResponse;
39
+ }
40
+ }
41
+ /**
42
+ * Thrown when the HTTP request to the provider fails, e.g. due to API issues or server errors.
43
+ */
44
+ class InferenceClientProviderApiError extends InferenceClientHttpRequestError {
45
+ constructor(message, httpRequest, httpResponse) {
46
+ super(message, httpRequest, httpResponse);
47
+ this.name = "ProviderApiError";
48
+ }
49
+ }
50
+ exports.InferenceClientProviderApiError = InferenceClientProviderApiError;
51
+ /**
52
+ * Thrown when the HTTP request to the hub fails, e.g. due to API issues or server errors.
53
+ */
54
+ class InferenceClientHubApiError extends InferenceClientHttpRequestError {
55
+ constructor(message, httpRequest, httpResponse) {
56
+ super(message, httpRequest, httpResponse);
57
+ this.name = "HubApiError";
58
+ }
59
+ }
60
+ exports.InferenceClientHubApiError = InferenceClientHubApiError;
61
+ /**
62
+ * Thrown when the inference output returned by the provider is invalid / does not match the expectations
63
+ */
64
+ class InferenceClientProviderOutputError extends InferenceClientError {
65
+ constructor(message) {
66
+ super(message);
67
+ this.name = "ProviderOutputError";
68
+ }
69
+ }
70
+ exports.InferenceClientProviderOutputError = InferenceClientProviderOutputError;
@@ -1,5 +1,5 @@
1
1
  export { InferenceClient, InferenceClientEndpoint, HfInference } from "./InferenceClient.js";
2
- export { InferenceOutputError } from "./lib/InferenceOutputError.js";
2
+ export * from "./errors.js";
3
3
  export * from "./types.js";
4
4
  export * from "./tasks/index.js";
5
5
  import * as snippets from "./snippets/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7F,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -36,13 +36,12 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.snippets = exports.InferenceOutputError = exports.HfInference = exports.InferenceClientEndpoint = exports.InferenceClient = void 0;
39
+ exports.snippets = exports.HfInference = exports.InferenceClientEndpoint = exports.InferenceClient = void 0;
40
40
  var InferenceClient_js_1 = require("./InferenceClient.js");
41
41
  Object.defineProperty(exports, "InferenceClient", { enumerable: true, get: function () { return InferenceClient_js_1.InferenceClient; } });
42
42
  Object.defineProperty(exports, "InferenceClientEndpoint", { enumerable: true, get: function () { return InferenceClient_js_1.InferenceClientEndpoint; } });
43
43
  Object.defineProperty(exports, "HfInference", { enumerable: true, get: function () { return InferenceClient_js_1.HfInference; } });
44
- var InferenceOutputError_js_1 = require("./lib/InferenceOutputError.js");
45
- Object.defineProperty(exports, "InferenceOutputError", { enumerable: true, get: function () { return InferenceOutputError_js_1.InferenceOutputError; } });
44
+ __exportStar(require("./errors.js"), exports);
46
45
  __exportStar(require("./types.js"), exports);
47
46
  __exportStar(require("./tasks/index.js"), exports);
48
47
  const snippets = __importStar(require("./snippets/index.js"));
@@ -1 +1 @@
1
- {"version":3,"file":"getInferenceProviderMapping.d.ts","sourceRoot":"","sources":["../../../src/lib/getInferenceProviderMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGzF,eAAO,MAAM,6BAA6B,uTAA+C,CAAC;AAE1F,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC7C,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,6BAA6B,EAAE,WAAW,CAAC,CAAC,CAC3E,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;CACjB;AAED,wBAAsB,qCAAqC,CAC1D,OAAO,EAAE,O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,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;CACjB;AAED,wBAAsB,qCAAqC,CAC1D,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,wBAAwB,CAAC,CAgDnC;AAED,wBAAsB,2BAA2B,CAChD,MAAM,EAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;CACjB,EACD,OAAO,EAAE;IACR,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtE,GACC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CA4B/C;AAED,wBAAsB,eAAe,CACpC,QAAQ,CAAC,EAAE,yBAAyB,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAyB5B"}
@@ -8,6 +8,7 @@ const config_js_1 = require("../config.js");
8
8
  const consts_js_1 = require("../providers/consts.js");
9
9
  const hf_inference_js_1 = require("../providers/hf-inference.js");
10
10
  const typedInclude_js_1 = require("../utils/typedInclude.js");
11
+ const errors_js_1 = require("../errors.js");
11
12
  exports.inferenceProviderMappingCache = new Map();
12
13
  async function fetchInferenceProviderMappingForModel(modelId, accessToken, options) {
13
14
  let inferenceProviderMapping;
@@ -16,22 +17,32 @@ async function fetchInferenceProviderMappingForModel(modelId, accessToken, optio
16
17
  inferenceProviderMapping = exports.inferenceProviderMappingCache.get(modelId);
17
18
  }
18
19
  else {
19
- const resp = await (options?.fetch ?? fetch)(`${config_js_1.HF_HUB_URL}/api/models/${modelId}?expand[]=inferenceProviderMapping`, {
20
+ const url = `${config_js_1.HF_HUB_URL}/api/models/${modelId}?expand[]=inferenceProviderMapping`;
21
+ const resp = await (options?.fetch ?? fetch)(url, {
20
22
  headers: accessToken?.startsWith("hf_") ? { Authorization: `Bearer ${accessToken}` } : {},
21
23
  });
22
- if (resp.status === 404) {
23
- throw new Error(`Model ${modelId} does not exist`);
24
+ if (!resp.ok) {
25
+ if (resp.headers.get("Content-Type")?.startsWith("application/json")) {
26
+ const error = await resp.json();
27
+ if ("error" in error && typeof error.error === "string") {
28
+ throw new errors_js_1.InferenceClientHubApiError(`Failed to fetch inference provider mapping for model ${modelId}: ${error.error}`, { url, method: "GET" }, { requestId: resp.headers.get("x-request-id") ?? "", status: resp.status, body: error });
29
+ }
30
+ }
31
+ else {
32
+ throw new errors_js_1.InferenceClientHubApiError(`Failed to fetch inference provider mapping for model ${modelId}`, { url, method: "GET" }, { requestId: resp.headers.get("x-request-id") ?? "", status: resp.status, body: await resp.text() });
33
+ }
24
34
  }
25
- inferenceProviderMapping = await resp
26
- .json()
27
- .then((json) => json.inferenceProviderMapping)
28
- .catch(() => null);
29
- if (inferenceProviderMapping) {
30
- exports.inferenceProviderMappingCache.set(modelId, inferenceProviderMapping);
35
+ let payload = null;
36
+ try {
37
+ payload = await resp.json();
31
38
  }
32
- }
33
- if (!inferenceProviderMapping) {
34
- throw new Error(`We have not been able to find inference provider information for model ${modelId}.`);
39
+ catch {
40
+ throw new errors_js_1.InferenceClientHubApiError(`Failed to fetch inference provider mapping for model ${modelId}: malformed API response, invalid JSON`, { url, method: "GET" }, { requestId: resp.headers.get("x-request-id") ?? "", status: resp.status, body: await resp.text() });
41
+ }
42
+ if (!payload?.inferenceProviderMapping) {
43
+ throw new errors_js_1.InferenceClientHubApiError(`We have not been able to find inference provider information for model ${modelId}.`, { url, method: "GET" }, { requestId: resp.headers.get("x-request-id") ?? "", status: resp.status, body: await resp.text() });
44
+ }
45
+ inferenceProviderMapping = payload.inferenceProviderMapping;
35
46
  }
36
47
  return inferenceProviderMapping;
37
48
  }
@@ -46,7 +57,7 @@ async function getInferenceProviderMapping(params, options) {
46
57
  ? hf_inference_js_1.EQUIVALENT_SENTENCE_TRANSFORMERS_TASKS
47
58
  : [params.task];
48
59
  if (!(0, typedInclude_js_1.typedInclude)(equivalentTasks, providerMapping.task)) {
49
- throw new Error(`Model ${params.modelId} is not supported for task ${params.task} and provider ${params.provider}. Supported task: ${providerMapping.task}.`);
60
+ throw new errors_js_1.InferenceClientInputError(`Model ${params.modelId} is not supported for task ${params.task} and provider ${params.provider}. Supported task: ${providerMapping.task}.`);
50
61
  }
51
62
  if (providerMapping.status === "staging") {
52
63
  console.warn(`Model ${params.modelId} is in staging mode for provider ${params.provider}. Meant for test purposes only.`);
@@ -58,7 +69,7 @@ async function getInferenceProviderMapping(params, options) {
58
69
  async function resolveProvider(provider, modelId, endpointUrl) {
59
70
  if (endpointUrl) {
60
71
  if (provider) {
61
- throw new Error("Specifying both endpointUrl and provider is not supported.");
72
+ throw new errors_js_1.InferenceClientInputError("Specifying both endpointUrl and provider is not supported.");
62
73
  }
63
74
  /// Defaulting to hf-inference helpers / API
64
75
  return "hf-inference";
@@ -69,13 +80,13 @@ async function resolveProvider(provider, modelId, endpointUrl) {
69
80
  }
70
81
  if (provider === "auto") {
71
82
  if (!modelId) {
72
- throw new Error("Specifying a model is required when provider is 'auto'");
83
+ throw new errors_js_1.InferenceClientInputError("Specifying a model is required when provider is 'auto'");
73
84
  }
74
85
  const inferenceProviderMapping = await fetchInferenceProviderMappingForModel(modelId);
75
86
  provider = Object.keys(inferenceProviderMapping)[0];
76
87
  }
77
88
  if (!provider) {
78
- throw new Error(`No Inference Provider available for model ${modelId}.`);
89
+ throw new errors_js_1.InferenceClientInputError(`No Inference Provider available for model ${modelId}.`);
79
90
  }
80
91
  return provider;
81
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getProviderHelper.d.ts","sourceRoot":"","sources":["../../../src/lib/getProviderHelper.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,wBAAwB,EACxB,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,EAChC,qCAAqC,EACrC,MAAM,gCAAgC,CAAC;AAIxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/F,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAkGnG,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,gBAAgB,GACpB,wBAAwB,GAAG,kBAAkB,CAAC;AACjD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,iBAAiB,GACrB,wBAAwB,GAAG,kBAAkB,CAAC;AACj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kBAAkB,CAAC;AAC/C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,qBAAqB,GACzB,4BAA4B,GAAG,kBAAkB,CAAC;AACrD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,0BAA0B,GAC9B,gCAAgC,GAAG,kBAAkB,CAAC;AACzD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,wBAAwB,GAC5B,+BAA+B,GAAG,kBAAkB,CAAC;AACxD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,oBAAoB,GACxB,2BAA2B,GAAG,kBAAkB,CAAC;AACpD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,sBAAsB,GAC1B,6BAA6B,GAAG,kBAAkB,CAAC;AACtD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GACjB,qBAAqB,GAAG,kBAAkB,CAAC;AAC9C,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,eAAe,GACnB,uBAAuB,GAAG,kBAAkB,CAAC;AAChD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,2BAA2B,GAC/B,iCAAiC,GAAG,kBAAkB,CAAC;AAC1D,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,yBAAyB,EACnC,IAAI,EAAE,aAAa,GAAG,SAAS,GAC7B,kBAAkB,CAAC"}
@@ -52,6 +52,7 @@ const OvhCloud = __importStar(require("../providers/ovhcloud.js"));
52
52
  const Replicate = __importStar(require("../providers/replicate.js"));
53
53
  const Sambanova = __importStar(require("../providers/sambanova.js"));
54
54
  const Together = __importStar(require("../providers/together.js"));
55
+ const errors_js_1 = require("../errors.js");
55
56
  exports.PROVIDERS = {
56
57
  "black-forest-labs": {
57
58
  "text-to-image": new BlackForestLabs.BlackForestLabsTextToImageTask(),
@@ -156,14 +157,14 @@ function getProviderHelper(provider, task) {
156
157
  return new HFInference.HFInferenceTask();
157
158
  }
158
159
  if (!task) {
159
- throw new Error("you need to provide a task name when using an external provider, e.g. 'text-to-image'");
160
+ throw new errors_js_1.InferenceClientInputError("you need to provide a task name when using an external provider, e.g. 'text-to-image'");
160
161
  }
161
162
  if (!(provider in exports.PROVIDERS)) {
162
- throw new Error(`Provider '${provider}' not supported. Available providers: ${Object.keys(exports.PROVIDERS)}`);
163
+ throw new errors_js_1.InferenceClientInputError(`Provider '${provider}' not supported. Available providers: ${Object.keys(exports.PROVIDERS)}`);
163
164
  }
164
165
  const providerTasks = exports.PROVIDERS[provider];
165
166
  if (!providerTasks || !(task in providerTasks)) {
166
- throw new Error(`Task '${task}' not supported for provider '${provider}'. Available tasks: ${Object.keys(providerTasks ?? {})}`);
167
+ throw new errors_js_1.InferenceClientInputError(`Task '${task}' not supported for provider '${provider}'. Available tasks: ${Object.keys(providerTasks ?? {})}`);
167
168
  }
168
169
  return providerTasks[task];
169
170
  }
@@ -1 +1 @@
1
- {"version":3,"file":"makeRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/makeRequestOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAShE;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,OAAO,CA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AAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAqE7C;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EACpD,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,OAAO,EAAE,6BAA6B,GAAG,SAAS,EAClD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,IAAI,CAAC,EAAE,aAAa,CAAC;CACrB,GACC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CA8EpC"}
@@ -6,6 +6,7 @@ const config_js_1 = require("../config.js");
6
6
  const package_js_1 = require("../package.js");
7
7
  const getInferenceProviderMapping_js_1 = require("./getInferenceProviderMapping.js");
8
8
  const isUrl_js_1 = require("./isUrl.js");
9
+ const errors_js_1 = require("../errors.js");
9
10
  /**
10
11
  * Lazy-loaded from huggingface.co/api/tasks when needed
11
12
  * Used to determine the default model to use when it's not user defined
@@ -21,22 +22,22 @@ async function makeRequestOptions(args, providerHelper, options) {
21
22
  const { task } = options ?? {};
22
23
  // Validate inputs
23
24
  if (args.endpointUrl && provider !== "hf-inference") {
24
- throw new Error(`Cannot use endpointUrl with a third-party provider.`);
25
+ throw new errors_js_1.InferenceClientInputError(`Cannot use endpointUrl with a third-party provider.`);
25
26
  }
26
27
  if (maybeModel && (0, isUrl_js_1.isUrl)(maybeModel)) {
27
- throw new Error(`Model URLs are no longer supported. Use endpointUrl instead.`);
28
+ throw new errors_js_1.InferenceClientInputError(`Model URLs are no longer supported. Use endpointUrl instead.`);
28
29
  }
29
30
  if (args.endpointUrl) {
30
31
  // No need to have maybeModel, or to load default model for a task
31
32
  return makeRequestOptionsFromResolvedModel(maybeModel ?? args.endpointUrl, providerHelper, args, undefined, options);
32
33
  }
33
34
  if (!maybeModel && !task) {
34
- throw new Error("No model provided, and no task has been specified.");
35
+ throw new errors_js_1.InferenceClientInputError("No model provided, and no task has been specified.");
35
36
  }
36
37
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
38
  const hfModel = maybeModel ?? (await loadDefaultModel(task));
38
39
  if (providerHelper.clientSideRoutingOnly && !maybeModel) {
39
- throw new Error(`Provider ${provider} requires a model ID to be passed directly.`);
40
+ throw new errors_js_1.InferenceClientInputError(`Provider ${provider} requires a model ID to be passed directly.`);
40
41
  }
41
42
  const inferenceProviderMapping = providerHelper.clientSideRoutingOnly
42
43
  ? {
@@ -56,7 +57,7 @@ async function makeRequestOptions(args, providerHelper, options) {
56
57
  accessToken: args.accessToken,
57
58
  }, { fetch: options?.fetch });
58
59
  if (!inferenceProviderMapping) {
59
- throw new Error(`We have not been able to find inference provider information for model ${hfModel}.`);
60
+ throw new errors_js_1.InferenceClientInputError(`We have not been able to find inference provider information for model ${hfModel}.`);
60
61
  }
61
62
  // Use the sync version with the resolved model
62
63
  return makeRequestOptionsFromResolvedModel(inferenceProviderMapping.providerId, providerHelper, args, inferenceProviderMapping, options);
@@ -75,9 +76,8 @@ function makeRequestOptionsFromResolvedModel(resolvedModel, providerHelper, args
75
76
  if (providerHelper.clientSideRoutingOnly) {
76
77
  // Closed-source providers require an accessToken (cannot be routed).
77
78
  if (accessToken && accessToken.startsWith("hf_")) {
78
- throw new Error(`Provider ${provider} is closed-source and does not support HF tokens.`);
79
+ throw new errors_js_1.InferenceClientInputError(`Provider ${provider} is closed-source and does not support HF tokens.`);
79
80
  }
80
- return "provider-key";
81
81
  }
82
82
  if (accessToken) {
83
83
  return accessToken.startsWith("hf_") ? "hf-token" : "provider-key";
@@ -142,20 +142,21 @@ async function loadDefaultModel(task) {
142
142
  }
143
143
  const taskInfo = tasks[task];
144
144
  if ((taskInfo?.models.length ?? 0) <= 0) {
145
- throw new Error(`No default model defined for task ${task}, please define the model explicitly.`);
145
+ throw new errors_js_1.InferenceClientInputError(`No default model defined for task ${task}, please define the model explicitly.`);
146
146
  }
147
147
  return taskInfo.models[0].id;
148
148
  }
149
149
  async function loadTaskInfo() {
150
- const res = await fetch(`${config_js_1.HF_HUB_URL}/api/tasks`);
150
+ const url = `${config_js_1.HF_HUB_URL}/api/tasks`;
151
+ const res = await fetch(url);
151
152
  if (!res.ok) {
152
- throw new Error("Failed to load tasks definitions from Hugging Face Hub.");
153
+ throw new errors_js_1.InferenceClientHubApiError("Failed to load tasks definitions from Hugging Face Hub.", { url, method: "GET" }, { requestId: res.headers.get("x-request-id") ?? "", status: res.status, body: await res.text() });
153
154
  }
154
155
  return await res.json();
155
156
  }
156
157
  function removeProviderPrefix(model, provider) {
157
158
  if (!model.startsWith(`${provider}/`)) {
158
- throw new Error(`Models from ${provider} must be prefixed by "${provider}/". Got "${model}".`);
159
+ throw new errors_js_1.InferenceClientInputError(`Models from ${provider} must be prefixed by "${provider}/". Got "${model}".`);
159
160
  }
160
161
  return model.slice(provider.length + 1);
161
162
  }
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "3.15.0";
1
+ export declare const PACKAGE_VERSION = "4.0.0";
2
2
  export declare const PACKAGE_NAME = "@huggingface/inference";
3
3
  //# sourceMappingURL=package.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,YAAY,2BAA2B,CAAC"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,2BAA2B,CAAC"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
4
4
  // Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
5
- exports.PACKAGE_VERSION = "3.15.0";
5
+ exports.PACKAGE_VERSION = "4.0.0";
6
6
  exports.PACKAGE_NAME = "@huggingface/inference";
@@ -1 +1 @@
1
- {"version":3,"file":"black-forest-labs.d.ts","sourceRoot":"","sources":["../../../src/providers/black-forest-labs.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGrF,UAAU,uBAAuB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8BAA+B,SAAQ,kBAAmB,YAAW,qBAAqB;;IAKtG,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQlD,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWtF,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAO9B,WAAW,CAChB,QAAQ,EAAE,uBAAuB,EACjC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,EACrB,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAgCzB"}
1
+ {"version":3,"file":"black-forest-labs.d.ts","sourceRoot":"","sources":["../../../src/providers/black-forest-labs.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGrF,UAAU,uBAAuB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8BAA+B,SAAQ,kBAAmB,YAAW,qBAAqB;;IAKtG,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQlD,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWtF,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAO9B,WAAW,CAChB,QAAQ,EAAE,uBAAuB,EACjC,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,EACrB,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAsCzB"}
@@ -17,7 +17,7 @@ exports.BlackForestLabsTextToImageTask = void 0;
17
17
  *
18
18
  * Thanks!
19
19
  */
20
- const InferenceOutputError_js_1 = require("../lib/InferenceOutputError.js");
20
+ const errors_js_1 = require("../errors.js");
21
21
  const delay_js_1 = require("../utils/delay.js");
22
22
  const omit_js_1 = require("../utils/omit.js");
23
23
  const providerHelper_js_1 = require("./providerHelper.js");
@@ -44,7 +44,7 @@ class BlackForestLabsTextToImageTask extends providerHelper_js_1.TaskProviderHel
44
44
  }
45
45
  makeRoute(params) {
46
46
  if (!params) {
47
- throw new Error("Params are required");
47
+ throw new errors_js_1.InferenceClientInputError("Params are required");
48
48
  }
49
49
  return `/v1/${params.model}`;
50
50
  }
@@ -56,7 +56,7 @@ class BlackForestLabsTextToImageTask extends providerHelper_js_1.TaskProviderHel
56
56
  urlObj.searchParams.set("attempt", step.toString(10));
57
57
  const resp = await fetch(urlObj, { headers: { "Content-Type": "application/json" } });
58
58
  if (!resp.ok) {
59
- throw new InferenceOutputError_js_1.InferenceOutputError("Failed to fetch result from black forest labs API");
59
+ throw new errors_js_1.InferenceClientProviderApiError("Failed to fetch result from black forest labs API", { url: urlObj.toString(), method: "GET", headers: { "Content-Type": "application/json" } }, { requestId: resp.headers.get("x-request-id") ?? "", status: resp.status, body: await resp.text() });
60
60
  }
61
61
  const payload = await resp.json();
62
62
  if (typeof payload === "object" &&
@@ -76,7 +76,7 @@ class BlackForestLabsTextToImageTask extends providerHelper_js_1.TaskProviderHel
76
76
  return await image.blob();
77
77
  }
78
78
  }
79
- throw new InferenceOutputError_js_1.InferenceOutputError("Failed to fetch result from black forest labs API");
79
+ throw new errors_js_1.InferenceClientProviderOutputError(`Timed out while waiting for the result from black forest labs API - aborting after 5 attempts`);
80
80
  }
81
81
  }
82
82
  exports.BlackForestLabsTextToImageTask = BlackForestLabsTextToImageTask;
@@ -1 +1 @@
1
- {"version":3,"file":"fal-ai.d.ts","sourceRoot":"","sources":["../../../src/providers/fal-ai.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAG3E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAW,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7F,OAAO,EACN,KAAK,oCAAoC,EACzC,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAEnG,MAAM,WAAW,gBAAgB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,sBAAsB;IAC/B,MAAM,EAAE,KAAK,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACZ,CAAC,CAAC;CACH;AAYD,eAAO,MAAM,2BAA2B,UAA0D,CAAC;AAEnG,uBAAe,SAAU,SAAQ,kBAAkB;gBACtC,GAAG,CAAC,EAAE,MAAM;IAIxB,cAAc,CAAC,MAAM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