@workglow/huggingface-inference 0.3.37 → 0.3.39
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/ai/HfInferenceProvider.d.ts +2 -43
- package/dist/ai/HfInferenceProvider.d.ts.map +1 -1
- package/dist/ai/HfInferenceQueuedProvider.d.ts +2 -43
- package/dist/ai/HfInferenceQueuedProvider.d.ts.map +1 -1
- package/dist/ai/common/HFI_ModelInfo.d.ts +5 -0
- package/dist/ai/common/HFI_ModelInfo.d.ts.map +1 -1
- package/dist/ai/common/HFI_ModelSchema.d.ts +70 -3
- package/dist/ai/common/HFI_ModelSchema.d.ts.map +1 -1
- package/dist/ai/common/HFI_TextGeneration.d.ts.map +1 -1
- package/dist/ai/common/HFI_TextRewriter.d.ts.map +1 -1
- package/dist/ai/common/HFI_TextSummary.d.ts.map +1 -1
- package/dist/ai/common/HFI_ToolCalling.d.ts.map +1 -1
- package/dist/ai/index.d.ts +1 -15
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai-runtime.js +111 -28
- package/dist/ai-runtime.js.map +7 -7
- package/dist/ai.js +111 -28
- package/dist/ai.js.map +8 -8
- package/package.json +13 -12
|
@@ -5,49 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Capability, ModelRecord } from "@workglow/ai/worker";
|
|
7
7
|
import { AiProvider } from "@workglow/ai/worker";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description?: string | undefined;
|
|
11
|
-
metadata?: {
|
|
12
|
-
[x: string]: unknown;
|
|
13
|
-
} | undefined;
|
|
14
|
-
model_id?: string | undefined;
|
|
15
|
-
provider: "HF_INFERENCE";
|
|
16
|
-
provider_config: {
|
|
17
|
-
credential_key?: string | undefined;
|
|
18
|
-
model_name: string;
|
|
19
|
-
provider?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
title?: string | undefined;
|
|
22
|
-
}>[] | undefined, previewTasks?: Record<string, import("@workglow/ai").AiProviderPreviewRunFn<any, any, {
|
|
23
|
-
capabilities?: string[] | undefined;
|
|
24
|
-
description?: string | undefined;
|
|
25
|
-
metadata?: {
|
|
26
|
-
[x: string]: unknown;
|
|
27
|
-
} | undefined;
|
|
28
|
-
model_id?: string | undefined;
|
|
29
|
-
provider: "HF_INFERENCE";
|
|
30
|
-
provider_config: {
|
|
31
|
-
credential_key?: string | undefined;
|
|
32
|
-
model_name: string;
|
|
33
|
-
provider?: string | undefined;
|
|
34
|
-
};
|
|
35
|
-
title?: string | undefined;
|
|
36
|
-
}>> | undefined) => AiProvider<{
|
|
37
|
-
capabilities?: string[] | undefined;
|
|
38
|
-
description?: string | undefined;
|
|
39
|
-
metadata?: {
|
|
40
|
-
[x: string]: unknown;
|
|
41
|
-
} | undefined;
|
|
42
|
-
model_id?: string | undefined;
|
|
43
|
-
provider: "HF_INFERENCE";
|
|
44
|
-
provider_config: {
|
|
45
|
-
credential_key?: string | undefined;
|
|
46
|
-
model_name: string;
|
|
47
|
-
provider?: string | undefined;
|
|
48
|
-
};
|
|
49
|
-
title?: string | undefined;
|
|
50
|
-
}> & {
|
|
8
|
+
import type { HfInferenceModelConfig } from "./common/HFI_ModelSchema";
|
|
9
|
+
declare const HfInferenceProvider_base: new (promiseRunFns?: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any, HfInferenceModelConfig>[] | undefined, previewTasks?: Record<string, import("@workglow/ai").AiProviderPreviewRunFn<any, any, HfInferenceModelConfig>> | undefined) => AiProvider<HfInferenceModelConfig> & {
|
|
51
10
|
readonly name: string;
|
|
52
11
|
readonly displayName: string;
|
|
53
12
|
readonly isLocal: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HfInferenceProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HfInferenceProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"HfInferenceProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HfInferenceProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;;;;;;;;AAEvE;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,wBAMxC;IACU,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAEpE;IAED,UAAmB,gBAAgB,IAAI,SAAS;QAAE,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAElF;CACF"}
|
|
@@ -5,49 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Capability, ModelRecord } from "@workglow/ai";
|
|
7
7
|
import { AiProvider } from "@workglow/ai";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description?: string | undefined;
|
|
11
|
-
metadata?: {
|
|
12
|
-
[x: string]: unknown;
|
|
13
|
-
} | undefined;
|
|
14
|
-
model_id?: string | undefined;
|
|
15
|
-
provider: "HF_INFERENCE";
|
|
16
|
-
provider_config: {
|
|
17
|
-
credential_key?: string | undefined;
|
|
18
|
-
model_name: string;
|
|
19
|
-
provider?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
title?: string | undefined;
|
|
22
|
-
}>[] | undefined, previewTasks?: Record<string, import("@workglow/ai").AiProviderPreviewRunFn<any, any, {
|
|
23
|
-
capabilities?: string[] | undefined;
|
|
24
|
-
description?: string | undefined;
|
|
25
|
-
metadata?: {
|
|
26
|
-
[x: string]: unknown;
|
|
27
|
-
} | undefined;
|
|
28
|
-
model_id?: string | undefined;
|
|
29
|
-
provider: "HF_INFERENCE";
|
|
30
|
-
provider_config: {
|
|
31
|
-
credential_key?: string | undefined;
|
|
32
|
-
model_name: string;
|
|
33
|
-
provider?: string | undefined;
|
|
34
|
-
};
|
|
35
|
-
title?: string | undefined;
|
|
36
|
-
}>> | undefined) => AiProvider<{
|
|
37
|
-
capabilities?: string[] | undefined;
|
|
38
|
-
description?: string | undefined;
|
|
39
|
-
metadata?: {
|
|
40
|
-
[x: string]: unknown;
|
|
41
|
-
} | undefined;
|
|
42
|
-
model_id?: string | undefined;
|
|
43
|
-
provider: "HF_INFERENCE";
|
|
44
|
-
provider_config: {
|
|
45
|
-
credential_key?: string | undefined;
|
|
46
|
-
model_name: string;
|
|
47
|
-
provider?: string | undefined;
|
|
48
|
-
};
|
|
49
|
-
title?: string | undefined;
|
|
50
|
-
}> & {
|
|
8
|
+
import type { HfInferenceModelConfig } from "./common/HFI_ModelSchema";
|
|
9
|
+
declare const HfInferenceQueuedProvider_base: new (promiseRunFns?: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any, HfInferenceModelConfig>[] | undefined, previewTasks?: Record<string, import("@workglow/ai").AiProviderPreviewRunFn<any, any, HfInferenceModelConfig>> | undefined) => AiProvider<HfInferenceModelConfig> & {
|
|
51
10
|
readonly name: string;
|
|
52
11
|
readonly displayName: string;
|
|
53
12
|
readonly isLocal: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HfInferenceQueuedProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HfInferenceQueuedProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"HfInferenceQueuedProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HfInferenceQueuedProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;;;;;;;;AAEvE,4FAA4F;AAC5F,qBAAa,yBAA0B,SAAQ,8BAM9C;IACU,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAEpE;IAED,UAAmB,gBAAgB,IAAI,SAAS;QAAE,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAElF;CACF"}
|
|
@@ -5,5 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { AiProviderRunFn, ModelInfoTaskInput, ModelInfoTaskOutput } from "@workglow/ai";
|
|
7
7
|
import type { HfInferenceModelConfig } from "./HFI_ModelSchema";
|
|
8
|
+
/**
|
|
9
|
+
* One-shot run-fn for `["model.info"]`. Verifies the model exists on the
|
|
10
|
+
* Hugging Face Hub, then emits a remote info record. When `detail` is
|
|
11
|
+
* `"dimensions"`, attaches provider_config dimensions after the check.
|
|
12
|
+
*/
|
|
8
13
|
export declare const HFI_ModelInfo: AiProviderRunFn<ModelInfoTaskInput, ModelInfoTaskOutput, HfInferenceModelConfig>;
|
|
9
14
|
//# sourceMappingURL=HFI_ModelInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_ModelInfo.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ModelInfo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"HFI_ModelInfo.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ModelInfo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAG7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAkGhE;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,eAAe,CACzC,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,CAsBvB,CAAC"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import type { WithModelPricing } from "@workglow/ai/worker";
|
|
7
|
+
import type { FromSchema } from "@workglow/util/worker";
|
|
7
8
|
export declare const HfInferenceModelSchema: {
|
|
8
9
|
readonly type: "object";
|
|
9
10
|
readonly properties: {
|
|
@@ -57,11 +58,44 @@ export declare const HfInferenceModelRecordSchema: {
|
|
|
57
58
|
readonly type: "string";
|
|
58
59
|
readonly "x-ui-editor": "textarea";
|
|
59
60
|
};
|
|
61
|
+
readonly effort: {
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
readonly enum: readonly ["none", "low", "medium", "high", "extra", "ultra"];
|
|
64
|
+
readonly description: "Coarse thinking/reasoning dial. Native provider_config thinking knobs always win when set.";
|
|
65
|
+
};
|
|
60
66
|
readonly metadata: {
|
|
61
67
|
readonly type: "object";
|
|
62
68
|
readonly default: {};
|
|
63
69
|
readonly "x-ui-hidden": true;
|
|
64
70
|
};
|
|
71
|
+
readonly pricing: {
|
|
72
|
+
readonly type: "object";
|
|
73
|
+
readonly description: "Per-million-token rates. Declared by the caller; the library ships none.";
|
|
74
|
+
readonly properties: {
|
|
75
|
+
readonly currency: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly default: "USD";
|
|
78
|
+
};
|
|
79
|
+
readonly input: {
|
|
80
|
+
readonly type: "number";
|
|
81
|
+
};
|
|
82
|
+
readonly output: {
|
|
83
|
+
readonly type: "number";
|
|
84
|
+
};
|
|
85
|
+
readonly cached: {
|
|
86
|
+
readonly type: "number";
|
|
87
|
+
};
|
|
88
|
+
readonly cacheWrite: {
|
|
89
|
+
readonly type: "number";
|
|
90
|
+
};
|
|
91
|
+
readonly cacheStoragePerHour: {
|
|
92
|
+
readonly type: "number";
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
readonly required: readonly ["currency"];
|
|
96
|
+
readonly additionalProperties: false;
|
|
97
|
+
readonly "x-ui-hidden": true;
|
|
98
|
+
};
|
|
65
99
|
readonly provider: {
|
|
66
100
|
readonly const: "HF_INFERENCE";
|
|
67
101
|
readonly description: "Discriminator: Hugging Face Inference API provider.";
|
|
@@ -92,7 +126,7 @@ export declare const HfInferenceModelRecordSchema: {
|
|
|
92
126
|
readonly required: readonly ["model_id", "capabilities", "provider", "title", "description", "provider_config", "metadata", "provider", "provider_config"];
|
|
93
127
|
readonly additionalProperties: false;
|
|
94
128
|
};
|
|
95
|
-
export type HfInferenceModelRecord = FromSchema<typeof HfInferenceModelRecordSchema
|
|
129
|
+
export type HfInferenceModelRecord = WithModelPricing<FromSchema<typeof HfInferenceModelRecordSchema>>;
|
|
96
130
|
export declare const HfInferenceModelConfigSchema: {
|
|
97
131
|
readonly type: "object";
|
|
98
132
|
readonly properties: {
|
|
@@ -113,11 +147,44 @@ export declare const HfInferenceModelConfigSchema: {
|
|
|
113
147
|
readonly type: "string";
|
|
114
148
|
readonly "x-ui-editor": "textarea";
|
|
115
149
|
};
|
|
150
|
+
readonly effort: {
|
|
151
|
+
readonly type: "string";
|
|
152
|
+
readonly enum: readonly ["none", "low", "medium", "high", "extra", "ultra"];
|
|
153
|
+
readonly description: "Coarse thinking/reasoning dial. Native provider_config thinking knobs always win when set.";
|
|
154
|
+
};
|
|
116
155
|
readonly metadata: {
|
|
117
156
|
readonly type: "object";
|
|
118
157
|
readonly default: {};
|
|
119
158
|
readonly "x-ui-hidden": true;
|
|
120
159
|
};
|
|
160
|
+
readonly pricing: {
|
|
161
|
+
readonly type: "object";
|
|
162
|
+
readonly description: "Per-million-token rates. Declared by the caller; the library ships none.";
|
|
163
|
+
readonly properties: {
|
|
164
|
+
readonly currency: {
|
|
165
|
+
readonly type: "string";
|
|
166
|
+
readonly default: "USD";
|
|
167
|
+
};
|
|
168
|
+
readonly input: {
|
|
169
|
+
readonly type: "number";
|
|
170
|
+
};
|
|
171
|
+
readonly output: {
|
|
172
|
+
readonly type: "number";
|
|
173
|
+
};
|
|
174
|
+
readonly cached: {
|
|
175
|
+
readonly type: "number";
|
|
176
|
+
};
|
|
177
|
+
readonly cacheWrite: {
|
|
178
|
+
readonly type: "number";
|
|
179
|
+
};
|
|
180
|
+
readonly cacheStoragePerHour: {
|
|
181
|
+
readonly type: "number";
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
readonly required: readonly ["currency"];
|
|
185
|
+
readonly additionalProperties: false;
|
|
186
|
+
readonly "x-ui-hidden": true;
|
|
187
|
+
};
|
|
121
188
|
readonly provider: {
|
|
122
189
|
readonly const: "HF_INFERENCE";
|
|
123
190
|
readonly description: "Discriminator: Hugging Face Inference API provider.";
|
|
@@ -148,5 +215,5 @@ export declare const HfInferenceModelConfigSchema: {
|
|
|
148
215
|
readonly required: readonly ["provider", "provider_config", "provider", "provider_config"];
|
|
149
216
|
readonly additionalProperties: false;
|
|
150
217
|
};
|
|
151
|
-
export type HfInferenceModelConfig = FromSchema<typeof HfInferenceModelConfigSchema
|
|
218
|
+
export type HfInferenceModelConfig = WithModelPricing<FromSchema<typeof HfInferenceModelConfigSchema>>;
|
|
152
219
|
//# sourceMappingURL=HFI_ModelSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"HFI_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG9E,eAAO,MAAM,sBAAsB;mBAC3B,QAAQ;;iBAEZ,QAAQ;qBACN,KAAK;qBACL,WAAW,EAAE,qDAAqD;;iBAEpE,eAAe;qBACb,IAAI,EAAE,QAAQ;qBACd,WAAW,EAAE,gDAAgD;qBAC7D,UAAU;yBACR,UAAU;6BACR,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,gFAAgF;;yBAEpF,cAAc;6BACZ,IAAI,EAAE,QAAQ;6BACd,MAAM,EAAE,YAAY;6BACpB,WAAW,EAAE,yDAAyD;6BACtE,aAAa;;yBAEf,QAAQ;6BACN,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,iGAAiG;;;qBAGvG,QAAQ;qBACR,oBAAoB;;;;;CAKe,CAAC;AAE1C,eAAO,MAAM,4BAA4B;mBACjC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAjCV,KAAK;qBACL,WAAW,EAAE,qDAAqD;;;qBAGlE,IAAI,EAAE,QAAQ;qBACd,WAAW,EAAE,gDAAgD;qBAC7D,UAAU;yBACR,UAAU;6BACR,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,gFAAgF;;yBAEpF,cAAc;6BACZ,IAAI,EAAE,QAAQ;6BACd,MAAM,EAAE,YAAY;6BACpB,WAAW,EAAE,yDAAyD;6BACtE,aAAa;;yBAEf,QAAQ;6BACN,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,iGAAiG;;;qBAGvG,QAAQ;qBACR,oBAAoB;;;;;CAee,CAAC;AAE1C,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CACnD,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAChD,CAAC;AAEF,eAAO,MAAM,4BAA4B;mBACjC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA/CV,KAAK;qBACL,WAAW,EAAE,qDAAqD;;;qBAGlE,IAAI,EAAE,QAAQ;qBACd,WAAW,EAAE,gDAAgD;qBAC7D,UAAU;yBACR,UAAU;6BACR,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,gFAAgF;;yBAEpF,cAAc;6BACZ,IAAI,EAAE,QAAQ;6BACd,MAAM,EAAE,YAAY;6BACpB,WAAW,EAAE,yDAAyD;6BACtE,aAAa;;yBAEf,QAAQ;6BACN,IAAI,EAAE,QAAQ;6BACd,WAAW,EACT,iGAAiG;;;qBAGvG,QAAQ;qBACR,oBAAoB;;;;;CA6Be,CAAC;AAE1C,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CACnD,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_TextGeneration.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextGeneration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"HFI_TextGeneration.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextGeneration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAYhE,eAAO,MAAM,yBAAyB,EAAE,eAAe,CACrD,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,CAiEvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_TextRewriter.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextRewriter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HFI_TextRewriter.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextRewriter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,eAAO,MAAM,uBAAuB,EAAE,eAAe,CACnD,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,CAuCvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_TextSummary.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextSummary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"HFI_TextSummary.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_TextSummary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,eAAO,MAAM,sBAAsB,EAAE,eAAe,CAClD,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,CAuCvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFI_ToolCalling.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ToolCalling.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"HFI_ToolCalling.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFI_ToolCalling.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAUjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,eAAO,MAAM,sBAAsB,EAAE,eAAe,CAClD,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,CAqCvB,CAAC"}
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -19,21 +19,7 @@ export declare const _testOnly: {
|
|
|
19
19
|
readonly HFI_RUN_FN_SPECS: {
|
|
20
20
|
serves: ["image.editing"] | ["image.generation"] | ["model.info"] | ["model.search"] | ["text.embedding"] | ["text.generation"] | ["text.rewriter"] | ["text.summary"] | ["text.generation", "tool-use"];
|
|
21
21
|
}[];
|
|
22
|
-
readonly HFI_RUN_FNS: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any,
|
|
23
|
-
capabilities?: string[] | undefined;
|
|
24
|
-
description?: string | undefined;
|
|
25
|
-
metadata?: {
|
|
26
|
-
[x: string]: unknown;
|
|
27
|
-
} | undefined;
|
|
28
|
-
model_id?: string | undefined;
|
|
29
|
-
provider: "HF_INFERENCE";
|
|
30
|
-
provider_config: {
|
|
31
|
-
credential_key?: string | undefined;
|
|
32
|
-
model_name: string;
|
|
33
|
-
provider?: string | undefined;
|
|
34
|
-
};
|
|
35
|
-
title?: string | undefined;
|
|
36
|
-
}>[];
|
|
22
|
+
readonly HFI_RUN_FNS: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any, import(".").HfInferenceModelConfig>[];
|
|
37
23
|
readonly _setHfInferenceSDKForTesting: typeof _setHfInferenceSDKForTesting;
|
|
38
24
|
};
|
|
39
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ai/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;CAKZ,CAAC"}
|
package/dist/ai-runtime.js
CHANGED
|
@@ -225,7 +225,71 @@ var HFI_ImageGenerate_Stream = async (input, model, signal, emit) => {
|
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
// src/ai/common/HFI_ModelInfo.ts
|
|
228
|
-
|
|
228
|
+
import { resolveApiKey as resolveApiKey2 } from "@workglow/ai/provider-utils";
|
|
229
|
+
var HF_API_BASE = "https://huggingface.co/api";
|
|
230
|
+
var HF_REPO_SEGMENT = /^[\w.-]+$/;
|
|
231
|
+
function isValidSegment(segment) {
|
|
232
|
+
return HF_REPO_SEGMENT.test(segment) && segment !== "." && segment !== "..";
|
|
233
|
+
}
|
|
234
|
+
function hfModelPath(modelName) {
|
|
235
|
+
const segments = modelName.split("/");
|
|
236
|
+
if (segments.length > 2 || !segments.every(isValidSegment)) {
|
|
237
|
+
throw new Error(`${HF_INFERENCE} model "${modelName}" is not a valid Hugging Face repo id`);
|
|
238
|
+
}
|
|
239
|
+
return segments.map(encodeURIComponent).join("/");
|
|
240
|
+
}
|
|
241
|
+
function modelNameOf(model) {
|
|
242
|
+
const name = model?.provider_config?.model_name;
|
|
243
|
+
if (!name) {
|
|
244
|
+
throw new Error("Missing model name in provider_config.model_name.");
|
|
245
|
+
}
|
|
246
|
+
return name;
|
|
247
|
+
}
|
|
248
|
+
function apiKeyOf(model) {
|
|
249
|
+
const config = model?.provider_config;
|
|
250
|
+
try {
|
|
251
|
+
return resolveApiKey2({
|
|
252
|
+
config,
|
|
253
|
+
envVar: "HF_TOKEN",
|
|
254
|
+
providerLabel: "Hugging Face Inference"
|
|
255
|
+
});
|
|
256
|
+
} catch {
|
|
257
|
+
return config?.api_key ?? config?.credential_key;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function assertHfModelExists(model, signal) {
|
|
261
|
+
const modelName = modelNameOf(model);
|
|
262
|
+
const token = apiKeyOf(model);
|
|
263
|
+
const res = await fetch(`${HF_API_BASE}/models/${hfModelPath(modelName)}`, {
|
|
264
|
+
signal,
|
|
265
|
+
headers: token ? { Authorization: `Bearer ${token}` } : undefined
|
|
266
|
+
});
|
|
267
|
+
if (res.status === 404) {
|
|
268
|
+
throw new Error(`${HF_INFERENCE} model "${modelName}" was not found (provider API returned not found)`);
|
|
269
|
+
}
|
|
270
|
+
if (res.status >= 400 && res.status < 500) {
|
|
271
|
+
throw new Error(`${HF_INFERENCE} model "${modelName}" lookup was rejected by the Hugging Face API (${res.status})`);
|
|
272
|
+
}
|
|
273
|
+
if (!res.ok) {
|
|
274
|
+
throw new Error(`${HF_INFERENCE} model "${modelName}" lookup failed (HuggingFace API returned ${res.status})`);
|
|
275
|
+
}
|
|
276
|
+
return modelName;
|
|
277
|
+
}
|
|
278
|
+
function remoteInfoBase(input) {
|
|
279
|
+
return {
|
|
280
|
+
model: input.model,
|
|
281
|
+
is_local: false,
|
|
282
|
+
is_remote: true,
|
|
283
|
+
supports_browser: true,
|
|
284
|
+
supports_node: true,
|
|
285
|
+
is_cached: false,
|
|
286
|
+
is_loaded: false,
|
|
287
|
+
file_sizes: null
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
var HFI_ModelInfo = async (input, model, signal, emit) => {
|
|
291
|
+
await assertHfModelExists(model, signal);
|
|
292
|
+
const base = remoteInfoBase(input);
|
|
229
293
|
if (input.detail === "dimensions") {
|
|
230
294
|
const pc = model?.provider_config;
|
|
231
295
|
const native_dimensions = typeof pc?.native_dimensions === "number" ? pc.native_dimensions : undefined;
|
|
@@ -233,33 +297,14 @@ var HFI_ModelInfo = async (input, model, _signal, emit) => {
|
|
|
233
297
|
emit({
|
|
234
298
|
type: "finish",
|
|
235
299
|
data: {
|
|
236
|
-
|
|
237
|
-
is_local: false,
|
|
238
|
-
is_remote: true,
|
|
239
|
-
supports_browser: true,
|
|
240
|
-
supports_node: true,
|
|
241
|
-
is_cached: false,
|
|
242
|
-
is_loaded: false,
|
|
243
|
-
file_sizes: null,
|
|
300
|
+
...base,
|
|
244
301
|
...native_dimensions !== undefined ? { native_dimensions } : {},
|
|
245
302
|
...mrl ? { mrl } : {}
|
|
246
303
|
}
|
|
247
304
|
});
|
|
248
305
|
return;
|
|
249
306
|
}
|
|
250
|
-
emit({
|
|
251
|
-
type: "finish",
|
|
252
|
-
data: {
|
|
253
|
-
model: input.model,
|
|
254
|
-
is_local: false,
|
|
255
|
-
is_remote: true,
|
|
256
|
-
supports_browser: true,
|
|
257
|
-
supports_node: true,
|
|
258
|
-
is_cached: false,
|
|
259
|
-
is_loaded: false,
|
|
260
|
-
file_sizes: null
|
|
261
|
-
}
|
|
262
|
-
});
|
|
307
|
+
emit({ type: "finish", data: base });
|
|
263
308
|
};
|
|
264
309
|
|
|
265
310
|
// src/ai/common/HFI_ModelSearch.ts
|
|
@@ -344,6 +389,10 @@ var HFI_TextEmbedding = async (input, model, signal, emit) => {
|
|
|
344
389
|
};
|
|
345
390
|
|
|
346
391
|
// src/ai/common/HFI_TextGeneration.ts
|
|
392
|
+
import {
|
|
393
|
+
createEstimatedOutputUsageReporter,
|
|
394
|
+
mapOpenAIChatUsage
|
|
395
|
+
} from "@workglow/ai/provider-utils";
|
|
347
396
|
import { toOpenAIMessages } from "@workglow/ai/worker";
|
|
348
397
|
var HFI_TextGeneration_Stream = async (input, model, signal, emit) => {
|
|
349
398
|
const client = await getClient(model);
|
|
@@ -357,6 +406,9 @@ var HFI_TextGeneration_Stream = async (input, model, signal, emit) => {
|
|
|
357
406
|
prompt: "",
|
|
358
407
|
tools: []
|
|
359
408
|
}).map((m) => ({ ...m, content: m.content ?? "" })) : [{ role: "user", content: input.prompt }];
|
|
409
|
+
const provisionalUsage = createEstimatedOutputUsageReporter(emit);
|
|
410
|
+
provisionalUsage.onPrompt(messages.map((m) => typeof m.content === "string" ? m.content : "").filter(Boolean).join(`
|
|
411
|
+
`));
|
|
360
412
|
const stream = client.chatCompletionStream({
|
|
361
413
|
model: modelName,
|
|
362
414
|
messages,
|
|
@@ -366,20 +418,31 @@ var HFI_TextGeneration_Stream = async (input, model, signal, emit) => {
|
|
|
366
418
|
frequency_penalty: input.frequencyPenalty,
|
|
367
419
|
provider
|
|
368
420
|
}, { signal });
|
|
421
|
+
let usage;
|
|
369
422
|
for await (const chunk of stream) {
|
|
423
|
+
usage = mapOpenAIChatUsage(chunk.usage) ?? usage;
|
|
370
424
|
const delta = chunk.choices?.[0]?.delta?.content ?? "";
|
|
371
425
|
if (delta) {
|
|
426
|
+
provisionalUsage.onText(delta);
|
|
372
427
|
emit({ type: "text-delta", port: "text", textDelta: delta });
|
|
373
428
|
}
|
|
374
429
|
}
|
|
375
|
-
|
|
430
|
+
provisionalUsage.flush();
|
|
431
|
+
emit({ type: "finish", data: {}, usage });
|
|
376
432
|
};
|
|
377
433
|
|
|
378
434
|
// src/ai/common/HFI_TextRewriter.ts
|
|
435
|
+
import {
|
|
436
|
+
createEstimatedOutputUsageReporter as createEstimatedOutputUsageReporter2,
|
|
437
|
+
mapOpenAIChatUsage as mapOpenAIChatUsage2
|
|
438
|
+
} from "@workglow/ai/provider-utils";
|
|
379
439
|
var HFI_TextRewriter_Stream = async (input, model, signal, emit) => {
|
|
380
440
|
const client = await getClient(model);
|
|
381
441
|
const modelName = getModelName(model);
|
|
382
442
|
const provider = getProvider(model);
|
|
443
|
+
const provisionalUsage = createEstimatedOutputUsageReporter2(emit);
|
|
444
|
+
provisionalUsage.onPrompt(`${typeof input.prompt === "string" ? input.prompt : ""}
|
|
445
|
+
${typeof input.text === "string" ? input.text : ""}`);
|
|
383
446
|
const stream = client.chatCompletionStream({
|
|
384
447
|
model: modelName,
|
|
385
448
|
messages: [
|
|
@@ -388,20 +451,31 @@ var HFI_TextRewriter_Stream = async (input, model, signal, emit) => {
|
|
|
388
451
|
],
|
|
389
452
|
provider
|
|
390
453
|
}, { signal });
|
|
454
|
+
let usage;
|
|
391
455
|
for await (const chunk of stream) {
|
|
456
|
+
usage = mapOpenAIChatUsage2(chunk.usage) ?? usage;
|
|
392
457
|
const delta = chunk.choices?.[0]?.delta?.content ?? "";
|
|
393
458
|
if (delta) {
|
|
459
|
+
provisionalUsage.onText(delta);
|
|
394
460
|
emit({ type: "text-delta", port: "text", textDelta: delta });
|
|
395
461
|
}
|
|
396
462
|
}
|
|
397
|
-
|
|
463
|
+
provisionalUsage.flush();
|
|
464
|
+
emit({ type: "finish", data: {}, usage });
|
|
398
465
|
};
|
|
399
466
|
|
|
400
467
|
// src/ai/common/HFI_TextSummary.ts
|
|
468
|
+
import {
|
|
469
|
+
createEstimatedOutputUsageReporter as createEstimatedOutputUsageReporter3,
|
|
470
|
+
mapOpenAIChatUsage as mapOpenAIChatUsage3
|
|
471
|
+
} from "@workglow/ai/provider-utils";
|
|
401
472
|
var HFI_TextSummary_Stream = async (input, model, signal, emit) => {
|
|
402
473
|
const client = await getClient(model);
|
|
403
474
|
const modelName = getModelName(model);
|
|
404
475
|
const provider = getProvider(model);
|
|
476
|
+
const provisionalUsage = createEstimatedOutputUsageReporter3(emit);
|
|
477
|
+
provisionalUsage.onPrompt(`Summarize the following text concisely.
|
|
478
|
+
${typeof input.text === "string" ? input.text : ""}`);
|
|
405
479
|
const stream = client.chatCompletionStream({
|
|
406
480
|
model: modelName,
|
|
407
481
|
messages: [
|
|
@@ -410,19 +484,25 @@ var HFI_TextSummary_Stream = async (input, model, signal, emit) => {
|
|
|
410
484
|
],
|
|
411
485
|
provider
|
|
412
486
|
}, { signal });
|
|
487
|
+
let usage;
|
|
413
488
|
for await (const chunk of stream) {
|
|
489
|
+
usage = mapOpenAIChatUsage3(chunk.usage) ?? usage;
|
|
414
490
|
const delta = chunk.choices?.[0]?.delta?.content ?? "";
|
|
415
491
|
if (delta) {
|
|
492
|
+
provisionalUsage.onText(delta);
|
|
416
493
|
emit({ type: "text-delta", port: "text", textDelta: delta });
|
|
417
494
|
}
|
|
418
495
|
}
|
|
419
|
-
|
|
496
|
+
provisionalUsage.flush();
|
|
497
|
+
emit({ type: "finish", data: {}, usage });
|
|
420
498
|
};
|
|
421
499
|
|
|
422
500
|
// src/ai/common/HFI_ToolCalling.ts
|
|
423
501
|
import {
|
|
424
502
|
accumulateOpenAIChatStream,
|
|
425
503
|
buildOpenAITools,
|
|
504
|
+
createEstimatedOutputUsageReporter as createEstimatedOutputUsageReporter4,
|
|
505
|
+
mapOpenAIChatUsage as mapOpenAIChatUsage4,
|
|
426
506
|
mapOpenAIToolChoice
|
|
427
507
|
} from "@workglow/ai/provider-utils";
|
|
428
508
|
import { toOpenAIMessages as toOpenAIMessages2 } from "@workglow/ai/worker";
|
|
@@ -433,6 +513,8 @@ var HFI_ToolCalling_Stream = async (input, model, signal, emit) => {
|
|
|
433
513
|
const tools = buildOpenAITools(input.tools);
|
|
434
514
|
const messages = toOpenAIMessages2(input);
|
|
435
515
|
const toolChoice = mapOpenAIToolChoice(input.toolChoice, false);
|
|
516
|
+
const promptText = messages.map((m) => typeof m.content === "string" ? m.content : "").filter(Boolean).join(`
|
|
517
|
+
`);
|
|
436
518
|
const params = {
|
|
437
519
|
model: modelName,
|
|
438
520
|
messages,
|
|
@@ -445,9 +527,10 @@ var HFI_ToolCalling_Stream = async (input, model, signal, emit) => {
|
|
|
445
527
|
params.tools = tools;
|
|
446
528
|
params.tool_choice = toolChoice;
|
|
447
529
|
}
|
|
530
|
+
createEstimatedOutputUsageReporter4(emit).onPrompt(promptText);
|
|
448
531
|
const stream = client.chatCompletionStream(params, { signal });
|
|
449
|
-
await accumulateOpenAIChatStream(stream, emit);
|
|
450
|
-
emit({ type: "finish", data: { text: "", toolCalls: [] } });
|
|
532
|
+
const usage = await accumulateOpenAIChatStream(stream, emit, mapOpenAIChatUsage4, { promptText });
|
|
533
|
+
emit({ type: "finish", data: { text: "", toolCalls: [] }, usage });
|
|
451
534
|
};
|
|
452
535
|
|
|
453
536
|
// src/ai/common/HFI_JobRunFns.ts
|
|
@@ -549,4 +632,4 @@ export {
|
|
|
549
632
|
_setHfInferenceSDKForTesting
|
|
550
633
|
};
|
|
551
634
|
|
|
552
|
-
//# debugId=
|
|
635
|
+
//# debugId=CB0021025AF0809D64756E2164756E21
|