Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update Dockerfile
#7
by
XciD
HF Staff
- opened
- .npmrc +1 -0
- .prettierrc.mjs +1 -1
- Dockerfile +1 -1
- package.json +1 -1
- pnpm-lock.yaml +11 -6
- src/lib/components/inference-playground/code-snippets.svelte +7 -5
- src/lib/types.ts +1 -0
- src/lib/utils/business.svelte.ts +7 -9
.npmrc
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
engine-strict=true
|
|
|
|
|
|
| 1 |
engine-strict=true
|
| 2 |
+
dedupe-peer-dependents=true
|
.prettierrc.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
export default {
|
| 2 |
arrowParens: "avoid",
|
| 3 |
quoteProps: "consistent",
|
| 4 |
-
trailingComma: "
|
| 5 |
useTabs: true,
|
| 6 |
tabWidth: 2,
|
| 7 |
printWidth: 120,
|
|
|
|
| 1 |
export default {
|
| 2 |
arrowParens: "avoid",
|
| 3 |
quoteProps: "consistent",
|
| 4 |
+
trailingComma: "all",
|
| 5 |
useTabs: true,
|
| 6 |
tabWidth: 2,
|
| 7 |
printWidth: 120,
|
Dockerfile
CHANGED
|
@@ -10,7 +10,7 @@ WORKDIR /app
|
|
| 10 |
COPY package.json pnpm-lock.yaml* ./
|
| 11 |
|
| 12 |
# Install all dependencies, including dev dependencies
|
| 13 |
-
RUN pnpm install --frozen-lockfile
|
| 14 |
|
| 15 |
# Copy the rest of the application code
|
| 16 |
COPY . .
|
|
|
|
| 10 |
COPY package.json pnpm-lock.yaml* ./
|
| 11 |
|
| 12 |
# Install all dependencies, including dev dependencies
|
| 13 |
+
RUN export NODE_OPTIONS=--max_old_space_size=8192 pnpm install --frozen-lockfile
|
| 14 |
|
| 15 |
# Copy the rest of the application code
|
| 16 |
COPY . .
|
package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"@eslint/js": "^9.22.0",
|
| 23 |
"@floating-ui/dom": "^1.6.13",
|
| 24 |
"@huggingface/hub": "^2.1.0",
|
| 25 |
-
"@huggingface/inference": "^
|
| 26 |
"@huggingface/tasks": "^0.19.8",
|
| 27 |
"@huggingface/transformers": "^3.5.1",
|
| 28 |
"@iconify-json/carbon": "^1.2.8",
|
|
|
|
| 22 |
"@eslint/js": "^9.22.0",
|
| 23 |
"@floating-ui/dom": "^1.6.13",
|
| 24 |
"@huggingface/hub": "^2.1.0",
|
| 25 |
+
"@huggingface/inference": "^4.4.0",
|
| 26 |
"@huggingface/tasks": "^0.19.8",
|
| 27 |
"@huggingface/transformers": "^3.5.1",
|
| 28 |
"@iconify-json/carbon": "^1.2.8",
|
pnpm-lock.yaml
CHANGED
|
@@ -34,8 +34,8 @@ importers:
|
|
| 34 |
specifier: ^2.1.0
|
| 35 |
version: 2.1.0
|
| 36 |
'@huggingface/inference':
|
| 37 |
-
specifier: ^
|
| 38 |
-
version:
|
| 39 |
'@huggingface/tasks':
|
| 40 |
specifier: ^0.19.8
|
| 41 |
version: 0.19.8
|
|
@@ -589,8 +589,8 @@ packages:
|
|
| 589 |
engines: {node: '>=18'}
|
| 590 |
hasBin: true
|
| 591 |
|
| 592 |
-
'@huggingface/inference@
|
| 593 |
-
resolution: {integrity: sha512-
|
| 594 |
engines: {node: '>=18'}
|
| 595 |
|
| 596 |
'@huggingface/[email protected]':
|
|
@@ -601,6 +601,9 @@ packages:
|
|
| 601 |
resolution: {integrity: sha512-Ptc03/jGRiYRoi0bUYKZ14MkDslsBRT24oxmsvUlfYrvQMldrxCevhPnT+hfX8awKTT8/f/0ZBBWldoeAcMHdQ==}
|
| 602 |
engines: {node: '>=18'}
|
| 603 |
|
|
|
|
|
|
|
|
|
|
| 604 |
'@huggingface/[email protected]':
|
| 605 |
resolution: {integrity: sha512-gR88OvYQQ2zu1Dt/tfFRVWJRfsKCdssxJBb8bz3tVd9fh3rneNE/pjkaGyG3oT1VlHv7wEmrqrnkmMcXy8O0rg==}
|
| 606 |
|
|
@@ -3545,15 +3548,17 @@ snapshots:
|
|
| 3545 |
dependencies:
|
| 3546 |
'@huggingface/tasks': 0.19.8
|
| 3547 |
|
| 3548 |
-
'@huggingface/inference@
|
| 3549 |
dependencies:
|
| 3550 |
'@huggingface/jinja': 0.5.0
|
| 3551 |
-
'@huggingface/tasks': 0.19.
|
| 3552 |
|
| 3553 |
'@huggingface/[email protected]': {}
|
| 3554 |
|
| 3555 |
'@huggingface/[email protected]': {}
|
| 3556 |
|
|
|
|
|
|
|
| 3557 |
'@huggingface/[email protected]': {}
|
| 3558 |
|
| 3559 |
'@huggingface/[email protected]':
|
|
|
|
| 34 |
specifier: ^2.1.0
|
| 35 |
version: 2.1.0
|
| 36 |
'@huggingface/inference':
|
| 37 |
+
specifier: ^4.4.0
|
| 38 |
+
version: 4.4.0
|
| 39 |
'@huggingface/tasks':
|
| 40 |
specifier: ^0.19.8
|
| 41 |
version: 0.19.8
|
|
|
|
| 589 |
engines: {node: '>=18'}
|
| 590 |
hasBin: true
|
| 591 |
|
| 592 |
+
'@huggingface/inference@4.4.0':
|
| 593 |
+
resolution: {integrity: sha512-YpkegUf1Mnrhkh+Tv47yIsA0+OEP73ODdn8GjMOG7Jf86y6MxO8LNGDVUUreg+Y4VgVq//j9j/tmENa8tYR4Dg==}
|
| 594 |
engines: {node: '>=18'}
|
| 595 |
|
| 596 |
'@huggingface/[email protected]':
|
|
|
|
| 601 |
resolution: {integrity: sha512-Ptc03/jGRiYRoi0bUYKZ14MkDslsBRT24oxmsvUlfYrvQMldrxCevhPnT+hfX8awKTT8/f/0ZBBWldoeAcMHdQ==}
|
| 602 |
engines: {node: '>=18'}
|
| 603 |
|
| 604 |
+
'@huggingface/[email protected]':
|
| 605 |
+
resolution: {integrity: sha512-jtRXsJZTES01X4gJ5VOUnEm3ONyyfXUcWKObbWkr/SQmjaH/kxtWqc2zVWKaxL4QLoXqXJ+T+Pi5xupMStSudQ==}
|
| 606 |
+
|
| 607 |
'@huggingface/[email protected]':
|
| 608 |
resolution: {integrity: sha512-gR88OvYQQ2zu1Dt/tfFRVWJRfsKCdssxJBb8bz3tVd9fh3rneNE/pjkaGyG3oT1VlHv7wEmrqrnkmMcXy8O0rg==}
|
| 609 |
|
|
|
|
| 3548 |
dependencies:
|
| 3549 |
'@huggingface/tasks': 0.19.8
|
| 3550 |
|
| 3551 |
+
'@huggingface/inference@4.4.0':
|
| 3552 |
dependencies:
|
| 3553 |
'@huggingface/jinja': 0.5.0
|
| 3554 |
+
'@huggingface/tasks': 0.19.22
|
| 3555 |
|
| 3556 |
'@huggingface/[email protected]': {}
|
| 3557 |
|
| 3558 |
'@huggingface/[email protected]': {}
|
| 3559 |
|
| 3560 |
+
'@huggingface/[email protected]': {}
|
| 3561 |
+
|
| 3562 |
'@huggingface/[email protected]': {}
|
| 3563 |
|
| 3564 |
'@huggingface/[email protected]':
|
src/lib/components/inference-playground/code-snippets.svelte
CHANGED
|
@@ -82,8 +82,8 @@
|
|
| 82 |
fromEntries(
|
| 83 |
keys(labelsByLanguage).map(lang => {
|
| 84 |
return [lang, 0];
|
| 85 |
-
})
|
| 86 |
-
)
|
| 87 |
);
|
| 88 |
|
| 89 |
type InstallInstructions = {
|
|
@@ -147,7 +147,9 @@
|
|
| 147 |
class="border-b border-gray-200 text-center text-sm font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"
|
| 148 |
>
|
| 149 |
<ul class="-mb-px flex flex-wrap">
|
| 150 |
-
{#each entries(labelsByLanguage)
|
|
|
|
|
|
|
| 151 |
<li>
|
| 152 |
<button
|
| 153 |
onclick={() => (lang = language)}
|
|
@@ -218,7 +220,7 @@
|
|
| 218 |
<pre
|
| 219 |
class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-xs dark:border-gray-800 dark:bg-gray-800/50">{@html highlight(
|
| 220 |
installInstructions.content,
|
| 221 |
-
selectedSnippet?.language
|
| 222 |
)}</pre>
|
| 223 |
{/if}
|
| 224 |
|
|
@@ -253,6 +255,6 @@
|
|
| 253 |
<pre
|
| 254 |
class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-xs dark:border-gray-800 dark:bg-gray-800/50">{@html highlight(
|
| 255 |
selectedSnippet?.content,
|
| 256 |
-
selectedSnippet?.language
|
| 257 |
)}</pre>
|
| 258 |
</div>
|
|
|
|
| 82 |
fromEntries(
|
| 83 |
keys(labelsByLanguage).map(lang => {
|
| 84 |
return [lang, 0];
|
| 85 |
+
}),
|
| 86 |
+
),
|
| 87 |
);
|
| 88 |
|
| 89 |
type InstallInstructions = {
|
|
|
|
| 147 |
class="border-b border-gray-200 text-center text-sm font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"
|
| 148 |
>
|
| 149 |
<ul class="-mb-px flex flex-wrap">
|
| 150 |
+
{#each entries(labelsByLanguage).filter(([lang]) => {
|
| 151 |
+
return snippetsByLang[lang]?.length;
|
| 152 |
+
}) as [language, label]}
|
| 153 |
<li>
|
| 154 |
<button
|
| 155 |
onclick={() => (lang = language)}
|
|
|
|
| 220 |
<pre
|
| 221 |
class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-xs dark:border-gray-800 dark:bg-gray-800/50">{@html highlight(
|
| 222 |
installInstructions.content,
|
| 223 |
+
selectedSnippet?.language,
|
| 224 |
)}</pre>
|
| 225 |
{/if}
|
| 226 |
|
|
|
|
| 255 |
<pre
|
| 256 |
class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-xs dark:border-gray-800 dark:bg-gray-800/50">{@html highlight(
|
| 257 |
selectedSnippet?.content,
|
| 258 |
+
selectedSnippet?.language,
|
| 259 |
)}</pre>
|
| 260 |
</div>
|
src/lib/types.ts
CHANGED
|
@@ -161,6 +161,7 @@ export enum Provider {
|
|
| 161 |
Together = "together",
|
| 162 |
Cohere = "cohere",
|
| 163 |
Groq = "groq",
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
export enum Status {
|
|
|
|
| 161 |
Together = "together",
|
| 162 |
Cohere = "cohere",
|
| 163 |
Groq = "groq",
|
| 164 |
+
Auto = "auto",
|
| 165 |
}
|
| 166 |
|
| 167 |
export enum Status {
|
src/lib/utils/business.svelte.ts
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
| 21 |
} from "$lib/types.js";
|
| 22 |
import { safeParse } from "$lib/utils/json.js";
|
| 23 |
import { omit, tryGet } from "$lib/utils/object.svelte.js";
|
| 24 |
-
import { type InferenceProvider } from "@huggingface/inference";
|
| 25 |
import type { ChatCompletionInputMessage, InferenceSnippet } from "@huggingface/tasks";
|
| 26 |
import { type ChatCompletionOutputMessage } from "@huggingface/tasks";
|
| 27 |
import { AutoTokenizer, PreTrainedTokenizer } from "@huggingface/transformers";
|
|
@@ -120,7 +119,7 @@ function getResponseFormatObj(conversation: ConversationClass | Conversation) {
|
|
| 120 |
|
| 121 |
async function getCompletionMetadata(
|
| 122 |
conversation: ConversationClass | Conversation,
|
| 123 |
-
signal?: AbortSignal
|
| 124 |
): Promise<CompletionMetadata> {
|
| 125 |
const data = conversation instanceof ConversationClass ? conversation.data : conversation;
|
| 126 |
const model = conversation.model;
|
|
@@ -180,7 +179,7 @@ async function getCompletionMetadata(
|
|
| 180 |
export async function handleStreamingResponse(
|
| 181 |
conversation: ConversationClass | Conversation,
|
| 182 |
onChunk: (content: string) => void,
|
| 183 |
-
abortController: AbortController
|
| 184 |
): Promise<void> {
|
| 185 |
const metadata = await getCompletionMetadata(conversation, abortController.signal);
|
| 186 |
|
|
@@ -211,7 +210,7 @@ export async function handleStreamingResponse(
|
|
| 211 |
}
|
| 212 |
|
| 213 |
export async function handleNonStreamingResponse(
|
| 214 |
-
conversation: ConversationClass | Conversation
|
| 215 |
): Promise<{ message: ChatCompletionOutputMessage; completion_tokens: number }> {
|
| 216 |
const metadata = await getCompletionMetadata(conversation);
|
| 217 |
|
|
@@ -325,11 +324,11 @@ export function getInferenceSnippet(
|
|
| 325 |
temperature?: ConversationEntityMembers["config"]["temperature"];
|
| 326 |
top_p?: ConversationEntityMembers["config"]["top_p"];
|
| 327 |
structured_output?: ConversationEntityMembers["structuredOutput"];
|
| 328 |
-
}
|
| 329 |
): GetInferenceSnippetReturn {
|
| 330 |
const model = conversation.model;
|
| 331 |
const data = conversation.data;
|
| 332 |
-
const provider = (isCustomModel(model) ? "hf-inference" : data.provider) as
|
| 333 |
|
| 334 |
// If it's a custom model, we don't generate inference snippets
|
| 335 |
if (isCustomModel(model)) {
|
|
@@ -337,14 +336,13 @@ export function getInferenceSnippet(
|
|
| 337 |
}
|
| 338 |
|
| 339 |
const providerMapping = model.inferenceProviderMapping.find(p => p.provider === provider);
|
| 340 |
-
if (!providerMapping) return [];
|
| 341 |
const allSnippets = snippets.getInferenceSnippets(
|
| 342 |
{ ...model, inference: "" },
|
| 343 |
-
accessToken,
|
| 344 |
provider,
|
| 345 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 346 |
{ ...providerMapping, hfModelId: model.id } as any,
|
| 347 |
-
opts
|
| 348 |
);
|
| 349 |
|
| 350 |
return allSnippets
|
|
|
|
| 21 |
} from "$lib/types.js";
|
| 22 |
import { safeParse } from "$lib/utils/json.js";
|
| 23 |
import { omit, tryGet } from "$lib/utils/object.svelte.js";
|
|
|
|
| 24 |
import type { ChatCompletionInputMessage, InferenceSnippet } from "@huggingface/tasks";
|
| 25 |
import { type ChatCompletionOutputMessage } from "@huggingface/tasks";
|
| 26 |
import { AutoTokenizer, PreTrainedTokenizer } from "@huggingface/transformers";
|
|
|
|
| 119 |
|
| 120 |
async function getCompletionMetadata(
|
| 121 |
conversation: ConversationClass | Conversation,
|
| 122 |
+
signal?: AbortSignal,
|
| 123 |
): Promise<CompletionMetadata> {
|
| 124 |
const data = conversation instanceof ConversationClass ? conversation.data : conversation;
|
| 125 |
const model = conversation.model;
|
|
|
|
| 179 |
export async function handleStreamingResponse(
|
| 180 |
conversation: ConversationClass | Conversation,
|
| 181 |
onChunk: (content: string) => void,
|
| 182 |
+
abortController: AbortController,
|
| 183 |
): Promise<void> {
|
| 184 |
const metadata = await getCompletionMetadata(conversation, abortController.signal);
|
| 185 |
|
|
|
|
| 210 |
}
|
| 211 |
|
| 212 |
export async function handleNonStreamingResponse(
|
| 213 |
+
conversation: ConversationClass | Conversation,
|
| 214 |
): Promise<{ message: ChatCompletionOutputMessage; completion_tokens: number }> {
|
| 215 |
const metadata = await getCompletionMetadata(conversation);
|
| 216 |
|
|
|
|
| 324 |
temperature?: ConversationEntityMembers["config"]["temperature"];
|
| 325 |
top_p?: ConversationEntityMembers["config"]["top_p"];
|
| 326 |
structured_output?: ConversationEntityMembers["structuredOutput"];
|
| 327 |
+
},
|
| 328 |
): GetInferenceSnippetReturn {
|
| 329 |
const model = conversation.model;
|
| 330 |
const data = conversation.data;
|
| 331 |
+
const provider = (isCustomModel(model) ? "hf-inference" : data.provider) as Provider;
|
| 332 |
|
| 333 |
// If it's a custom model, we don't generate inference snippets
|
| 334 |
if (isCustomModel(model)) {
|
|
|
|
| 336 |
}
|
| 337 |
|
| 338 |
const providerMapping = model.inferenceProviderMapping.find(p => p.provider === provider);
|
| 339 |
+
if (!providerMapping && provider !== "auto") return [];
|
| 340 |
const allSnippets = snippets.getInferenceSnippets(
|
| 341 |
{ ...model, inference: "" },
|
|
|
|
| 342 |
provider,
|
| 343 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 344 |
{ ...providerMapping, hfModelId: model.id } as any,
|
| 345 |
+
{ ...opts, accessToken },
|
| 346 |
);
|
| 347 |
|
| 348 |
return allSnippets
|