Skip to content

Commit

Permalink
expose transformers piplie
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 9, 2025
1 parent 4ba9d8c commit 8c9456e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
17 changes: 1 addition & 16 deletions docs/src/content/docs/guides/transformers-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```

Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,4 +13,9 @@ export const delay: (ms: number) => Promise<void> = _delay
/**
* Zod schema generator
*/
export const z = zod
export const z = _z

/**
* HuggingFace transformers.js pipeline apis.
*/
export const pipeline = _pipeline

0 comments on commit 8c9456e

Please sign in to comment.