New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@huggingface/inference

Package Overview
Dependencies
Maintainers
3
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@huggingface/inference - npm Package Compare versions

Comparing version

to
2.6.3

8

./dist/index.js

@@ -105,3 +105,3 @@ /// <reference path="./index.d.ts" />

var HF_HUB_URL = "https://huggingface.co";
async function getDefaultTask(model, accessToken) {
async function getDefaultTask(model, accessToken, options) {
if (isUrl(model)) {

@@ -117,3 +117,3 @@ return null;

if (cachedTask === void 0) {
const modelTask = await fetch(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
const modelTask = await (options?.fetch ?? fetch)(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}

@@ -603,3 +603,3 @@ }).then((resp) => resp.json()).then((json) => json.pipeline_tag).catch(() => null);

async function featureExtraction(args, options) {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : void 0;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : void 0;
const res = await request(args, {

@@ -659,3 +659,3 @@ ...options,

async function sentenceSimilarity(args, options) {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : void 0;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : void 0;
const res = await request(args, {

@@ -662,0 +662,0 @@ ...options,

@@ -105,3 +105,3 @@ /// <reference path="./index.d.ts" />

var HF_HUB_URL = "https://huggingface.co";
async function getDefaultTask(model, accessToken) {
async function getDefaultTask(model, accessToken, options) {
if (isUrl(model)) {

@@ -117,3 +117,3 @@ return null;

if (cachedTask === void 0) {
const modelTask = await fetch(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
const modelTask = await (options?.fetch ?? fetch)(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}

@@ -603,3 +603,3 @@ }).then((resp) => resp.json()).then((json) => json.pipeline_tag).catch(() => null);

async function featureExtraction(args, options) {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : void 0;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : void 0;
const res = await request(args, {

@@ -659,3 +659,3 @@ ...options,

async function sentenceSimilarity(args, options) {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : void 0;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : void 0;
const res = await request(args, {

@@ -662,0 +662,0 @@ ...options,

{
"name": "@huggingface/inference",
"version": "2.6.2",
"version": "2.6.3",
"packageManager": "pnpm@8.3.1",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -13,2 +13,6 @@ import { isUrl } from "./isUrl";

export interface DefaultTaskOptions {
fetch?: typeof fetch;
}
/**

@@ -20,3 +24,7 @@ * Get the default task. Use a LRU cache of 1000 items with 10 minutes expiration

*/
export async function getDefaultTask(model: string, accessToken: string | undefined): Promise<string | null> {
export async function getDefaultTask(
model: string,
accessToken: string | undefined,
options?: DefaultTaskOptions
): Promise<string | null> {
if (isUrl(model)) {

@@ -35,3 +43,3 @@ return null;

if (cachedTask === undefined) {
const modelTask = await fetch(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
const modelTask = await (options?.fetch ?? fetch)(`${HF_HUB_URL}/api/models/${model}?expand[]=pipeline_tag`, {
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},

@@ -38,0 +46,0 @@ })

@@ -28,3 +28,3 @@ import { InferenceOutputError } from "../../lib/InferenceOutputError";

): Promise<FeatureExtractionOutput> {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : undefined;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : undefined;

@@ -31,0 +31,0 @@ const res = await request<FeatureExtractionOutput>(args, {

@@ -28,3 +28,3 @@ import { InferenceOutputError } from "../../lib/InferenceOutputError";

): Promise<SentenceSimilarityOutput> {
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken) : undefined;
const defaultTask = args.model ? await getDefaultTask(args.model, args.accessToken, options) : undefined;
const res = await request<SentenceSimilarityOutput>(args, {

@@ -31,0 +31,0 @@ ...options,

Sorry, the diff of this file is not supported yet