Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
·
efa0b5c
1
Parent(s):
316b7a8
Sync widgets demo
Browse files- packages/tasks/src/tasks/index.ts +58 -0
- packages/widgets/package.json +3 -2
- packages/widgets/pnpm-lock.yaml +80 -23
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetHeader/WidgetHeader.svelte +10 -8
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte +1 -1
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOutputConvo/WidgetOutputConvo.svelte +1 -1
- packages/widgets/src/lib/components/InferenceWidget/stores.ts +22 -1
- packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte +54 -58
- packages/widgets/src/routes/+page.svelte +14 -1
- packages/widgets/tailwind.config.cjs +3 -0
packages/tasks/src/tasks/index.ts
CHANGED
|
@@ -36,6 +36,64 @@ import zeroShotClassification from "./zero-shot-classification/data";
|
|
| 36 |
import zeroShotImageClassification from "./zero-shot-image-classification/data";
|
| 37 |
import zeroShotObjectDetection from "./zero-shot-object-detection/data";
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
import type { ModelLibraryKey } from "../model-libraries";
|
| 40 |
|
| 41 |
/**
|
|
|
|
| 36 |
import zeroShotImageClassification from "./zero-shot-image-classification/data";
|
| 37 |
import zeroShotObjectDetection from "./zero-shot-object-detection/data";
|
| 38 |
|
| 39 |
+
export type * from "./audio-classification/inference";
|
| 40 |
+
export type * from "./automatic-speech-recognition/inference";
|
| 41 |
+
export type * from "./document-question-answering/inference";
|
| 42 |
+
export type * from "./feature-extraction/inference";
|
| 43 |
+
export type * from "./fill-mask/inference";
|
| 44 |
+
export type {
|
| 45 |
+
ImageClassificationInput,
|
| 46 |
+
ImageClassificationOutput,
|
| 47 |
+
ImageClassificationOutputElement,
|
| 48 |
+
ImageClassificationParameters,
|
| 49 |
+
} from "./image-classification/inference";
|
| 50 |
+
export type * from "./image-to-image/inference";
|
| 51 |
+
export type { ImageToTextInput, ImageToTextOutput, ImageToTextParameters } from "./image-to-text/inference";
|
| 52 |
+
export type * from "./image-segmentation/inference";
|
| 53 |
+
export type * from "./object-detection/inference";
|
| 54 |
+
export type * from "./depth-estimation/inference";
|
| 55 |
+
export type * from "./question-answering/inference";
|
| 56 |
+
export type * from "./sentence-similarity/inference";
|
| 57 |
+
export type * from "./summarization/inference";
|
| 58 |
+
export type * from "./table-question-answering/inference";
|
| 59 |
+
export type { TextToImageInput, TextToImageOutput, TextToImageParameters } from "./text-to-image/inference";
|
| 60 |
+
export type { TextToAudioParameters, TextToSpeechInput, TextToSpeechOutput } from "./text-to-speech/inference";
|
| 61 |
+
export type * from "./token-classification/inference";
|
| 62 |
+
export type {
|
| 63 |
+
Text2TextGenerationParameters,
|
| 64 |
+
Text2TextGenerationTruncationStrategy,
|
| 65 |
+
TranslationInput,
|
| 66 |
+
TranslationOutput,
|
| 67 |
+
} from "./translation/inference";
|
| 68 |
+
export type {
|
| 69 |
+
ClassificationOutputTransform,
|
| 70 |
+
TextClassificationInput,
|
| 71 |
+
TextClassificationOutput,
|
| 72 |
+
TextClassificationOutputElement,
|
| 73 |
+
TextClassificationParameters,
|
| 74 |
+
} from "./text-classification/inference";
|
| 75 |
+
export type {
|
| 76 |
+
FinishReason,
|
| 77 |
+
PrefillToken,
|
| 78 |
+
TextGenerationInput,
|
| 79 |
+
TextGenerationOutput,
|
| 80 |
+
TextGenerationOutputDetails,
|
| 81 |
+
TextGenerationParameters,
|
| 82 |
+
TextGenerationSequenceDetails,
|
| 83 |
+
Token,
|
| 84 |
+
} from "./text-generation/inference";
|
| 85 |
+
export type * from "./video-classification/inference";
|
| 86 |
+
export type * from "./visual-question-answering/inference";
|
| 87 |
+
export type * from "./zero-shot-classification/inference";
|
| 88 |
+
export type * from "./zero-shot-image-classification/inference";
|
| 89 |
+
export type {
|
| 90 |
+
BoundingBox,
|
| 91 |
+
ZeroShotObjectDetectionInput,
|
| 92 |
+
ZeroShotObjectDetectionInputData,
|
| 93 |
+
ZeroShotObjectDetectionOutput,
|
| 94 |
+
ZeroShotObjectDetectionOutputElement,
|
| 95 |
+
} from "./zero-shot-object-detection/inference";
|
| 96 |
+
|
| 97 |
import type { ModelLibraryKey } from "../model-libraries";
|
| 98 |
|
| 99 |
/**
|
packages/widgets/package.json
CHANGED
|
@@ -46,7 +46,8 @@
|
|
| 46 |
],
|
| 47 |
"dependencies": {
|
| 48 |
"@huggingface/tasks": "workspace:^",
|
| 49 |
-
"@huggingface/jinja": "workspace:^"
|
|
|
|
| 50 |
},
|
| 51 |
"peerDependencies": {
|
| 52 |
"svelte": "^3.59.2"
|
|
@@ -69,7 +70,7 @@
|
|
| 69 |
"svelte": "^3.59.2",
|
| 70 |
"svelte-check": "^3.6.0",
|
| 71 |
"svelte-preprocess": "^5.1.1",
|
| 72 |
-
"tailwindcss": "^3.
|
| 73 |
"tslib": "^2.4.1",
|
| 74 |
"vite": "^4.5.0",
|
| 75 |
"vite-plugin-dts": "^3.6.4"
|
|
|
|
| 46 |
],
|
| 47 |
"dependencies": {
|
| 48 |
"@huggingface/tasks": "workspace:^",
|
| 49 |
+
"@huggingface/jinja": "workspace:^",
|
| 50 |
+
"@huggingface/inference": "workspace:^"
|
| 51 |
},
|
| 52 |
"peerDependencies": {
|
| 53 |
"svelte": "^3.59.2"
|
|
|
|
| 70 |
"svelte": "^3.59.2",
|
| 71 |
"svelte-check": "^3.6.0",
|
| 72 |
"svelte-preprocess": "^5.1.1",
|
| 73 |
+
"tailwindcss": "^3.4.1",
|
| 74 |
"tslib": "^2.4.1",
|
| 75 |
"vite": "^4.5.0",
|
| 76 |
"vite-plugin-dts": "^3.6.4"
|
packages/widgets/pnpm-lock.yaml
CHANGED
|
@@ -5,6 +5,9 @@ settings:
|
|
| 5 |
excludeLinksFromLockfile: false
|
| 6 |
|
| 7 |
dependencies:
|
|
|
|
|
|
|
|
|
|
| 8 |
'@huggingface/jinja':
|
| 9 |
specifier: workspace:^
|
| 10 |
version: link:../jinja
|
|
@@ -33,13 +36,13 @@ devDependencies:
|
|
| 33 |
version: 1.27.4(svelte@3.59.2)(vite@4.5.0)
|
| 34 |
'@sveltejs/package':
|
| 35 |
specifier: ^2.0.0
|
| 36 |
-
version: 2.0.0(svelte@3.59.2)(typescript@5.
|
| 37 |
'@sveltejs/vite-plugin-svelte':
|
| 38 |
specifier: 2.5.3
|
| 39 |
version: 2.5.3(svelte@3.59.2)(vite@4.5.0)
|
| 40 |
'@tailwindcss/forms':
|
| 41 |
specifier: ^0.5.7
|
| 42 |
-
version: 0.5.7(tailwindcss@3.
|
| 43 |
'@types/node':
|
| 44 |
specifier: '20'
|
| 45 |
version: 20.10.1
|
|
@@ -63,10 +66,10 @@ devDependencies:
|
|
| 63 |
version: 3.6.0(postcss@8.4.31)(svelte@3.59.2)
|
| 64 |
svelte-preprocess:
|
| 65 |
specifier: ^5.1.1
|
| 66 |
-
version: 5.1.1(postcss@8.4.31)(svelte@3.59.2)(typescript@5.
|
| 67 |
tailwindcss:
|
| 68 |
-
specifier: ^3.
|
| 69 |
-
version: 3.
|
| 70 |
tslib:
|
| 71 |
specifier: ^2.4.1
|
| 72 |
version: 2.4.1
|
|
@@ -75,7 +78,7 @@ devDependencies:
|
|
| 75 |
version: 4.5.0(@types/node@20.10.1)
|
| 76 |
vite-plugin-dts:
|
| 77 |
specifier: ^3.6.4
|
| 78 |
-
version: 3.6.4(@types/node@20.10.1)(typescript@5.
|
| 79 |
|
| 80 |
packages:
|
| 81 |
|
|
@@ -633,7 +636,7 @@ packages:
|
|
| 633 |
- supports-color
|
| 634 |
dev: true
|
| 635 |
|
| 636 |
-
/@sveltejs/package@2.0.0(svelte@3.59.2)(typescript@5.
|
| 637 |
resolution: {integrity: sha512-sANz/dJibOHOe83hl8pFWUSypqefdYwPp6SUr0SmJxTNQFB5dDECEqwAwoy28DWCQFYl7DU+C1hKkTXyuKOdug==}
|
| 638 |
engines: {node: ^16.14 || >=18}
|
| 639 |
hasBin: true
|
|
@@ -644,7 +647,7 @@ packages:
|
|
| 644 |
kleur: 4.1.5
|
| 645 |
sade: 1.8.1
|
| 646 |
svelte: 3.59.2
|
| 647 |
-
svelte2tsx: 0.6.25(svelte@3.59.2)(typescript@5.
|
| 648 |
transitivePeerDependencies:
|
| 649 |
- typescript
|
| 650 |
dev: true
|
|
@@ -685,13 +688,13 @@ packages:
|
|
| 685 |
- supports-color
|
| 686 |
dev: true
|
| 687 |
|
| 688 |
-
/@tailwindcss/forms@0.5.7(tailwindcss@3.
|
| 689 |
resolution: {integrity: sha512-QE7X69iQI+ZXwldE+rzasvbJiyV/ju1FGHH0Qn2W3FKbuYtqp8LKcy6iSw79fVUT5/Vvf+0XgLCeYVG+UV6hOw==}
|
| 690 |
peerDependencies:
|
| 691 |
tailwindcss: '>=3.0.0 || >= 3.0.0-alpha.1'
|
| 692 |
dependencies:
|
| 693 |
mini-svg-data-uri: 1.4.4
|
| 694 |
-
tailwindcss: 3.
|
| 695 |
dev: true
|
| 696 |
|
| 697 |
/@types/argparse@1.0.38:
|
|
@@ -755,7 +758,7 @@ packages:
|
|
| 755 |
'@vue/shared': 3.3.9
|
| 756 |
dev: true
|
| 757 |
|
| 758 |
-
/@vue/language-core@1.8.24(typescript@5.
|
| 759 |
resolution: {integrity: sha512-2ClHvij0WlsDWryPzXJCSpPc6rusZFNoVtRZGgGGkKCmKuIREDDKmH8j+1tYyxPYyH0qL6pZ6+IHD8KIm5nWAw==}
|
| 760 |
peerDependencies:
|
| 761 |
typescript: '*'
|
|
@@ -771,7 +774,7 @@ packages:
|
|
| 771 |
minimatch: 9.0.3
|
| 772 |
muggle-string: 0.3.1
|
| 773 |
path-browserify: 1.0.1
|
| 774 |
-
typescript: 5.
|
| 775 |
vue-template-compiler: 2.7.15
|
| 776 |
dev: true
|
| 777 |
|
|
@@ -2252,7 +2255,55 @@ packages:
|
|
| 2252 |
typescript: 5.0.4
|
| 2253 |
dev: true
|
| 2254 |
|
| 2255 |
-
/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2256 |
resolution: {integrity: sha512-hhBKL5X9gGvKQAZ9xLoHnbE9Yb00HxEZJlxcj2drxWK+Tpqcs/bnodjSfCGbqEhvNaUXYNbVL7s4dEXT+o0f6w==}
|
| 2257 |
peerDependencies:
|
| 2258 |
svelte: ^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0
|
|
@@ -2261,7 +2312,7 @@ packages:
|
|
| 2261 |
dedent-js: 1.0.1
|
| 2262 |
pascal-case: 3.1.2
|
| 2263 |
svelte: 3.59.2
|
| 2264 |
-
typescript: 5.
|
| 2265 |
dev: true
|
| 2266 |
|
| 2267 |
/svelte@3.59.2:
|
|
@@ -2269,8 +2320,8 @@ packages:
|
|
| 2269 |
engines: {node: '>= 8'}
|
| 2270 |
dev: true
|
| 2271 |
|
| 2272 |
-
/tailwindcss@3.
|
| 2273 |
-
resolution: {integrity: sha512-
|
| 2274 |
engines: {node: '>=14.0.0'}
|
| 2275 |
hasBin: true
|
| 2276 |
dependencies:
|
|
@@ -2367,6 +2418,12 @@ packages:
|
|
| 2367 |
hasBin: true
|
| 2368 |
dev: true
|
| 2369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2370 |
/undici-types@5.26.5:
|
| 2371 |
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
| 2372 |
dev: true
|
|
@@ -2409,7 +2466,7 @@ packages:
|
|
| 2409 |
engines: {node: '>= 0.10'}
|
| 2410 |
dev: true
|
| 2411 |
|
| 2412 |
-
/vite-plugin-dts@3.6.4(@types/node@20.10.1)(typescript@5.
|
| 2413 |
resolution: {integrity: sha512-yOVhUI/kQhtS6lCXRYYLv2UUf9bftcwQK9ROxCX2ul17poLQs02ctWX7+vXB8GPRzH8VCK3jebEFtPqqijXx6w==}
|
| 2414 |
engines: {node: ^14.18.0 || >=16.0.0}
|
| 2415 |
peerDependencies:
|
|
@@ -2421,12 +2478,12 @@ packages:
|
|
| 2421 |
dependencies:
|
| 2422 |
'@microsoft/api-extractor': 7.38.3(@types/node@20.10.1)
|
| 2423 |
'@rollup/pluginutils': 5.0.5(rollup@3.29.4)
|
| 2424 |
-
'@vue/language-core': 1.8.24(typescript@5.
|
| 2425 |
debug: 4.3.4
|
| 2426 |
kolorist: 1.8.0
|
| 2427 |
-
typescript: 5.
|
| 2428 |
vite: 4.5.0(@types/node@20.10.1)
|
| 2429 |
-
vue-tsc: 1.8.24(typescript@5.
|
| 2430 |
transitivePeerDependencies:
|
| 2431 |
- '@types/node'
|
| 2432 |
- rollup
|
|
@@ -2487,16 +2544,16 @@ packages:
|
|
| 2487 |
he: 1.2.0
|
| 2488 |
dev: true
|
| 2489 |
|
| 2490 |
-
/vue-tsc@1.8.24(typescript@5.
|
| 2491 |
resolution: {integrity: sha512-eH1CSj231OzVEY5Hi7wS6ubzyOEwgr5jCptR0Ddf2SitGcaXIsPVDvrprm3eolCdyhDt3WS1Eb2F4fGX9BsUUw==}
|
| 2492 |
hasBin: true
|
| 2493 |
peerDependencies:
|
| 2494 |
typescript: '*'
|
| 2495 |
dependencies:
|
| 2496 |
'@volar/typescript': 1.11.1
|
| 2497 |
-
'@vue/language-core': 1.8.24(typescript@5.
|
| 2498 |
semver: 7.5.4
|
| 2499 |
-
typescript: 5.
|
| 2500 |
dev: true
|
| 2501 |
|
| 2502 |
/which@2.0.2:
|
|
|
|
| 5 |
excludeLinksFromLockfile: false
|
| 6 |
|
| 7 |
dependencies:
|
| 8 |
+
'@huggingface/inference':
|
| 9 |
+
specifier: workspace:^
|
| 10 |
+
version: link:../inference
|
| 11 |
'@huggingface/jinja':
|
| 12 |
specifier: workspace:^
|
| 13 |
version: link:../jinja
|
|
|
|
| 36 |
version: 1.27.4(svelte@3.59.2)(vite@4.5.0)
|
| 37 |
'@sveltejs/package':
|
| 38 |
specifier: ^2.0.0
|
| 39 |
+
version: 2.0.0(svelte@3.59.2)(typescript@5.3.3)
|
| 40 |
'@sveltejs/vite-plugin-svelte':
|
| 41 |
specifier: 2.5.3
|
| 42 |
version: 2.5.3(svelte@3.59.2)(vite@4.5.0)
|
| 43 |
'@tailwindcss/forms':
|
| 44 |
specifier: ^0.5.7
|
| 45 |
+
version: 0.5.7(tailwindcss@3.4.1)
|
| 46 |
'@types/node':
|
| 47 |
specifier: '20'
|
| 48 |
version: 20.10.1
|
|
|
|
| 66 |
version: 3.6.0(postcss@8.4.31)(svelte@3.59.2)
|
| 67 |
svelte-preprocess:
|
| 68 |
specifier: ^5.1.1
|
| 69 |
+
version: 5.1.1(postcss@8.4.31)(svelte@3.59.2)(typescript@5.3.3)
|
| 70 |
tailwindcss:
|
| 71 |
+
specifier: ^3.4.1
|
| 72 |
+
version: 3.4.1
|
| 73 |
tslib:
|
| 74 |
specifier: ^2.4.1
|
| 75 |
version: 2.4.1
|
|
|
|
| 78 |
version: 4.5.0(@types/node@20.10.1)
|
| 79 |
vite-plugin-dts:
|
| 80 |
specifier: ^3.6.4
|
| 81 |
+
version: 3.6.4(@types/node@20.10.1)(typescript@5.3.3)(vite@4.5.0)
|
| 82 |
|
| 83 |
packages:
|
| 84 |
|
|
|
|
| 636 |
- supports-color
|
| 637 |
dev: true
|
| 638 |
|
| 639 |
+
/@sveltejs/package@2.0.0(svelte@3.59.2)(typescript@5.3.3):
|
| 640 |
resolution: {integrity: sha512-sANz/dJibOHOe83hl8pFWUSypqefdYwPp6SUr0SmJxTNQFB5dDECEqwAwoy28DWCQFYl7DU+C1hKkTXyuKOdug==}
|
| 641 |
engines: {node: ^16.14 || >=18}
|
| 642 |
hasBin: true
|
|
|
|
| 647 |
kleur: 4.1.5
|
| 648 |
sade: 1.8.1
|
| 649 |
svelte: 3.59.2
|
| 650 |
+
svelte2tsx: 0.6.25(svelte@3.59.2)(typescript@5.3.3)
|
| 651 |
transitivePeerDependencies:
|
| 652 |
- typescript
|
| 653 |
dev: true
|
|
|
|
| 688 |
- supports-color
|
| 689 |
dev: true
|
| 690 |
|
| 691 |
+
/@tailwindcss/forms@0.5.7(tailwindcss@3.4.1):
|
| 692 |
resolution: {integrity: sha512-QE7X69iQI+ZXwldE+rzasvbJiyV/ju1FGHH0Qn2W3FKbuYtqp8LKcy6iSw79fVUT5/Vvf+0XgLCeYVG+UV6hOw==}
|
| 693 |
peerDependencies:
|
| 694 |
tailwindcss: '>=3.0.0 || >= 3.0.0-alpha.1'
|
| 695 |
dependencies:
|
| 696 |
mini-svg-data-uri: 1.4.4
|
| 697 |
+
tailwindcss: 3.4.1
|
| 698 |
dev: true
|
| 699 |
|
| 700 |
/@types/argparse@1.0.38:
|
|
|
|
| 758 |
'@vue/shared': 3.3.9
|
| 759 |
dev: true
|
| 760 |
|
| 761 |
+
/@vue/language-core@1.8.24(typescript@5.3.3):
|
| 762 |
resolution: {integrity: sha512-2ClHvij0WlsDWryPzXJCSpPc6rusZFNoVtRZGgGGkKCmKuIREDDKmH8j+1tYyxPYyH0qL6pZ6+IHD8KIm5nWAw==}
|
| 763 |
peerDependencies:
|
| 764 |
typescript: '*'
|
|
|
|
| 774 |
minimatch: 9.0.3
|
| 775 |
muggle-string: 0.3.1
|
| 776 |
path-browserify: 1.0.1
|
| 777 |
+
typescript: 5.3.3
|
| 778 |
vue-template-compiler: 2.7.15
|
| 779 |
dev: true
|
| 780 |
|
|
|
|
| 2255 |
typescript: 5.0.4
|
| 2256 |
dev: true
|
| 2257 |
|
| 2258 |
+
/svelte-preprocess@5.1.1(postcss@8.4.31)(svelte@3.59.2)(typescript@5.3.3):
|
| 2259 |
+
resolution: {integrity: sha512-p/Dp4hmrBW5mrCCq29lEMFpIJT2FZsRlouxEc5qpbOmXRbaFs7clLs8oKPwD3xCFyZfv1bIhvOzpQkhMEVQdMw==}
|
| 2260 |
+
engines: {node: '>= 14.10.0'}
|
| 2261 |
+
requiresBuild: true
|
| 2262 |
+
peerDependencies:
|
| 2263 |
+
'@babel/core': ^7.10.2
|
| 2264 |
+
coffeescript: ^2.5.1
|
| 2265 |
+
less: ^3.11.3 || ^4.0.0
|
| 2266 |
+
postcss: ^7 || ^8
|
| 2267 |
+
postcss-load-config: ^2.1.0 || ^3.0.0 || ^4.0.0
|
| 2268 |
+
pug: ^3.0.0
|
| 2269 |
+
sass: ^1.26.8
|
| 2270 |
+
stylus: ^0.55.0
|
| 2271 |
+
sugarss: ^2.0.0 || ^3.0.0 || ^4.0.0
|
| 2272 |
+
svelte: ^3.23.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0
|
| 2273 |
+
typescript: '>=3.9.5 || ^4.0.0 || ^5.0.0'
|
| 2274 |
+
peerDependenciesMeta:
|
| 2275 |
+
'@babel/core':
|
| 2276 |
+
optional: true
|
| 2277 |
+
coffeescript:
|
| 2278 |
+
optional: true
|
| 2279 |
+
less:
|
| 2280 |
+
optional: true
|
| 2281 |
+
postcss:
|
| 2282 |
+
optional: true
|
| 2283 |
+
postcss-load-config:
|
| 2284 |
+
optional: true
|
| 2285 |
+
pug:
|
| 2286 |
+
optional: true
|
| 2287 |
+
sass:
|
| 2288 |
+
optional: true
|
| 2289 |
+
stylus:
|
| 2290 |
+
optional: true
|
| 2291 |
+
sugarss:
|
| 2292 |
+
optional: true
|
| 2293 |
+
typescript:
|
| 2294 |
+
optional: true
|
| 2295 |
+
dependencies:
|
| 2296 |
+
'@types/pug': 2.0.9
|
| 2297 |
+
detect-indent: 6.1.0
|
| 2298 |
+
magic-string: 0.27.0
|
| 2299 |
+
postcss: 8.4.31
|
| 2300 |
+
sorcery: 0.11.0
|
| 2301 |
+
strip-indent: 3.0.0
|
| 2302 |
+
svelte: 3.59.2
|
| 2303 |
+
typescript: 5.3.3
|
| 2304 |
+
dev: true
|
| 2305 |
+
|
| 2306 |
+
/svelte2tsx@0.6.25(svelte@3.59.2)(typescript@5.3.3):
|
| 2307 |
resolution: {integrity: sha512-hhBKL5X9gGvKQAZ9xLoHnbE9Yb00HxEZJlxcj2drxWK+Tpqcs/bnodjSfCGbqEhvNaUXYNbVL7s4dEXT+o0f6w==}
|
| 2308 |
peerDependencies:
|
| 2309 |
svelte: ^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0
|
|
|
|
| 2312 |
dedent-js: 1.0.1
|
| 2313 |
pascal-case: 3.1.2
|
| 2314 |
svelte: 3.59.2
|
| 2315 |
+
typescript: 5.3.3
|
| 2316 |
dev: true
|
| 2317 |
|
| 2318 |
/svelte@3.59.2:
|
|
|
|
| 2320 |
engines: {node: '>= 8'}
|
| 2321 |
dev: true
|
| 2322 |
|
| 2323 |
+
/tailwindcss@3.4.1:
|
| 2324 |
+
resolution: {integrity: sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==}
|
| 2325 |
engines: {node: '>=14.0.0'}
|
| 2326 |
hasBin: true
|
| 2327 |
dependencies:
|
|
|
|
| 2418 |
hasBin: true
|
| 2419 |
dev: true
|
| 2420 |
|
| 2421 |
+
/typescript@5.3.3:
|
| 2422 |
+
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
|
| 2423 |
+
engines: {node: '>=14.17'}
|
| 2424 |
+
hasBin: true
|
| 2425 |
+
dev: true
|
| 2426 |
+
|
| 2427 |
/undici-types@5.26.5:
|
| 2428 |
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
| 2429 |
dev: true
|
|
|
|
| 2466 |
engines: {node: '>= 0.10'}
|
| 2467 |
dev: true
|
| 2468 |
|
| 2469 |
+
/vite-plugin-dts@3.6.4(@types/node@20.10.1)(typescript@5.3.3)(vite@4.5.0):
|
| 2470 |
resolution: {integrity: sha512-yOVhUI/kQhtS6lCXRYYLv2UUf9bftcwQK9ROxCX2ul17poLQs02ctWX7+vXB8GPRzH8VCK3jebEFtPqqijXx6w==}
|
| 2471 |
engines: {node: ^14.18.0 || >=16.0.0}
|
| 2472 |
peerDependencies:
|
|
|
|
| 2478 |
dependencies:
|
| 2479 |
'@microsoft/api-extractor': 7.38.3(@types/node@20.10.1)
|
| 2480 |
'@rollup/pluginutils': 5.0.5(rollup@3.29.4)
|
| 2481 |
+
'@vue/language-core': 1.8.24(typescript@5.3.3)
|
| 2482 |
debug: 4.3.4
|
| 2483 |
kolorist: 1.8.0
|
| 2484 |
+
typescript: 5.3.3
|
| 2485 |
vite: 4.5.0(@types/node@20.10.1)
|
| 2486 |
+
vue-tsc: 1.8.24(typescript@5.3.3)
|
| 2487 |
transitivePeerDependencies:
|
| 2488 |
- '@types/node'
|
| 2489 |
- rollup
|
|
|
|
| 2544 |
he: 1.2.0
|
| 2545 |
dev: true
|
| 2546 |
|
| 2547 |
+
/vue-tsc@1.8.24(typescript@5.3.3):
|
| 2548 |
resolution: {integrity: sha512-eH1CSj231OzVEY5Hi7wS6ubzyOEwgr5jCptR0Ddf2SitGcaXIsPVDvrprm3eolCdyhDt3WS1Eb2F4fGX9BsUUw==}
|
| 2549 |
hasBin: true
|
| 2550 |
peerDependencies:
|
| 2551 |
typescript: '*'
|
| 2552 |
dependencies:
|
| 2553 |
'@volar/typescript': 1.11.1
|
| 2554 |
+
'@vue/language-core': 1.8.24(typescript@5.3.3)
|
| 2555 |
semver: 7.5.4
|
| 2556 |
+
typescript: 5.3.3
|
| 2557 |
dev: true
|
| 2558 |
|
| 2559 |
/which@2.0.2:
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetHeader/WidgetHeader.svelte
CHANGED
|
@@ -66,15 +66,17 @@
|
|
| 66 |
</div>
|
| 67 |
<div class="mb-0.5 flex w-full max-w-full flex-wrap items-center justify-between text-sm text-gray-500">
|
| 68 |
{#if pipeline && task}
|
| 69 |
-
<
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
| 77 |
{/if}
|
|
|
|
| 78 |
{#if validExamples.length && applyWidgetExample}
|
| 79 |
<WidgetExamples {validExamples} {isLoading} {applyWidgetExample} {callApiOnMount} {exampleQueryParams} />
|
| 80 |
{/if}
|
|
|
|
| 66 |
</div>
|
| 67 |
<div class="mb-0.5 flex w-full max-w-full flex-wrap items-center justify-between text-sm text-gray-500">
|
| 68 |
{#if pipeline && task}
|
| 69 |
+
<div class="flex gap-4 items-center mb-1.5">
|
| 70 |
+
<a
|
| 71 |
+
href={TASKS_DATA[task] ? `/tasks/${task}` : undefined}
|
| 72 |
+
target="_blank"
|
| 73 |
+
title={TASKS_DATA[task] ? `Learn more about ${task}` : undefined}
|
| 74 |
+
>
|
| 75 |
+
<PipelineTag {pipeline} classNames={TASKS_DATA[task] ? "hover:underline" : ""} />
|
| 76 |
+
</a>
|
| 77 |
+
</div>
|
| 78 |
{/if}
|
| 79 |
+
|
| 80 |
{#if validExamples.length && applyWidgetExample}
|
| 81 |
<WidgetExamples {validExamples} {isLoading} {applyWidgetExample} {callApiOnMount} {exampleQueryParams} />
|
| 82 |
{/if}
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
</script>
|
| 5 |
|
| 6 |
<div
|
| 7 |
-
class="rounded-2xl px-3 py-2 {position === 'right'
|
| 8 |
? 'ml-7 bg-blue-600 text-white'
|
| 9 |
: 'mr-7 place-self-start bg-gray-50 dark:bg-gray-850 dark:text-gray-200'}"
|
| 10 |
>
|
|
|
|
| 4 |
</script>
|
| 5 |
|
| 6 |
<div
|
| 7 |
+
class="rounded-2xl px-3 py-2 text-smd {position === 'right'
|
| 8 |
? 'ml-7 bg-blue-600 text-white'
|
| 9 |
: 'mr-7 place-self-start bg-gray-50 dark:bg-gray-850 dark:text-gray-200'}"
|
| 10 |
>
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetOutputConvo/WidgetOutputConvo.svelte
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
</script>
|
| 19 |
|
| 20 |
<div bind:this={wrapperEl} class="h-64 overflow-y-auto rounded-t-lg border border-b-0 leading-tight">
|
| 21 |
-
<div class="p-3 pt-6 text-center text-sm text-gray-400">
|
| 22 |
Input a message to start chatting with
|
| 23 |
<strong>{modelId}</strong>.
|
| 24 |
</div>
|
|
|
|
| 18 |
</script>
|
| 19 |
|
| 20 |
<div bind:this={wrapperEl} class="h-64 overflow-y-auto rounded-t-lg border border-b-0 leading-tight">
|
| 21 |
+
<div class="p-3 pt-6 text-center text-sm text-gray-400 text-balance">
|
| 22 |
Input a message to start chatting with
|
| 23 |
<strong>{modelId}</strong>.
|
| 24 |
</div>
|
packages/widgets/src/lib/components/InferenceWidget/stores.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { writable } from "svelte/store";
|
| 2 |
import type { ModelData } from "@huggingface/tasks";
|
| 3 |
import type { ModelLoadInfo, WidgetState } from "./shared/types.js";
|
| 4 |
|
|
@@ -8,6 +8,27 @@ export const widgetNoInference = writable<Record<ModelData["id"], boolean>>({});
|
|
| 8 |
|
| 9 |
export const widgetStates = writable<Record<ModelData["id"], WidgetState>>({});
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
export function updateWidgetState(modelId: ModelData["id"], key: keyof WidgetState, val: boolean): void {
|
| 12 |
widgetStates.update((states) => {
|
| 13 |
// Check if the modelId exists, if not initialize it
|
|
|
|
| 1 |
+
import { get, writable } from "svelte/store";
|
| 2 |
import type { ModelData } from "@huggingface/tasks";
|
| 3 |
import type { ModelLoadInfo, WidgetState } from "./shared/types.js";
|
| 4 |
|
|
|
|
| 8 |
|
| 9 |
export const widgetStates = writable<Record<ModelData["id"], WidgetState>>({});
|
| 10 |
|
| 11 |
+
const tgiSupportedModels = writable<Set<string> | undefined>(undefined);
|
| 12 |
+
|
| 13 |
+
export async function getTgiSupportedModels(url: string): Promise<typeof tgiSupportedModels> {
|
| 14 |
+
if (!get(tgiSupportedModels)) {
|
| 15 |
+
const response = await fetch(`${url}/framework/text-generation-inference`);
|
| 16 |
+
const output = await response.json();
|
| 17 |
+
if (response.ok) {
|
| 18 |
+
tgiSupportedModels.set(
|
| 19 |
+
new Set(
|
| 20 |
+
(output as { model_id: string; task: string }[])
|
| 21 |
+
.filter(({ task }) => task === "text-generation")
|
| 22 |
+
.map(({ model_id }) => model_id)
|
| 23 |
+
)
|
| 24 |
+
);
|
| 25 |
+
} else {
|
| 26 |
+
console.warn(response.status, output.error);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
return tgiSupportedModels;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
export function updateWidgetState(modelId: ModelData["id"], key: keyof WidgetState, val: boolean): void {
|
| 33 |
widgetStates.update((states) => {
|
| 34 |
// Check if the modelId exists, if not initialize it
|
packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte
CHANGED
|
@@ -2,15 +2,23 @@
|
|
| 2 |
import { onMount } from "svelte";
|
| 3 |
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types.js";
|
| 4 |
import { Template } from "@huggingface/jinja";
|
| 5 |
-
import type {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
|
|
|
|
|
|
|
| 7 |
import type { ConversationMessage } from "../../shared/types.js";
|
| 8 |
import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
|
| 9 |
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
|
| 10 |
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
|
| 11 |
import { addInferenceParameters, callInferenceApi, updateUrl } from "../../shared/helpers.js";
|
| 12 |
import { isTextInput } from "../../shared/inputValidation.js";
|
| 13 |
-
import { widgetStates } from "../../stores.js";
|
|
|
|
| 14 |
|
| 15 |
export let apiToken: WidgetProps["apiToken"];
|
| 16 |
export let apiUrl: WidgetProps["apiUrl"];
|
|
@@ -20,24 +28,23 @@
|
|
| 20 |
export let shouldUpdateUrl: WidgetProps["shouldUpdateUrl"];
|
| 21 |
export let includeCredentials: WidgetProps["includeCredentials"];
|
| 22 |
|
|
|
|
|
|
|
| 23 |
$: isDisabled = $widgetStates?.[model.id]?.isDisabled;
|
| 24 |
|
| 25 |
-
let computeTime = "";
|
| 26 |
let messages: ConversationMessage[] = [];
|
| 27 |
let error: string = "";
|
| 28 |
let isLoading = false;
|
| 29 |
-
let modelLoading = {
|
| 30 |
-
isLoading: false,
|
| 31 |
-
estimatedTime: 0,
|
| 32 |
-
};
|
| 33 |
let outputJson: string;
|
| 34 |
let text = "";
|
| 35 |
|
| 36 |
let compiledTemplate: Template;
|
| 37 |
let tokenizerConfig: TokenizerConfig;
|
|
|
|
| 38 |
|
| 39 |
// Check config and compile template
|
| 40 |
onMount(() => {
|
|
|
|
| 41 |
const config = model.config;
|
| 42 |
if (config === undefined) {
|
| 43 |
error = "Model config not found";
|
|
@@ -61,6 +68,8 @@
|
|
| 61 |
error = `Invalid chat template: "${(e as Error).message}"`;
|
| 62 |
return;
|
| 63 |
}
|
|
|
|
|
|
|
| 64 |
});
|
| 65 |
|
| 66 |
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
|
|
@@ -68,6 +77,11 @@
|
|
| 68 |
return;
|
| 69 |
}
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
const trimmedText = text.trim();
|
| 72 |
if (!trimmedText) {
|
| 73 |
return;
|
|
@@ -97,65 +111,47 @@
|
|
| 97 |
return;
|
| 98 |
}
|
| 99 |
|
| 100 |
-
const
|
| 101 |
inputs: chatText,
|
| 102 |
parameters: {
|
| 103 |
return_full_text: false,
|
| 104 |
-
max_new_tokens: 100,
|
| 105 |
},
|
| 106 |
};
|
| 107 |
-
addInferenceParameters(
|
| 108 |
|
| 109 |
isLoading = true;
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
} else if (res.status === "loading-model") {
|
| 138 |
-
modelLoading = {
|
| 139 |
-
isLoading: true,
|
| 140 |
-
estimatedTime: res.estimatedTime,
|
| 141 |
-
};
|
| 142 |
-
getOutput({ withModelLoading: true });
|
| 143 |
-
} else if (res.status === "error") {
|
| 144 |
-
error = res.error;
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
function parseOutput(body: unknown, chat: ConversationMessage[]): ConversationMessage[] {
|
| 149 |
-
if (Array.isArray(body) && body.length) {
|
| 150 |
-
const text = body[0]?.generated_text ?? "";
|
| 151 |
-
|
| 152 |
-
if (!text.length) {
|
| 153 |
-
throw new Error("Model did not generate a response.");
|
| 154 |
}
|
| 155 |
-
|
| 156 |
-
|
| 157 |
}
|
| 158 |
-
|
| 159 |
}
|
| 160 |
|
| 161 |
function extractSpecialTokensMap(tokenizerConfig: TokenizerConfig): SpecialTokensMap {
|
|
@@ -202,7 +198,7 @@
|
|
| 202 |
submitButtonLabel="Send"
|
| 203 |
/>
|
| 204 |
|
| 205 |
-
<WidgetInfo {model} {
|
| 206 |
|
| 207 |
<WidgetFooter {model} {isDisabled} {outputJson} />
|
| 208 |
</WidgetWrapper>
|
|
|
|
| 2 |
import { onMount } from "svelte";
|
| 3 |
import type { WidgetProps, ExampleRunOpts, InferenceRunOpts } from "../../shared/types.js";
|
| 4 |
import { Template } from "@huggingface/jinja";
|
| 5 |
+
import type {
|
| 6 |
+
SpecialTokensMap,
|
| 7 |
+
TokenizerConfig,
|
| 8 |
+
WidgetExampleTextInput,
|
| 9 |
+
TextGenerationInput,
|
| 10 |
+
} from "@huggingface/tasks";
|
| 11 |
import { SPECIAL_TOKENS_ATTRIBUTES } from "@huggingface/tasks";
|
| 12 |
+
import { HfInference } from "@huggingface/inference";
|
| 13 |
+
|
| 14 |
import type { ConversationMessage } from "../../shared/types.js";
|
| 15 |
import WidgetOutputConvo from "../../shared/WidgetOutputConvo/WidgetOutputConvo.svelte";
|
| 16 |
import WidgetQuickInput from "../../shared/WidgetQuickInput/WidgetQuickInput.svelte";
|
| 17 |
import WidgetWrapper from "../../shared/WidgetWrapper/WidgetWrapper.svelte";
|
| 18 |
import { addInferenceParameters, callInferenceApi, updateUrl } from "../../shared/helpers.js";
|
| 19 |
import { isTextInput } from "../../shared/inputValidation.js";
|
| 20 |
+
import { widgetStates, getTgiSupportedModels } from "../../stores.js";
|
| 21 |
+
import type { Writable } from "svelte/store";
|
| 22 |
|
| 23 |
export let apiToken: WidgetProps["apiToken"];
|
| 24 |
export let apiUrl: WidgetProps["apiUrl"];
|
|
|
|
| 28 |
export let shouldUpdateUrl: WidgetProps["shouldUpdateUrl"];
|
| 29 |
export let includeCredentials: WidgetProps["includeCredentials"];
|
| 30 |
|
| 31 |
+
let tgiSupportedModels: Writable<Set<string> | undefined>;
|
| 32 |
+
|
| 33 |
$: isDisabled = $widgetStates?.[model.id]?.isDisabled;
|
| 34 |
|
|
|
|
| 35 |
let messages: ConversationMessage[] = [];
|
| 36 |
let error: string = "";
|
| 37 |
let isLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
let outputJson: string;
|
| 39 |
let text = "";
|
| 40 |
|
| 41 |
let compiledTemplate: Template;
|
| 42 |
let tokenizerConfig: TokenizerConfig;
|
| 43 |
+
let inferenceClient: HfInference | undefined = undefined;
|
| 44 |
|
| 45 |
// Check config and compile template
|
| 46 |
onMount(() => {
|
| 47 |
+
getTgiSupportedModels(apiUrl).then((store) => (tgiSupportedModels = store));
|
| 48 |
const config = model.config;
|
| 49 |
if (config === undefined) {
|
| 50 |
error = "Model config not found";
|
|
|
|
| 68 |
error = `Invalid chat template: "${(e as Error).message}"`;
|
| 69 |
return;
|
| 70 |
}
|
| 71 |
+
|
| 72 |
+
inferenceClient = new HfInference();
|
| 73 |
});
|
| 74 |
|
| 75 |
async function getOutput({ withModelLoading = false, isOnLoadCall = false }: InferenceRunOpts = {}) {
|
|
|
|
| 77 |
return;
|
| 78 |
}
|
| 79 |
|
| 80 |
+
if (!inferenceClient) {
|
| 81 |
+
error = "Inference client not ready";
|
| 82 |
+
return;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
const trimmedText = text.trim();
|
| 86 |
if (!trimmedText) {
|
| 87 |
return;
|
|
|
|
| 111 |
return;
|
| 112 |
}
|
| 113 |
|
| 114 |
+
const input: TextGenerationInput & Required<Pick<TextGenerationInput, "parameters">> = {
|
| 115 |
inputs: chatText,
|
| 116 |
parameters: {
|
| 117 |
return_full_text: false,
|
|
|
|
| 118 |
},
|
| 119 |
};
|
| 120 |
+
addInferenceParameters(input, model);
|
| 121 |
|
| 122 |
isLoading = true;
|
| 123 |
+
text = "";
|
| 124 |
+
try {
|
| 125 |
+
if ($tgiSupportedModels?.has(model.id)) {
|
| 126 |
+
console.debug("Starting text generation using the TGI streaming API");
|
| 127 |
+
let newMessage = {
|
| 128 |
+
role: "assistant",
|
| 129 |
+
content: "",
|
| 130 |
+
} satisfies ConversationMessage;
|
| 131 |
+
const previousMessages = [...messages];
|
| 132 |
+
const tokenStream = inferenceClient.textGenerationStream({
|
| 133 |
+
...input,
|
| 134 |
+
model: model.id,
|
| 135 |
+
accessToken: apiToken,
|
| 136 |
+
});
|
| 137 |
+
for await (const newToken of tokenStream) {
|
| 138 |
+
if (newToken.token.special) continue;
|
| 139 |
+
newMessage.content = newMessage.content + newToken.token.text;
|
| 140 |
+
messages = [...previousMessages, newMessage];
|
| 141 |
+
}
|
| 142 |
+
} else {
|
| 143 |
+
console.debug("Starting text generation using the synchronous API");
|
| 144 |
+
input.parameters.max_new_tokens = 100;
|
| 145 |
+
const output = await inferenceClient.textGeneration(
|
| 146 |
+
{ ...input, model: model.id, accessToken: apiToken },
|
| 147 |
+
{ includeCredentials, dont_load_model: !withModelLoading }
|
| 148 |
+
);
|
| 149 |
+
messages = [...messages, { role: "assistant", content: output.generated_text }];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
+
} catch (e) {
|
| 152 |
+
error = `Something went wrong while requesting the Inference API: "${(e as Error).message}"`;
|
| 153 |
}
|
| 154 |
+
isLoading = false;
|
| 155 |
}
|
| 156 |
|
| 157 |
function extractSpecialTokensMap(tokenizerConfig: TokenizerConfig): SpecialTokensMap {
|
|
|
|
| 198 |
submitButtonLabel="Send"
|
| 199 |
/>
|
| 200 |
|
| 201 |
+
<WidgetInfo {model} {error} />
|
| 202 |
|
| 203 |
<WidgetFooter {model} {isDisabled} {outputJson} />
|
| 204 |
</WidgetWrapper>
|
packages/widgets/src/routes/+page.svelte
CHANGED
|
@@ -48,9 +48,22 @@
|
|
| 48 |
},
|
| 49 |
},
|
| 50 |
{
|
| 51 |
-
id: "
|
| 52 |
pipeline_tag: "text-generation",
|
| 53 |
inference: InferenceDisplayability.Yes,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
},
|
| 55 |
{
|
| 56 |
id: "openai/clip-vit-base-patch16",
|
|
|
|
| 48 |
},
|
| 49 |
},
|
| 50 |
{
|
| 51 |
+
id: "microsoft/phi-2",
|
| 52 |
pipeline_tag: "text-generation",
|
| 53 |
inference: InferenceDisplayability.Yes,
|
| 54 |
+
config: {
|
| 55 |
+
architectures: ["PhiForCausalLM"],
|
| 56 |
+
model_type: "phi",
|
| 57 |
+
auto_map: {
|
| 58 |
+
AutoConfig: "configuration_phi.PhiConfig",
|
| 59 |
+
AutoModelForCausalLM: "modeling_phi.PhiForCausalLM",
|
| 60 |
+
},
|
| 61 |
+
tokenizer_config: {
|
| 62 |
+
bos_token: "<|endoftext|>",
|
| 63 |
+
eos_token: "<|endoftext|>",
|
| 64 |
+
unk_token: "<|endoftext|>",
|
| 65 |
+
},
|
| 66 |
+
},
|
| 67 |
},
|
| 68 |
{
|
| 69 |
id: "openai/clip-vit-base-patch16",
|
packages/widgets/tailwind.config.cjs
CHANGED
|
@@ -37,6 +37,9 @@ module.exports = {
|
|
| 37 |
sans: ["Source Sans Pro", ...defaultTheme.fontFamily.sans],
|
| 38 |
mono: ["IBM Plex Mono", ...defaultTheme.fontFamily.mono],
|
| 39 |
},
|
|
|
|
|
|
|
|
|
|
| 40 |
},
|
| 41 |
},
|
| 42 |
plugins: [require("@tailwindcss/forms")],
|
|
|
|
| 37 |
sans: ["Source Sans Pro", ...defaultTheme.fontFamily.sans],
|
| 38 |
mono: ["IBM Plex Mono", ...defaultTheme.fontFamily.mono],
|
| 39 |
},
|
| 40 |
+
fontSize: {
|
| 41 |
+
smd: "0.94rem",
|
| 42 |
+
},
|
| 43 |
},
|
| 44 |
},
|
| 45 |
plugins: [require("@tailwindcss/forms")],
|