@huggingface/inference 3.1.3 → 3.1.4-test

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.
package/dist/index.cjs CHANGED
@@ -4,8 +4,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") {
@@ -228,6 +228,10 @@ function isUrl(modelOrUrl) {
228
228
  return /^http(s?):/.test(modelOrUrl) || modelOrUrl.startsWith("/");
229
229
  }
230
230
 
231
+ // package.json
232
+ var name = "@huggingface/inference";
233
+ var version = "3.1.4-test";
234
+
231
235
  // src/lib/makeRequestOptions.ts
232
236
  var HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_HUB_URL}/api/inference-proxy/{{PROVIDER}}`;
233
237
  var tasks = null;
@@ -268,6 +272,8 @@ async function makeRequestOptions(args, options) {
268
272
  if (accessToken) {
269
273
  headers["Authorization"] = provider === "fal-ai" && authMethod === "provider-key" ? `Key ${accessToken}` : `Bearer ${accessToken}`;
270
274
  }
275
+ const ownUserAgent = `${name}/${version}`;
276
+ headers["User-Agent"] = [ownUserAgent, typeof navigator !== "undefined" ? navigator.userAgent : void 0].filter((x) => x !== void 0).join(" ");
271
277
  const binary = "data" in args && !!args.data;
272
278
  if (!binary) {
273
279
  headers["Content-Type"] = "application/json";
@@ -293,8 +299,8 @@ async function makeRequestOptions(args, options) {
293
299
  credentials = "include";
294
300
  }
295
301
  if (provider === "replicate") {
296
- const version = model.includes(":") ? model.split(":")[1] : void 0;
297
- otherArgs = { input: otherArgs, version };
302
+ const version2 = model.includes(":") ? model.split(":")[1] : void 0;
303
+ otherArgs = { input: otherArgs, version: version2 };
298
304
  }
299
305
  const info = {
300
306
  headers,
@@ -1308,8 +1314,8 @@ var HfInference = class {
1308
1314
  constructor(accessToken = "", defaultOptions = {}) {
1309
1315
  this.accessToken = accessToken;
1310
1316
  this.defaultOptions = defaultOptions;
1311
- for (const [name, fn] of Object.entries(tasks_exports)) {
1312
- Object.defineProperty(this, name, {
1317
+ for (const [name2, fn] of Object.entries(tasks_exports)) {
1318
+ Object.defineProperty(this, name2, {
1313
1319
  enumerable: false,
1314
1320
  value: (params, options) => (
1315
1321
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1329,8 +1335,8 @@ var HfInferenceEndpoint = class {
1329
1335
  constructor(endpointUrl, accessToken = "", defaultOptions = {}) {
1330
1336
  accessToken;
1331
1337
  defaultOptions;
1332
- for (const [name, fn] of Object.entries(tasks_exports)) {
1333
- Object.defineProperty(this, name, {
1338
+ for (const [name2, fn] of Object.entries(tasks_exports)) {
1339
+ Object.defineProperty(this, name2, {
1334
1340
  enumerable: false,
1335
1341
  value: (params, options) => (
1336
1342
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
3
+ for (var name2 in all)
4
+ __defProp(target, name2, { get: all[name2], enumerable: true });
5
5
  };
6
6
 
7
7
  // src/tasks/index.ts
@@ -169,6 +169,10 @@ function isUrl(modelOrUrl) {
169
169
  return /^http(s?):/.test(modelOrUrl) || modelOrUrl.startsWith("/");
170
170
  }
171
171
 
172
+ // package.json
173
+ var name = "@huggingface/inference";
174
+ var version = "3.1.4-test";
175
+
172
176
  // src/lib/makeRequestOptions.ts
173
177
  var HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_HUB_URL}/api/inference-proxy/{{PROVIDER}}`;
174
178
  var tasks = null;
