@huggingface/inference 1.4.2 → 1.4.3
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/README.md +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -10
- package/dist/index.mjs +5 -9
- package/package.json +1 -1
- package/src/{HuggingFace.ts → HfInference.ts} +3 -3
- package/src/index.ts +1 -3
package/README.md
CHANGED
|
@@ -19,9 +19,9 @@ pnpm add @huggingface/inference
|
|
|
19
19
|
### Basic examples
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import
|
|
22
|
+
import { HfInference } from '@huggingface/inference'
|
|
23
23
|
|
|
24
|
-
const hf = new
|
|
24
|
+
const hf = new HfInference('your api key')
|
|
25
25
|
|
|
26
26
|
// Natural Language
|
|
27
27
|
|
|
@@ -177,7 +177,7 @@ HF_ACCESS_TOKEN="your access token" npm run test
|
|
|
177
177
|
## Options
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
|
-
export declare class
|
|
180
|
+
export declare class HfInference {
|
|
181
181
|
private readonly apiKey
|
|
182
182
|
private readonly defaultOptions
|
|
183
183
|
constructor(apiKey: string, defaultOptions?: Options)
|
package/dist/index.d.ts
CHANGED
|
@@ -442,7 +442,7 @@ type AudioClassificationReturnValue = {
|
|
|
442
442
|
score: number;
|
|
443
443
|
};
|
|
444
444
|
type AudioClassificationReturn = AudioClassificationReturnValue[];
|
|
445
|
-
declare class
|
|
445
|
+
declare class HfInference {
|
|
446
446
|
private readonly apiKey;
|
|
447
447
|
private readonly defaultOptions;
|
|
448
448
|
constructor(apiKey: string, defaultOptions?: Options);
|
|
@@ -524,4 +524,4 @@ declare class HuggingFace {
|
|
|
524
524
|
private static toArray;
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
-
export { Args, AudioClassificationArgs, AudioClassificationReturn, AudioClassificationReturnValue, AutomaticSpeechRecognitionArgs, AutomaticSpeechRecognitionReturn, ConversationalArgs, ConversationalReturn, FeatureExtractionArgs, FeatureExtractionReturn, FillMaskArgs, FillMaskReturn,
|
|
527
|
+
export { Args, AudioClassificationArgs, AudioClassificationReturn, AudioClassificationReturnValue, AutomaticSpeechRecognitionArgs, AutomaticSpeechRecognitionReturn, ConversationalArgs, ConversationalReturn, FeatureExtractionArgs, FeatureExtractionReturn, FillMaskArgs, FillMaskReturn, HfInference, ImageClassificationArgs, ImageClassificationReturn, ImageClassificationReturnValue, ImageSegmentationArgs, ImageSegmentationReturn, ImageSegmentationReturnValue, ObjectDetectionArgs, ObjectDetectionReturn, ObjectDetectionReturnValue, Options, QuestionAnswerArgs, QuestionAnswerReturn, SummarizationArgs, SummarizationReturn, TableQuestionAnswerArgs, TableQuestionAnswerReturn, TextClassificationArgs, TextClassificationReturn, TextGenerationArgs, TextGenerationReturn, TokenClassificationArgs, TokenClassificationReturn, TokenClassificationReturnValue, TranslationArgs, TranslationReturn, ZeroShotClassificationArgs, ZeroShotClassificationReturn, ZeroShotClassificationReturnValue };
|
package/dist/index.js
CHANGED
|
@@ -19,13 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/index.ts
|
|
20
20
|
var src_exports = {};
|
|
21
21
|
__export(src_exports, {
|
|
22
|
-
|
|
23
|
-
default: () => src_default
|
|
22
|
+
HfInference: () => HfInference
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(src_exports);
|
|
26
25
|
|
|
27
|
-
// src/
|
|
28
|
-
var
|
|
26
|
+
// src/HfInference.ts
|
|
27
|
+
var HfInference = class {
|
|
29
28
|
apiKey;
|
|
30
29
|
defaultOptions;
|
|
31
30
|
constructor(apiKey, defaultOptions = {}) {
|
|
@@ -72,7 +71,7 @@ var HuggingFace = class {
|
|
|
72
71
|
* Usually used for sentence parsing, either grammatical, or Named Entity Recognition (NER) to understand keywords contained within text. Recommended model: dbmdz/bert-large-cased-finetuned-conll03-english
|
|
73
72
|
*/
|
|
74
73
|
async tokenClassification(args, options) {
|
|
75
|
-
return
|
|
74
|
+
return HfInference.toArray(await this.request(args, options));
|
|
76
75
|
}
|
|
77
76
|
/**
|
|
78
77
|
* This task is well known to translate text from one language to another. Recommended model: Helsinki-NLP/opus-mt-ru-en.
|
|
@@ -84,7 +83,7 @@ var HuggingFace = class {
|
|
|
84
83
|
* This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result. Recommended model: facebook/bart-large-mnli.
|
|
85
84
|
*/
|
|
86
85
|
async zeroShotClassification(args, options) {
|
|
87
|
-
return
|
|
86
|
+
return HfInference.toArray(await this.request(args, options));
|
|
88
87
|
}
|
|
89
88
|
/**
|
|
90
89
|
* This task corresponds to any chatbot like structure. Models tend to have shorter max_length, so please check with caution when using a given model if you need long range dependency or not. Recommended model: microsoft/DialoGPT-large.
|
|
@@ -179,10 +178,7 @@ var HuggingFace = class {
|
|
|
179
178
|
return [obj];
|
|
180
179
|
}
|
|
181
180
|
};
|
|
182
|
-
|
|
183
|
-
// src/index.ts
|
|
184
|
-
var src_default = HuggingFace;
|
|
185
181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
182
|
0 && (module.exports = {
|
|
187
|
-
|
|
183
|
+
HfInference
|
|
188
184
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
var
|
|
1
|
+
// src/HfInference.ts
|
|
2
|
+
var HfInference = class {
|
|
3
3
|
apiKey;
|
|
4
4
|
defaultOptions;
|
|
5
5
|
constructor(apiKey, defaultOptions = {}) {
|
|
@@ -46,7 +46,7 @@ var HuggingFace = class {
|
|
|
46
46
|
* Usually used for sentence parsing, either grammatical, or Named Entity Recognition (NER) to understand keywords contained within text. Recommended model: dbmdz/bert-large-cased-finetuned-conll03-english
|
|
47
47
|
*/
|
|
48
48
|
async tokenClassification(args, options) {
|
|
49
|
-
return
|
|
49
|
+
return HfInference.toArray(await this.request(args, options));
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* This task is well known to translate text from one language to another. Recommended model: Helsinki-NLP/opus-mt-ru-en.
|
|
@@ -58,7 +58,7 @@ var HuggingFace = class {
|
|
|
58
58
|
* This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result. Recommended model: facebook/bart-large-mnli.
|
|
59
59
|
*/
|
|
60
60
|
async zeroShotClassification(args, options) {
|
|
61
|
-
return
|
|
61
|
+
return HfInference.toArray(await this.request(args, options));
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* This task corresponds to any chatbot like structure. Models tend to have shorter max_length, so please check with caution when using a given model if you need long range dependency or not. Recommended model: microsoft/DialoGPT-large.
|
|
@@ -153,10 +153,6 @@ var HuggingFace = class {
|
|
|
153
153
|
return [obj];
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
-
|
|
157
|
-
// src/index.ts
|
|
158
|
-
var src_default = HuggingFace;
|
|
159
156
|
export {
|
|
160
|
-
|
|
161
|
-
src_default as default
|
|
157
|
+
HfInference
|
|
162
158
|
};
|
package/package.json
CHANGED
|
@@ -485,7 +485,7 @@ export type AudioClassificationReturnValue = {
|
|
|
485
485
|
|
|
486
486
|
export type AudioClassificationReturn = AudioClassificationReturnValue[];
|
|
487
487
|
|
|
488
|
-
export class
|
|
488
|
+
export class HfInference {
|
|
489
489
|
private readonly apiKey: string;
|
|
490
490
|
private readonly defaultOptions: Options;
|
|
491
491
|
|
|
@@ -546,7 +546,7 @@ export class HuggingFace {
|
|
|
546
546
|
args: TokenClassificationArgs,
|
|
547
547
|
options?: Options
|
|
548
548
|
): Promise<TokenClassificationReturn> {
|
|
549
|
-
return
|
|
549
|
+
return HfInference.toArray(await this.request(args, options));
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
/**
|
|
@@ -563,7 +563,7 @@ export class HuggingFace {
|
|
|
563
563
|
args: ZeroShotClassificationArgs,
|
|
564
564
|
options?: Options
|
|
565
565
|
): Promise<ZeroShotClassificationReturn> {
|
|
566
|
-
return
|
|
566
|
+
return HfInference.toArray(await this.request(args, options));
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
/**
|
package/src/index.ts
CHANGED