From 8c9456e9c5efb28606dce5b2c657bfd6f1be1b14 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 9 Jan 2025 16:20:48 +0000 Subject: [PATCH] expose transformers piplie --- .../src/content/docs/guides/transformers-js.mdx | 17 +---------------- packages/cli/src/runtime.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/docs/src/content/docs/guides/transformers-js.mdx b/docs/src/content/docs/guides/transformers-js.mdx index fb89e6557a..36e22583ec 100644 --- a/docs/src/content/docs/guides/transformers-js.mdx +++ b/docs/src/content/docs/guides/transformers-js.mdx @@ -25,28 +25,13 @@ for more. ::: -## Installation - -Following the [installation instructions](https://huggingface.co/docs/transformers.js/installation), -we add the [@huggingface/transformers](https://www.npmjs.com/package/@huggingface/transformers) to the current project. - -```bash -npm install @huggingface/transformers -``` - -You can also install this library globally to be able to use on any project - -```bash "-g" -npm install -g @huggingface/transformers -``` - ## Import the pipeline The snippet below imports the Transformers.js library and loads the summarizer pipeline and model. You can specify a model name or let the library pick the latest and greatest. ```js -import { pipeline } from "@huggingface/transformers" +import { pipeline } from "genaiscript/runtime" const summarizer = await pipeline("summarization") ``` diff --git a/packages/cli/src/runtime.ts b/packages/cli/src/runtime.ts index 6c4515e3ed..8af4bc1af3 100644 --- a/packages/cli/src/runtime.ts +++ b/packages/cli/src/runtime.ts @@ -2,7 +2,8 @@ * GenAIScript supporting runtime */ import { delay as _delay } from "es-toolkit" -import { z as zod } from "zod" +import { z as _z } from "zod" +import { pipeline as _pipeline } from "@huggingface/transformers" /** * A helper function to delay the execution of the script @@ -12,4 +13,9 @@ export const delay: (ms: number) => Promise = _delay /** * Zod schema generator */ -export const z = zod +export const z = _z + +/** + * HuggingFace transformers.js pipeline apis. + */ +export const pipeline = _pipeline \ No newline at end of file