@@ -209,6 +213,8 @@ async function makeRequestOptions(args, options) {
209
213
  if (accessToken) {
210
214
  headers["Authorization"] = provider === "fal-ai" && authMethod === "provider-key" ? `Key ${accessToken}` : `Bearer ${accessToken}`;
211
215
  }
216
+ const ownUserAgent = `${name}/${version}`;
217
+ headers["User-Agent"] = [ownUserAgent, typeof navigator !== "undefined" ? navigator.userAgent : void 0].filter((x) => x !== void 0).join(" ");
212
218
  const binary = "data" in args && !!args.data;
213
219
  if (!binary) {
214
220
  headers["Content-Type"] = "application/json";
@@ -234,8 +240,8 @@ async function makeRequestOptions(args, options) {
234
240
  credentials = "include";
235
241
  }
236
242
  if (provider === "replicate") {
237
- const version = model.includes(":") ? model.split(":")[1] : void 0;
238
- otherArgs = { input: otherArgs, version };
243
+ const version2 = model.includes(":") ? model.split(":")[1] : void 0;
244
+ otherArgs = { input: otherArgs, version: version2 };
239
245
  }
240
246
  const info = {
241
247
  headers,
@@ -1249,8 +1255,8 @@ var HfInference = class {
1249
1255
  constructor(accessToken = "", defaultOptions = {}) {
1250
1256
  this.accessToken = accessToken;
1251
1257
  this.defaultOptions = defaultOptions;
1252
- for (const [name, fn] of Object.entries(tasks_exports)) {
1253
- Object.defineProperty(this, name, {
1258
+ for (const [name2, fn] of Object.entries(tasks_exports)) {
1259
+ Object.defineProperty(this, name2, {
1254
1260
  enumerable: false,
1255
1261
  value: (params, options) => (
1256
1262
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1270,8 +1276,8 @@ var HfInferenceEndpoint = class {
1270
1276
  constructor(endpointUrl, accessToken = "", defaultOptions = {}) {
1271
1277
  accessToken;
1272
1278
  defaultOptions;
1273
- for (const [name, fn] of Object.entries(tasks_exports)) {
1274
- Object.defineProperty(this, name, {
1279
+ for (const [name2, fn] of Object.entries(tasks_exports)) {
1280
+ Object.defineProperty(this, name2, {
1275
1281
  enumerable: false,
1276
1282
  value: (params, options) => (
1277
1283
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1 +1 @@
1
- {"version":3,"file":"makeRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/makeRequestOptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAWpE;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACnC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAiH7C"}
1
+ {"version":3,"file":"makeRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/makeRequestOptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAYpE;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,WAAW,GAAG;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,OAAO,CAAC,EAAE,OAAO,GAAG;IACnB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACnC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAuH7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huggingface/inference",
3
- "version": "3.1.3",
3
+ "version": "3.1.4-test",
4
4
  "packageManager": "pnpm@8.10.5",
5
5
  "license": "MIT",
6
6
  "author": "Tim Mikeladze <tim.mikeladze@gmail.com>",
@@ -7,6 +7,7 @@ import { TOGETHER_API_BASE_URL, TOGETHER_SUPPORTED_MODEL_IDS } from "../provider
7
7
  import type { InferenceProvider } from "../types";
8
8
  import type { InferenceTask, Options, RequestArgs } from "../types";
9
9
  import { isUrl } from "./isUrl";
10
+ import { version as packageVersion, name as packageName } from "../../package.json";
10
11
 
11
12
  const HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_HUB_URL}/api/inference-proxy/{{PROVIDER}}`;
12
13
 
@@ -89,6 +90,12 @@ export async function makeRequestOptions(
89
90
  provider === "fal-ai" && authMethod === "provider-key" ? `Key ${accessToken}` : `Bearer ${accessToken}`;
90
91
  }
91
92
 
93
+ // e.g. @huggingface/inference@3.1.3
94
+ const ownUserAgent = `${packageName}/${packageVersion}`;
95
+ headers["User-Agent"] = [ownUserAgent, typeof navigator !== "undefined" ? navigator.userAgent : undefined]
96
+ .filter((x) => x !== undefined)
97
+ .join(" ");
98
+
92
99
  const binary = "data" in args && !!args.data;
93
100
 
94
101
  if (!binary) {